summaryrefslogtreecommitdiff
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
parent6b35c254f0f918c05989b7e62cfd8bca87cc97b5 (diff)
improve addon and comment
-rw-r--r--xmake/core/package/addon.lua11
-rw-r--r--xmake/core/project/rule.lua7
-rw-r--r--xmake/core/tool/toolchain.lua7
3 files changed, 14 insertions, 11 deletions
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua
index 1f116bcd4..586a3ea15 100644
--- a/xmake/core/package/addon.lua
+++ b/xmake/core/package/addon.lua
@@ -166,11 +166,14 @@ function addon._check_conflicts(dirname, addoninfo)
end
end
- -- the global modules can also conflict with the builtin ones
+ -- the global modules can also conflict with the builtin and the user modules
for _, name in ipairs(addoninfo.globalmodules or {}) do
- local modulefile = path.join(os.programdir(), "modules", (name:gsub("%.", "/")) .. ".lua")
- if os.isfile(modulefile) then
- return string.format("global module(%s) conflicts, it has been provided by xmake!\nplease rename it in the addon manifest.", name)
+ local modulepath = (name:gsub("%.", "/")) .. ".lua"
+ for _, moduledir in ipairs({os.programdir(), global.directory()}) do
+ if os.isfile(path.join(moduledir, "modules", modulepath)) then
+ return string.format("global module(%s) conflicts, it has been provided by %s!\nplease rename it in the addon manifest.",
+ name, moduledir == os.programdir() and "xmake" or path.join(moduledir, "modules"))
+ end
end
end
end
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
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index 76438abfa..6f55a898d 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -672,12 +672,11 @@ end
--
function toolchain.parsename(name)
- -- the toolchain of an addon? e.g. set_toolchains("@addon.esp32.xtensa"), set_toolchains("@self.xtensa")
+ -- the toolchain of an addon?
+ -- e.g. set_toolchains("@addon/esp32/xtensa"), set_toolchains("@addon/esp32/clang@llvm"), set_toolchains("@self/xtensa")
--
-- @note we need to parse it first, because `@` is also used for the toolchain packages, e.g. "@zig"
--
- -- e.g. set_toolchains("@addon/esp32/xtensa"), set_toolchains("@addon/esp32/clang@llvm"), set_toolchains("@self/xtensa")
- --
-- @note we only strip the `@addon/<addon>/` prefix here, the rest is parsed as usual,
-- so the addon toolchains can also be bound to packages, e.g. "@addon/esp32/clang@llvm"
--
@@ -777,8 +776,6 @@ function toolchain.directories()
return dirs
end
-
-
-- add toolchain directories
function toolchain.add_directories(...)
local dirs = toolchain.directories()