diff options
| author | ruki <[email protected]> | 2022-08-08 23:31:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-08 23:31:35 +0800 |
| commit | ad67a37fe4981f68c52ae1e7497090a60a30edab (patch) | |
| tree | eb07345f116359a3f0810753277bb1f797ecda3e | |
| parent | d0e4316018f9d75742b26b3abf75860d129c31c8 (diff) | |
fix module dpes
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 9 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/xmake.lua | 28 |
2 files changed, 20 insertions, 17 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 52a428874..ee1016d68 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -413,18 +413,19 @@ end -- get module dependencies function get_module_dependencies(target, sourcebatch, opt) - local modules = _g.modules + local cachekey = target:name() .. "/" .. sourcebatch.rulename + local modules = memcache():get2("modules", cachekey) if modules == nil then - modules = localcache():get("modules") + modules = localcache():get2("modules", cachekey) opt.progress = opt.progress or 0 local changed = modules_support(target).generate_dependencies(target, sourcebatch, opt) if changed or modules == nil then local moduleinfos = load_moduleinfos(target, sourcebatch) modules = parse_dependency_data(target, moduleinfos) - localcache():set("modules", modules) + localcache():set2("modules", cachekey, modules) localcache():save() end - _g.modules = modules + memcache():set2("modules", cachekey, modules) end return modules end diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index 7048ec49b..3c69600bd 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -50,6 +50,7 @@ rule("c++.build.modules") -- build modules rule("c++.build.modules.builder") + set_sourcekinds("cxx") set_extensions(".mpp", ".mxx", ".cppm", ".ixx") -- parallel build support to accelerate `xmake build` to build headerunits @@ -75,27 +76,28 @@ rule("c++.build.modules.builder") import("modules_support.common") local modules = common.get_module_dependencies(target, sourcebatch, opt) common.build_modules_for_batchjobs(target, batchjobs, sourcebatch, modules, opt) + else + sourcebatch.objectfiles = {} end end, {batch = true}) -- serial compilation only, usually used to support project generator before_buildcmd_files(function(target, batchcmds, sourcebatch, opt) - if not target:data("cxx.has_modules") then - return - end - - -- patch sourcebatch - import("modules_support.common") - common.patch_sourcebatch(target, sourcebatch, opt) + if target:data("cxx.has_modules") then + import("modules_support.common") - -- get module dependencies - local modules = common.get_module_dependencies(target, sourcebatch, opt) + -- patch sourcebatch + common.patch_sourcebatch(target, sourcebatch, opt) - -- generate headerunits - common.generate_headerunits_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) + -- generate headerunits + local modules = common.get_module_dependencies(target, sourcebatch, opt) + common.generate_headerunits_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) - -- build modules - common.build_modules_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) + -- build modules + common.build_modules_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) + else + sourcebatch.objectfiles = {} + end end) before_link(function(target) |
