diff options
| author | ruki <[email protected]> | 2023-01-08 10:48:39 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-08 10:48:39 +0800 |
| commit | 1b19d2ba990e8714d0298de50d009ee7ff6576e5 (patch) | |
| tree | 3a90a3e96ab35b2ff9f86fce174abea25292b46b /xmake/rules/c++/modules/modules_support/clang.lua | |
| parent | 06829c1ac295a74a62e4c2b9a1732017d1d7a80d (diff) | |
| parent | b5e29bdae4f381e343632cf5ea51224aea8f720a (diff) | |
Merge pull request #3228 from Arthapz/support-c++20-module-packages
Add support of importing modules from packages
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/clang.lua')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 3dbb7b01d..0f159ae57 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.json") import("core.tool.compiler") import("core.project.project") import("core.project.depend") @@ -471,6 +472,24 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op end end local moduleinfo = table.copy(provide) or {} + + if provide then + local fileconfig = target:fileconfig(cppfile) + if fileconfig and fileconfig.install then + batchjobs:addjob(name .. "_metafile", function(index, total) + local cachedir = common.modules_cachedir(target) + local metafilepath = path.join(cachedir, path.filename(cppfile) .. ".meta-info") + depend.on_changed(function() + progress.show(opt.progress, "${color.build.object}generating.module.metadata %s", name) + local metadata = common.generate_meta_module_info(target, name, cppfile, module.requires) + json.savefile(metafilepath, metadata) + + end, {dependfile = target:dependfile(metafilepath), files = {cppfile}}) + + end, {rootjob = flushjob}) + end + end + table.join2(moduleinfo, { name = name or cppfile, deps = table.keys(module.requires or {}), @@ -484,13 +503,18 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op if provide or common.has_module_extension(cppfile) then local bmifile = provide and provide.bmi - _build_modulefile(target, provide and provide.sourcefile or cppfile, { - objectfile = objectfile, - dependfile = target:dependfile(bmifile or objectfile), - provide = provide and {bmifile = bmifile, name = name}, - common_args = common_args, - requiresflags = requiresflags, - progress = (index * 100) / total}) + if not common.memcache():get2(name or cppfile, "compiling") then + if name and module.external then + common.memcache():set2(name or cppfile, "compiling", true) + end + _build_modulefile(target, provide and provide.sourcefile or cppfile, { + objectfile = objectfile, + dependfile = target:dependfile(bmifile or objectfile), + provide = provide and {bmifile = bmifile, name = name}, + common_args = common_args, + requiresflags = requiresflags, + progress = (index * 100) / total}) + end target:add("objectfiles", objectfile) if provide then |
