summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-05-12 07:49:22 +0800
committerGitHub <[email protected]>2025-05-12 07:49:22 +0800
commit5a580f088db2e75271f133e68d549102fa334486 (patch)
treef5a4badfd8b223ab8799b26b1408b37833f7d2d5
parent755820aa98c7e57512626f6dc3fd6c0710f44b67 (diff)
parent774eca8ceedfd8cbc5901a7f10d01d21773f3b83 (diff)
Merge pull request #6422 from Arthapz/fix-built-artifacts
(C++ modules support) fix nil built_artifacts error when an error occur during the module sorting
-rw-r--r--xmake/rules/c++/modules/scanner.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/xmake/rules/c++/modules/scanner.lua b/xmake/rules/c++/modules/scanner.lua
index dcb4f22b8..263b5725a 100644
--- a/xmake/rules/c++/modules/scanner.lua
+++ b/xmake/rules/c++/modules/scanner.lua
@@ -637,8 +637,11 @@ end
-- topological sort
function sort_modules_by_dependencies(target, modules)
- local changed = support.memcache():get2(target:fullname(), "modules.changed")
- if changed then
+ local memcache = support.memcache()
+ local localcache = support.localcache()
+ local changed = memcache:get2(target:fullname(), "modules.changed")
+ local built_artifacts = localcache:get2(target:fullname(), "c++.modules.built_artifacts")
+ if changed or not built_artifacts then
local built_modules = {}
local built_headerunits = {}
local objectfiles = {}
@@ -751,11 +754,12 @@ function sort_modules_by_dependencies(target, modules)
table.sort(objectfiles)
built_headerunits = table.unique(built_headerunits)
- support.localcache():set2(target:fullname(), "c++.modules.built_artifacts", {modules = built_modules, headerunits = built_headerunits, objectfiles = objectfiles})
- support.localcache():save()
- support.memcache():set2(target:fullname(), "modules.changed", false)
+ built_artifacts = {modules = built_modules, headerunits = built_headerunits, objectfiles = objectfiles}
+ localcache:set2(target:fullname(), "c++.modules.built_artifacts", built_artifacts)
+ localcache:save()
+ memcache:set2(target:fullname(), "modules.changed", false)
end
- local built_artifacts = support.localcache():get2(target:fullname(), "c++.modules.built_artifacts")
+ assert(built_artifacts, "shouldn't assert here, please open an issue")
return built_artifacts.modules, built_artifacts.headerunits, built_artifacts.objectfiles
end