summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/gcc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/gcc.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index ef04c6952..9754b63ee 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -55,6 +55,15 @@ function _add_module_to_mapper(file, module, bmi)
return true
end
+function _get_module_from_mapper(file, module)
+ for line in io.lines(file) do
+ if line:startswith(module .. " ") then
+ return line:split(" ", {plain = true})
+ end
+ end
+ return nil
+end
+
-- load module support for the current target
function load(target)
local modulesflag = get_modulesflag(target)
@@ -417,6 +426,20 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
deps = table.keys(module.requires or {}),
sourcefile = cppfile,
job = batchjobs:newjob(name or cppfile, function(index, total)
+ -- 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
if provide or common.has_module_extension(cppfile) then
_build_modulefile(target, cppfile, {