Compare commits

...

2 Commits

Author SHA1 Message Date
Zhicheng Wang 56b5259a37 fix header distribution of headeronly project 5 days ago
Zhicheng Wang 2e56bb6f18 change mimalloc to static library 1 week ago
  1. 6
      shared_module/xmake.lua
  2. 22
      xmake/rules/library/shared/xmake.lua

6
shared_module/xmake.lua

@ -1,4 +1,4 @@
add_requires("mimalloc-adjust") add_requires("mimalloc", {configs = {shared = false}})
add_requires("parallel-hashmap") add_requires("parallel-hashmap")
add_requires("range-v3") add_requires("range-v3")
add_requires("eigen-latest") add_requires("eigen-latest")
@ -8,6 +8,6 @@ add_requires("xxhash")
target("shared_module") target("shared_module")
set_kind("headeronly") set_kind("headeronly")
add_includedirs("./", {public = true}) add_includedirs("./", {public = true})
add_packages("mimalloc-adjust", "parallel-hashmap", "range-v3", "eigen-latest", "xxhash", {public = true}) add_packages("mimalloc", "parallel-hashmap", "range-v3", "eigen-latest", "xxhash", {public = true})
add_rules("library.force.distribute.header", {headers = path.join(os.scriptdir(), "math", "math_defs.h")}) add_rules("library.headeronly.distribute.header", {projectdir = os.scriptdir()})
target_end() target_end()

22
xmake/rules/library/shared/xmake.lua

@ -18,8 +18,9 @@ rule_end()
rule("library.distribute.header") rule("library.distribute.header")
after_build(function (target) after_build(function (target)
local projectdir = target:extraconf("rules", "library.distribute.header", "projectdir") local projectdir = target:extraconf("rules", "library.distribute.header", "projectdir")
local outputdir = path.join(target:targetdir(), "..", "include") local outputdir = path.join(os.projectdir(), "distribute", "include")
if has_config("shipping_one") then if has_config("shipping_one") then
print("Distributing header files for project: " .. target:name())
for _, filepath in ipairs(os.files(path.join(projectdir, "interface", "*.h"))) do for _, filepath in ipairs(os.files(path.join(projectdir, "interface", "*.h"))) do
local file = io.readfile(filepath) local file = io.readfile(filepath)
@ -32,6 +33,7 @@ rule("library.distribute.header")
local replace_api2 = string.gsub(replace_api1, "API", "__declspec(dllimport)") local replace_api2 = string.gsub(replace_api1, "API", "__declspec(dllimport)")
io.writefile(path.join(outputdir, path.filename(filepath)), replace_api2) io.writefile(path.join(outputdir, path.filename(filepath)), replace_api2)
print("Distributed header file: " .. path.filename(filepath))
end end
end end
end) end)
@ -40,8 +42,9 @@ rule_end()
rule("library.force.distribute.header") rule("library.force.distribute.header")
after_build(function (target) after_build(function (target)
local headers = target:extraconf("rules", "library.force.distribute.header", "headers") local headers = target:extraconf("rules", "library.force.distribute.header", "headers")
local outputdir = path.join(target:targetdir(), "..", "include") local outputdir = path.join(os.projectdir(), "distribute", "include")
if has_config("shipping_one") then if has_config("shipping_one") then
print("Forcing distribution of header files: " .. headers)
for _, filepath in ipairs(os.files(headers)) do for _, filepath in ipairs(os.files(headers)) do
local file = io.readfile(filepath) local file = io.readfile(filepath)
@ -54,6 +57,21 @@ rule("library.force.distribute.header")
local replace_api2 = string.gsub(replace_api1, "API", "__declspec(dllimport)") local replace_api2 = string.gsub(replace_api1, "API", "__declspec(dllimport)")
io.writefile(path.join(outputdir, path.filename(filepath)), replace_api2) io.writefile(path.join(outputdir, path.filename(filepath)), replace_api2)
print("Forced distribution of header file: " .. path.filename(filepath))
end
end
end)
rule_end()
rule("library.headeronly.distribute.header")
on_build(function (target)
print("Distributing header files for header-only library: " .. target:name())
local projectdir = target:extraconf("rules", "library.headeronly.distribute.header", "projectdir")
local outputdir = path.join(os.projectdir(), "distribute", "include")
if has_config("shipping_one") then
for _, filepath in ipairs(os.files(path.join(projectdir, "**", "*.h"))) do
os.cp(filepath, outputdir)
print("Distributed header file: " .. path.filename(filepath))
end end
end end
end) end)

Loading…
Cancel
Save