summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÂngelo Andrade Cirino <[email protected]>2022-01-17 15:49:50 -0300
committerÂngelo Andrade Cirino <[email protected]>2022-01-17 15:57:48 -0300
commit1b2a5da03aea8f9082204c345e852ee69bd6cec4 (patch)
treeb954e5f500119ca80b5a05b983cdbd2091ca72e1
parent92978c6f56ab66e17e19776d2e35832fa8be6e97 (diff)
Solved building submodules with clang
-rw-r--r--xmake/rules/c++/modules/build_modules/clang.lua11
-rw-r--r--xmake/rules/c++/modules/build_modules/module_parser.lua9
2 files changed, 14 insertions, 6 deletions
diff --git a/xmake/rules/c++/modules/build_modules/clang.lua b/xmake/rules/c++/modules/build_modules/clang.lua
index 523c61ad9..49ae5b2de 100644
--- a/xmake/rules/c++/modules/build_modules/clang.lua
+++ b/xmake/rules/c++/modules/build_modules/clang.lua
@@ -89,7 +89,7 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt)
local sourcefiles_total = #sourcebatch.sourcefiles
for i = 1, sourcefiles_total do
local sourcefile = sourcebatch.sourcefiles[i]
- local moduledep = assert(moduledeps_files[sourcefile], "moduledep(%s) not found!", sourcefile)
+ local moduledep = moduledeps_files[sourcefile] or {}
moduledep.job = batchjobs:newjob(sourcefile, function (index, total)
-- compile module files to *.pcm
@@ -100,6 +100,14 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt)
opt2.objectfile = modulefiles[i]
opt2.dependfile = target:dependfile(opt2.objectfile)
opt2.sourcekind = assert(sourcebatch.sourcekind, "%s: sourcekind not found!", sourcefile)
+ if moduledep["deps"] then
+ for _, modulefile in ipairs(modulefiles) do
+ local found = modulefile:find(moduledep["name"])
+ if found == nil then
+ target:add("cxxflags", "-fmodule-file=" .. modulefile, {force = true})
+ end
+ end
+ end
objectbuilder.build_object(target, sourcefile, opt2)
-- compile *.pcm to object files
@@ -136,4 +144,3 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt)
end
end
end
-
diff --git a/xmake/rules/c++/modules/build_modules/module_parser.lua b/xmake/rules/c++/modules/build_modules/module_parser.lua
index b97b7e1d0..881f2b48f 100644
--- a/xmake/rules/c++/modules/build_modules/module_parser.lua
+++ b/xmake/rules/c++/modules/build_modules/module_parser.lua
@@ -84,15 +84,16 @@ function load(target, sourcebatch, opt)
generate(target, sourcebatch, opt)
-- load deps
- local moduledeps
+ local moduledeps = moduledeps or {}
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local dependfile = _get_dependfile_of_modulesource(target, sourcefile)
if os.isfile(dependfile) then
local data = io.load(dependfile)
if data then
- local moduleinfo = data.moduleinfo
- moduledeps = moduledeps or {}
- moduledeps[moduleinfo.name] = moduleinfo
+ if data.moduleinfo then
+ local moduleinfo = data.moduleinfo
+ moduledeps[moduleinfo.name] = moduleinfo
+ end
end
end
end