summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/clang.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-01-07 21:35:55 +0800
committerruki <[email protected]>2023-01-07 21:35:55 +0800
commit7781a45723b7c359d5cfb2df309daf66f00342ab (patch)
tree967c4177cc78ea094b36bdf015b9eb0b514d75f3 /xmake/rules/c++/modules/modules_support/clang.lua
parent79685060276a531eb230d05bbeb7b56966620c09 (diff)
support build module with space for clang
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/clang.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua34
1 files changed, 28 insertions, 6 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 02d08e6b0..3dbb7b01d 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -497,7 +497,16 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
_add_module_to_mapper(target, name, bmifile, requiresflags)
end
elseif requiresflags then
- target:fileconfig_add(cppfile, {force = {cxxflags = requiresflags}})
+ local cxxflags = {}
+ for _, flag in ipairs(requiresflags) do
+ -- we need wrap flag to support flag with space
+ if type(flag) == "string" and flag:find(" ", 1, true) then
+ table.insert(cxxflags, {flag})
+ else
+ table.insert(cxxflags, flag)
+ end
+ end
+ target:fileconfig_add(cppfile, {force = {cxxflags = cxxflags}})
end
end)})
modulesjobs[name or cppfile] = moduleinfo
@@ -553,7 +562,16 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op
not provide and {"-x", "c++"} or {}, {"-c", file, "-o", path(objectfile)}))
target:add("objectfiles", objectfile)
elseif requiresflags then
- target:fileconfig_add(cppfile, {force = {cxxflags = requiresflags}})
+ local cxxflags = {}
+ for _, flag in ipairs(requiresflags) do
+ -- we need wrap flag to support flag with space
+ if type(flag) == "string" and flag:find(" ", 1, true) then
+ table.insert(cxxflags, {flag})
+ else
+ table.insert(cxxflags, flag)
+ end
+ end
+ target:fileconfig_add(cppfile, {force = {cxxflags = cxxflags}})
end
batchcmds:add_depfiles(cppfile)
@@ -701,8 +719,10 @@ function get_requiresflags(target, requires)
local modulemap_ = _get_modulemap_from_mapper(dep, name)
if modulemap_ then
already_mapped_modules[name] = true
- table.join2(flags, modulemap_.flag)
- table.join2(flags, modulemap_.deps or {})
+ table.insert(flags, modulemap_.flag)
+ if modulemap_.deps then
+ table.shallow_join2(flags, modulemap_.deps)
+ end
goto continue
end
end
@@ -711,8 +731,10 @@ function get_requiresflags(target, requires)
local modulemap = _get_modulemap_from_mapper(target, name)
if modulemap then
already_mapped_modules[name] = true
- table.join2(flags, modulemap.flag)
- table.join2(flags, modulemap.deps or {})
+ table.insert(flags, modulemap.flag)
+ if modulemap.deps then
+ table.shallow_join2(flags, modulemap.deps)
+ end
goto continue
end