summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-05-11 18:21:35 +0200
committerArthur LAURENT <[email protected]>2025-05-11 18:21:35 +0200
commit774eca8ceedfd8cbc5901a7f10d01d21773f3b83 (patch)
treeba6b3d01a48a82d2a8fa2336ae4a54fe7da6167a
parent22fcfc64078f4ad04a9ecf5af30adaf7dae199e5 (diff)
(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