diff options
| author | ruki <[email protected]> | 2022-08-27 22:57:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-27 22:57:39 +0800 |
| commit | 15617ba485850dd33c2ff8c329a1c24f8631da9f (patch) | |
| tree | 74cdb84b69c4feffdf81c8fb998d55de3c4ce47b /xmake/rules/c++ | |
| parent | 21ef485f37c1e1901914f8419b252715713cc247 (diff) | |
improve headerunits
Diffstat (limited to 'xmake/rules/c++')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 36 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/xmake.lua | 19 |
2 files changed, 21 insertions, 34 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 0c0ee4fb7..ae1b1ca9e 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -459,41 +459,15 @@ function get_module_dependencies(target, sourcebatch, opt) return modules end --- generate headerunits for batchjobs -function generate_headerunits_for_batchjobs(target, batchjobs, sourcebatch, modules, opt) - - -- get headerunits info - local headerunits, stl_headerunits = get_headerunits(target, sourcebatch, modules) - - -- generate headerunits - -- build stl header units as other headerunits may need them - local headerunits_flags - if stl_headerunits then - headerunits_flags = headerunits_flags or {} - table.join2(headerunits_flags, modules_support(target).generate_stl_headerunits_for_batchjobs(target, batchjobs, stl_headerunits, opt)) - end - if headerunits then - headerunits_flags = headerunits_flags or {} - table.join2(headerunits_flags, modules_support(target).generate_user_headerunits_for_batchjobs(target, batchjobs, headerunits, opt)) - end - return headerunits_flags -end - -- generate headerunits for batchcmds function generate_headerunits_for_batchcmds(target, batchcmds, sourcebatch, modules, opt) - - -- get headerunits info local user_headerunits, stl_headerunits = get_headerunits(target, sourcebatch, modules) - - -- generate headerunits -- build stl header units as other headerunits may need them - if stl_headerunits or user_headerunits then - if stl_headerunits then - modules_support(target).generate_stl_headerunits_for_batchcmds(target, batchcmds, stl_headerunits, opt) - end - if user_headerunits then - modules_support(target).generate_user_headerunits_for_batchcmds(target, batchcmds, user_headerunits, opt) - end + if stl_headerunits then + modules_support(target).generate_stl_headerunits_for_batchcmds(target, batchcmds, stl_headerunits, opt) + end + if user_headerunits then + modules_support(target).generate_user_headerunits_for_batchcmds(target, batchcmds, user_headerunits, opt) end end diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index 387534fe0..4a7193710 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -63,9 +63,22 @@ rule("c++.build.modules.builder") 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", {rootjob = opt.rootjob}) - common.generate_headerunits_for_batchjobs(target, batchjobs, sourcebatch, modules, opt) + local user_headerunits, stl_headerunits = common.get_headerunits(target, sourcebatch, modules) + if user_headerunits or stl_headerunits then + -- we need new group(headerunits) + -- e.g. group(build_modules) -> group(headerunits) + opt.rootjob = batchjobs:group_leave() or opt.rootjob + batchjobs:group_enter(target:name() .. "/generate_headerunits", {rootjob = opt.rootjob}) + local modules_support = common.modules_support(target) + if stl_headerunits then + -- build stl header units as other headerunits may need them + -- TODO maybe we need new group(build_modules) -> group(user_headerunits) -> group(stl_headerunits) + modules_support.generate_stl_headerunits_for_batchjobs(target, batchjobs, stl_headerunits, opt) + end + if user_headerunits then + modules_support.generate_user_headerunits_for_batchjobs(target, batchjobs, user_headerunits, opt) + end + end else -- avoid duplicate linking of object files of non-module programs sourcebatch.objectfiles = {} |
