summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-08 22:40:44 +0800
committerruki <[email protected]>2022-08-08 22:40:44 +0800
commit1fb045a19472a8d04d24cb41c49a3bf75b2767d2 (patch)
treebd52399f33cb7c2434b0112d83864a420528111a /xmake/rules/c++/modules/xmake.lua
parenteac8fac2b08d6d2d16b7b9fe091e5594d091027d (diff)
add batchjobs for gcc
Diffstat (limited to 'xmake/rules/c++/modules/xmake.lua')
-rw-r--r--xmake/rules/c++/modules/xmake.lua47
1 files changed, 23 insertions, 24 deletions
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index 4117004cc..3efa123e6 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -53,35 +53,34 @@ rule("c++.build.modules.builder")
set_sourcekinds("cxx")
set_extensions(".mpp", ".mxx", ".cppm", ".ixx")
- -- TODO parallel build support to accelerate `xmake build` to build modules
- --[[
- before_build_files(function(target, batchjobs, sourcebatch, opt)
- if not target:data("cxx.has_modules") then
- sourcebatch.objectfiles = {}
- return
- end
+ 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)
- -- patch sourcebatch
- import("modules_support.common")
- common.patch_sourcebatch(target, sourcebatch, opt)
-
- -- generate dependencies
- local modules = common.generate_dependencies(target, sourcebatch, opt)
-
- -- generate headerunits
- local headerunits_flags = common.generate_headerunits_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
- if headerunits_flags then
- target:add("cxxflags", headerunits_flags, {force = true, expand = false})
+ -- 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
- common.build_modules_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
- end, {batch = true})]]
+ -- parallel build support to accelerate `xmake build` to build modules
+ before_build_files(function(target, batchjobs, sourcebatch, opt)
+ if target:data("cxx.has_modules") then
+ import("modules_support.common")
+ local modules = common.get_module_dependencies(target, sourcebatch, opt)
+ common.build_modules_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
+ 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
- sourcebatch.objectfiles = {}
return
end
@@ -89,8 +88,8 @@ rule("c++.build.modules.builder")
import("modules_support.common")
common.patch_sourcebatch(target, sourcebatch, opt)
- -- generate dependencies
- local modules = common.generate_dependencies(target, sourcebatch, opt)
+ -- get module dependencies
+ local modules = common.get_module_dependencies(target, sourcebatch, opt)
-- generate headerunits
common.generate_headerunits_for_batchcmds(target, batchcmds, sourcebatch, modules, opt)