summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/gcc.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-12-06 19:10:17 +0100
committerArthur LAURENT <[email protected]>2022-12-07 01:08:58 +0100
commitb0f325733ca94d1f6286167144c3e3bc97082b31 (patch)
treee1b05e1af58a8ae19e6ab58606e265018b396f5e /xmake/rules/c++/modules/modules_support/gcc.lua
parent36b847657952d6f3d97ba827a4d1dc8fe9163c8b (diff)
fix gcc
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/gcc.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua30
1 files changed, 18 insertions, 12 deletions
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index 9754b63ee..7c7db66e8 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -67,22 +67,12 @@ end
-- load module support for the current target
function load(target)
local modulesflag = get_modulesflag(target)
- local modulemapperflag = get_modulemapperflag(target)
target:add("cxxflags", modulesflag)
if os.isfile(_get_module_mapper(target)) then
os.rm(_get_module_mapper(target))
end
- target:add("cxxflags", modulemapperflag .. _get_module_mapper(target), {force = true, expand = false})
-- fix cxxabi issue, @see https://github.com/xmake-io/xmake/issues/2716#issuecomment-1225057760
target:add("cxxflags", "-D_GLIBCXX_USE_CXX11_ABI=0")
- local deps_mappers
- for _, dep in ipairs(target:orderdeps()) do
- deps_mappers = deps_mappers or {}
- table.insert(deps_mappers, 1, modulemapperflag .. _get_module_mapper(dep))
- end
- if deps_mappers then
- target:add("cxxflags", deps_mappers, {force = true, expand = false})
- end
end
-- get includedirs for stl headers
@@ -116,7 +106,8 @@ function _build_modulefile(target, sourcefile, opt)
local objectfile = opt.objectfile
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
- local compflags = table.join("-x", "c++", compinst:compflags({target = target}))
+ local modulemapperflag = get_modulemapperflag(target)
+ local compflags = table.join("-x", "c++", modulemapperflag .. path.translate(_get_module_mapper(target)), compinst:compflags({target = target}))
local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
-- need build this object?
@@ -464,6 +455,7 @@ end
-- build module files for batchcmds
function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, opt)
local compinst = target:compiler("cxx")
+ local modulemapperflag = get_modulemapperflag(target)
local mapper_file = _get_module_mapper(target)
-- build modules
@@ -487,7 +479,21 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op
break
end
end
- local flags = {"-x", "c++","-c", path(cppfile), "-o", path(objectfile)}
+ -- append dependencies module now to ensures deps modulemap is filled
+ for required, _ in pairs(module.requires) do
+ local m
+ for _, dep in ipairs(target:orderdeps()) do
+ m = _get_module_from_mapper(_get_module_mapper(dep), required)
+ if m then
+ break
+ end
+ end
+ if m then
+ _add_module_to_mapper(mapper_file, m[1], m[2])
+ break
+ end
+ end
+ local flags = {"-x", "c++", modulemapperflag .. path.translate(_get_module_mapper(target)),"-c", path(cppfile), "-o", path(objectfile)}
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.module.$(mode) %s", name or cppfile)
batchcmds:mkdir(path.directory(objectfile))
batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), flags))