From c63f962b4369cb1d5c7ca24bfbe3031a831e9e77 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 27 Aug 2022 21:50:24 +0800 Subject: format code --- xmake/rules/c++/modules/modules_support/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmake/rules/c++/modules/modules_support/common.lua') diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 92c92d465..0c0ee4fb7 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -553,7 +553,7 @@ end function append_dependency_objectfiles(target) local cachekey = target:name() .. "dependency_objectfiles" local cache = localcache():get(cachekey) - if cache then + if cache then if target:is_binary() then target:add("ldflags", cache, {force = true}) elseif target:is_static() then -- cgit v1.3.1 From 15617ba485850dd33c2ff8c329a1c24f8631da9f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 27 Aug 2022 22:57:39 +0800 Subject: improve headerunits --- xmake/rules/c++/modules/modules_support/common.lua | 36 +++------------------- xmake/rules/c++/modules/xmake.lua | 19 ++++++++++-- 2 files changed, 21 insertions(+), 34 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support/common.lua') 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 = {} -- cgit v1.3.1