diff options
| author | ruki <[email protected]> | 2022-01-19 10:21:54 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-19 10:21:54 +0800 |
| commit | 093fcdb414bcf289d1c621768ded2bcb6a00fe46 (patch) | |
| tree | 98a13679cbb7867e5e34f503132b2248da341baa | |
| parent | 07bbfefb26b8f0489b55b1e4af0d98671e53ff28 (diff) | |
| parent | f4056bea6f7bf0cc10cc54ead8305d448d5d1fae (diff) | |
Merge pull request #1982 from aacirino/fix_clang_submodules
Fix clang submodules
| -rw-r--r-- | xmake/rules/c++/modules/build_modules/clang.lua | 14 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/build_modules/module_parser.lua | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/xmake/rules/c++/modules/build_modules/clang.lua b/xmake/rules/c++/modules/build_modules/clang.lua index 523c61ad9..4cde11419 100644 --- a/xmake/rules/c++/modules/build_modules/clang.lua +++ b/xmake/rules/c++/modules/build_modules/clang.lua @@ -66,16 +66,13 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt) local cachedir = path.join(target:autogendir(), "rules", "modules", "cache") -- we need patch objectfiles to sourcebatch for linking module objects - local modulefiles = {} sourcebatch.sourcekind = "cxx" sourcebatch.objectfiles = sourcebatch.objectfiles or {} sourcebatch.dependfiles = sourcebatch.dependfiles or {} for _, sourcefile in ipairs(sourcebatch.sourcefiles) do - local modulefile = path.join(cachedir, path.basename(sourcefile) .. ".pcm") local objectfile = target:objectfile(sourcefile) table.insert(sourcebatch.objectfiles, objectfile) table.insert(sourcebatch.dependfiles, target:dependfile(objectfile)) - table.insert(modulefiles, modulefile) end -- load moduledeps @@ -86,10 +83,18 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt) -- compile module files to object files local count = 0 + local modulefiles = {} 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 {} + + -- make module file path, @note we need process submodule name, e.g. module.submodule.mpp -> module.submodule.pcm + -- @see https://github.com/xmake-io/xmake/pull/1982 + local modulefile = path.join(cachedir, (moduledep.name or path.basename(sourcefile)) .. ".pcm") + table.insert(modulefiles, modulefile) + + -- make build job moduledep.job = batchjobs:newjob(sourcefile, function (index, total) -- compile module files to *.pcm @@ -136,4 +141,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..5f7bee717 100644 --- a/xmake/rules/c++/modules/build_modules/module_parser.lua +++ b/xmake/rules/c++/modules/build_modules/module_parser.lua @@ -91,8 +91,10 @@ function load(target, sourcebatch, opt) local data = io.load(dependfile) if data then local moduleinfo = data.moduleinfo - moduledeps = moduledeps or {} - moduledeps[moduleinfo.name] = moduleinfo + if moduleinfo then + moduledeps = moduledeps or {} + moduledeps[moduleinfo.name] = moduleinfo + end end end end |
