forked from DawnMagnet/bitserial
Refactor code structure for improved readability and maintainability
This commit is contained in:
+1162
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,50 @@ if is_plat("mingw") then
|
||||
add_ldflags("-static", "-static-libgcc", "-static-libstdc++")
|
||||
end
|
||||
|
||||
task("export_all")
|
||||
set_menu {
|
||||
usage = "xmake export_all",
|
||||
description = "Generate the single-header bitserial_all.hpp"
|
||||
}
|
||||
on_run(function ()
|
||||
local rootdir = os.projectdir()
|
||||
local output = path.join(rootdir, "bitserial_all.hpp")
|
||||
local headers = {
|
||||
"include/bitserial/detail/config.hpp",
|
||||
"include/bitserial/bit_io.hpp",
|
||||
"include/bitserial/bulk.hpp",
|
||||
"include/bitserial/bitserial.hpp"
|
||||
}
|
||||
local out = {
|
||||
"// This file is generated by `xmake export_all`.",
|
||||
"// Do not edit it directly; edit headers under include/bitserial instead.",
|
||||
"#pragma once"
|
||||
}
|
||||
|
||||
local function append_header(header)
|
||||
table.insert(out, "")
|
||||
table.insert(out, "// =============================================================================")
|
||||
table.insert(out, "// " .. header)
|
||||
table.insert(out, "// =============================================================================")
|
||||
|
||||
local content = io.readfile(path.join(rootdir, header))
|
||||
content = content:gsub("\r\n", "\n")
|
||||
for line in (content .. "\n"):gmatch("(.-)\n") do
|
||||
if not line:match("^%s*#pragma%s+once%s*$") and
|
||||
not line:match("^%s*#%s*include%s*[<\"]bitserial/") then
|
||||
table.insert(out, line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, header in ipairs(headers) do
|
||||
append_header(header)
|
||||
end
|
||||
|
||||
io.writefile(output, table.concat(out, "\n") .. "\n")
|
||||
cprint("${bright green}generated ${clear}%s", output)
|
||||
end)
|
||||
|
||||
target("bitserial")
|
||||
set_kind("headeronly")
|
||||
add_headerfiles("bitserial.hpp", "include/(bitserial/**.hpp)")
|
||||
|
||||
Reference in New Issue
Block a user