diff options
| author | ruki <[email protected]> | 2022-08-06 00:59:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-06 00:59:10 +0800 |
| commit | 53c31dfffd73cd635a6512d49b902e8c45dca102 (patch) | |
| tree | 998921520a998224de105e5dcfb637a6ba85a38c /xmake/rules/c++/modules/xmake.lua | |
| parent | 8ac03c2d83d6cf5b9509ab2d4e756998711886b8 (diff) | |
add batchjobs stub
Diffstat (limited to 'xmake/rules/c++/modules/xmake.lua')
| -rw-r--r-- | xmake/rules/c++/modules/xmake.lua | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index a4288034d..6d0da85c2 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -22,7 +22,6 @@ rule("c++.build.modules") set_extensions(".mpp", ".mxx", ".cppm", ".ixx") - add_deps("c++.build.modules.dependencies") add_deps("c++.build.modules.builder") add_deps("c++.build.modules.install") @@ -49,45 +48,58 @@ rule("c++.build.modules") end end) --- build dependencies -rule("c++.build.modules.dependencies") - before_buildcmd(function(target, batchcmds, opt) - if target:data("cxx.has_modules") then - import("modules_support.common") - local sourcebatch = target:sourcebatches()["c++.build.modules.builder"] - common.patch_sourcebatch(target, sourcebatch) - local modules = common.generate_dependencies(target, sourcebatch, opt) - target:data_set("cxx.modules", modules) - end - end) - -- build modules rule("c++.build.modules.builder") set_sourcekinds("cxx") set_extensions(".mpp", ".mxx", ".cppm", ".ixx") - before_buildcmd_files(function(target, batchcmds, sourcebatch, opt) + -- 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 + -- 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}) + end + + -- build modules + common.build_modules_for_batchjobs(target, batchjobs, sourcebatch, modules, opt) + 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 -- 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(target, batchcmds, sourcebatch, opt) + local headerunits_flags = common.generate_headerunits_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) if headerunits_flags then target:add("cxxflags", headerunits_flags, {force = true, expand = false}) end - -- topological sort - local modules = target:data("cxx.modules") - local modules_support = common.modules_support(target) - local objectfiles = common.sort_modules_by_dependencies(sourcebatch.objectfiles, modules) - modules_support.build_modules(target, batchcmds, objectfiles, modules, opt) + -- build modules + common.build_modules_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) end) -- install modules |
