summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/xmake.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/rules/c++/modules/xmake.lua')
-rw-r--r--xmake/rules/c++/modules/xmake.lua25
1 files changed, 7 insertions, 18 deletions
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index 062dea52b..8a05ff0e0 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -52,24 +52,6 @@ rule("c++.build.modules.builder")
set_sourcekinds("cxx")
set_extensions(".mpp", ".mxx", ".cppm", ".ixx")
- -- generate headerunits
- -- parallel build support to accelerate `xmake build` to build headerunits
- before_build(function(target, batchjobs, opt)
- local job
- if target:data("cxx.has_modules") then
- import("modules_support.common")
- local sourcebatch = target:sourcebatches()["c++.build.modules.builder"]
- common.patch_sourcebatch(target, sourcebatch, opt)
-
- -- generate headerunits
- local modules = common.get_module_dependencies(target, sourcebatch, opt)
- batchjobs:group_enter(target:name() .. "/generate_headerunits")
- common.generate_headerunits_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
- job = batchjobs:group_leave()
- end
- return job or opt.rootjob
- end, {batch = true})
-
-- build modules
-- parallel build support to accelerate `xmake build` to build modules
before_build_files(function(target, batchjobs, sourcebatch, opt)
@@ -77,7 +59,14 @@ rule("c++.build.modules.builder")
import("modules_support.common")
common.patch_sourcebatch(target, sourcebatch, opt)
local modules = common.get_module_dependencies(target, sourcebatch, opt)
+
+ -- build modules
common.build_modules_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
+
+ -- generate headerunits and we need do it before building modules
+ opt.rootjob = batchjobs:group_leave() or opt.rootjob
+ batchjobs:group_enter(target:name() .. "/generate_headerunits")
+ common.generate_headerunits_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
else
-- avoid duplicate linking of object files of non-module programs
sourcebatch.objectfiles = {}