diff options
| author | ruki <[email protected]> | 2022-08-06 00:49:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-06 00:49:37 +0800 |
| commit | 11c04bf269dba07285bbbc50dee6fa13cdc15f8d (patch) | |
| tree | 901f34aae756ed3e8c60697ef438a84042f6bf9a /xmake/rules/c++ | |
| parent | bee2b91e6e7171c5034f2beef7bb6d0f1af247d8 (diff) | |
wrap generate headerunits
Diffstat (limited to 'xmake/rules/c++')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 30 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/xmake.lua | 20 |
2 files changed, 26 insertions, 24 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 2cba5fe89..b5a49e680 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -406,16 +406,28 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile) end -- generate dependencies -function generate_dependencies(target, opt) - - -- get sourcebatch - local sourcebatch = target:sourcebatches()["c++.build.modules.builder"] - patch_sourcebatch(target, sourcebatch) - - -- generate dependencies +function generate_dependencies(target, sourcebatch, opt) modules_support(target).generate_dependencies(target, sourcebatch, opt) - - -- load and parse module dependencies local moduleinfos = load_moduleinfos(target, sourcebatch) return parse_dependency_data(target, moduleinfos) end + +-- generate headerunits +function generate_headerunits(target, batchcmds, sourcebatch, opt) + + -- get headerunits info + local headerunits, stl_headerunits = get_headerunits(target, sourcebatch) + + -- generate headerunits + local headerunits_flags + -- build stl header units as other headerunits may need them + if stl_headerunits then + headerunits_flags = headerunits_flags or {} + table.join2(headerunits_flags, modules_support(target).generate_stl_headerunits(target, batchcmds, stl_headerunits, opt)) + end + if headerunits then + headerunits_flags = headerunits_flags or {} + table.join2(headerunits_flags, modules_support(target).generate_user_headerunits(target, batchcmds, headerunits, opt)) + end + return headerunits_flags +end diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index d3dac2b69..321ee5089 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -54,7 +54,9 @@ rule("c++.build.modules.dependencies") before_buildcmd(function(target, batchcmds, opt) if target:data("cxx.has_modules") then import("modules_support.common") - local modules = common.generate_dependencies(target, opt) + 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) @@ -76,27 +78,15 @@ rule("c++.build.modules.builder") -- patch sourcebatch common.patch_sourcebatch(target, sourcebatch, opt) - -- get headerunits info - local headerunits, stl_headerunits = common.get_headerunits(target, sourcebatch) - -- generate headerunits - local headerunits_flags - local modules_support = common.modules_support(target) - -- build stl header units as other headerunits may need them - if stl_headerunits then - headerunits_flags = headerunits_flags or {} - table.join2(headerunits_flags, modules_support.generate_stl_headerunits(target, batchcmds, stl_headerunits, opt)) - end - if headerunits then - headerunits_flags = headerunits_flags or {} - table.join2(headerunits_flags, modules_support.generate_user_headerunits(target, batchcmds, headerunits, opt)) - end + local headerunits_flags = common.generate_headerunits(target, batchcmds, sourcebatch, 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) end) |
