From dc73c38303b736a8dec9ac4df0ed0a3a7f55d318 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Fri, 4 Oct 2024 17:52:17 +0200 Subject: fix module dependency flags update --- .../rules/c++/modules/modules_support/builder.lua | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'xmake/rules/c++/modules/modules_support/builder.lua') diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua index f651e2b69..51e87a8a8 100644 --- a/xmake/rules/c++/modules/modules_support/builder.lua +++ b/xmake/rules/c++/modules/modules_support/builder.lua @@ -21,6 +21,7 @@ -- imports import("core.base.json") import("core.base.option") +import("core.base.hashset") import("async.runjobs") import("private.async.buildjobs") import("core.tool.compiler") @@ -460,3 +461,32 @@ function add_headerunit_to_target_mapper(target, headerunit, bmifile) return deduplicated and true or false end +-- check if dependencies changed +function is_dependencies_changed(target, module) + local cachekey = target:name() .. module.name + + for required, _ in table.orderpairs(module.requires) do + requires = requires or hashset.new() + requires:insert(required) + end + + local oldrequires = compiler_support.memcache():get2(cachekey, "oldrequires") + or compiler_support.localcache():get2(cachekey, "oldrequires") + + local changed = false + if oldrequires and requires then + oldrequires = hashset.from(oldrequires) + if oldrequires:size() ~= requires:size() then + requires_changed = true + else + for required in requires:keys() do + if not oldrequires:has(required) then + requires_changed = true + break + end + end + end + end + + return requires:to_array(), changed +end -- cgit v1.3.1 From 6cf96ccaf32860e128a5447c48a1f1dcd6b216de Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sat, 5 Oct 2024 18:48:41 +0200 Subject: add missing local variable declaration for moduler build --- xmake/rules/c++/modules/modules_support/builder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmake/rules/c++/modules/modules_support/builder.lua') diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua index 51e87a8a8..9133bad60 100644 --- a/xmake/rules/c++/modules/modules_support/builder.lua +++ b/xmake/rules/c++/modules/modules_support/builder.lua @@ -465,13 +465,13 @@ end function is_dependencies_changed(target, module) local cachekey = target:name() .. module.name + local requires for required, _ in table.orderpairs(module.requires) do requires = requires or hashset.new() requires:insert(required) end local oldrequires = compiler_support.memcache():get2(cachekey, "oldrequires") - or compiler_support.localcache():get2(cachekey, "oldrequires") local changed = false if oldrequires and requires then -- cgit v1.3.1 From d8b4280e5b43bbeeed8c4ddf67ad1dd08fbc70a5 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Mon, 7 Oct 2024 16:37:37 +0200 Subject: don't convert hashset to table and some cleanup for module builders --- xmake/rules/c++/modules/modules_support/builder.lua | 13 +++++-------- xmake/rules/c++/modules/modules_support/clang/builder.lua | 2 +- xmake/rules/c++/modules/modules_support/msvc/builder.lua | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support/builder.lua') diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua index 9133bad60..7e51ad6f8 100644 --- a/xmake/rules/c++/modules/modules_support/builder.lua +++ b/xmake/rules/c++/modules/modules_support/builder.lua @@ -465,21 +465,18 @@ end function is_dependencies_changed(target, module) local cachekey = target:name() .. module.name - local requires + local requires = hashset.new() for required, _ in table.orderpairs(module.requires) do - requires = requires or hashset.new() requires:insert(required) end local oldrequires = compiler_support.memcache():get2(cachekey, "oldrequires") - local changed = false - if oldrequires and requires then - oldrequires = hashset.from(oldrequires) - if oldrequires:size() ~= requires:size() then + if oldrequires then + if oldrequires ~= requires:size() then requires_changed = true else - for required in requires:keys() do + for _, required in requires:keys() do if not oldrequires:has(required) then requires_changed = true break @@ -488,5 +485,5 @@ function is_dependencies_changed(target, module) end end - return requires:to_array(), changed + return requires, changed end diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua index 2ad97a943..ad30aa158 100644 --- a/xmake/rules/c++/modules/modules_support/clang/builder.lua +++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua @@ -126,7 +126,7 @@ function _get_requiresflags(target, module, opt) local requiresflags = compiler_support.memcache():get2(cachekey, "requiresflags") if not requiresflags or requires_changed then requiresflags = {} - for required, _ in table.orderpairs(module.requires) do + for required, _ in requires:orderkeys() do local dep_module = get_from_target_mapper(target, required) assert(dep_module, "module dependency %s required for %s not found", required, name) diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua index de4f97bd4..bb7090cb4 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua @@ -173,9 +173,8 @@ function _get_requiresflags(target, module, opt) local requiresflags = compiler_support.memcache():get2(cachekey, "requiresflags") if not requiresflags or requires_changed then local deps_flags = {} - for required, _ in table.orderpairs(module.requires) do + for required, _ in requires:orderkeys() do local dep_module = get_from_target_mapper(target, required) - assert(dep_module, "module dependency %s required for %s not found <%s>", required, name, target:name()) local mapflag -- cgit v1.3.1 From 665fafc8ae0f3fdd6c2205b2fd0b90a9627409b6 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 8 Oct 2024 11:27:31 +0800 Subject: Update builder.lua --- xmake/rules/c++/modules/modules_support/builder.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support/builder.lua') diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua index 7e51ad6f8..60e1112d8 100644 --- a/xmake/rules/c++/modules/modules_support/builder.lua +++ b/xmake/rules/c++/modules/modules_support/builder.lua @@ -464,19 +464,14 @@ end -- check if dependencies changed function is_dependencies_changed(target, module) local cachekey = target:name() .. module.name - - local requires = hashset.new() - for required, _ in table.orderpairs(module.requires) do - requires:insert(required) - end - + local requires = hashset.from(table.keys(module.requires or {})) local oldrequires = compiler_support.memcache():get2(cachekey, "oldrequires") local changed = false if oldrequires then - if oldrequires ~= requires:size() then + if oldrequires ~= requires then requires_changed = true else - for _, required in requires:keys() do + for required in requires:items() do if not oldrequires:has(required) then requires_changed = true break @@ -484,6 +479,5 @@ function is_dependencies_changed(target, module) end end end - return requires, changed end -- cgit v1.3.1