summaryrefslogtreecommitdiff
path: root/xmake/core/project/rule.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-12 00:35:48 +0800
committerruki <[email protected]>2026-08-12 00:35:48 +0800
commit56a581b37b3c4e7d8b96415a03f850db827956ab (patch)
treedf58b1231679ed59d9266ae792b21fe7f5b7c3de /xmake/core/project/rule.lua
parent6b35c254f0f918c05989b7e62cfd8bca87cc97b5 (diff)
improve addon and comment
Diffstat (limited to 'xmake/core/project/rule.lua')
-rw-r--r--xmake/core/project/rule.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua
index b8cb72ed4..66c0719a6 100644
--- a/xmake/core/project/rule.lua
+++ b/xmake/core/project/rule.lua
@@ -674,10 +674,13 @@ function rule.rules()
end
-- make rule instances
+ --
+ -- @note we reuse the rules which have been loaded on demand,
+ -- otherwise we would have two instances of the same rule
+ local loaded = rule._LOADED or {}
rules = {}
for rulename, ruleinfo in pairs(ruleinfos) do
- local instance = rule.new(rulename, ruleinfo)
- rules[rulename] = instance
+ rules[rulename] = loaded[rulename] or rule.new(rulename, ruleinfo)
end
rule._RULES = rules
end