summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-15 16:29:16 +0800
committerruki <[email protected]>2026-08-15 16:29:16 +0800
commit67ffcd8a481a5c6c51da8044bfe1ebed980b1e56 (patch)
tree28054248eb7e151102330994b45ce1087ee8905d
parent62bae6f061c8577aae7dff8c1f6c47a5e705f3bb (diff)
fix some bugs
-rw-r--r--xmake/actions/addon/main.lua4
-rw-r--r--xmake/core/package/addon.lua48
-rw-r--r--xmake/core/project/addons.lua3
-rw-r--r--xmake/core/project/project.lua5
-rw-r--r--xmake/core/sandbox/modules/import/core/package/addon.lua1
-rw-r--r--xmake/core/tool/toolchain.lua38
6 files changed, 26 insertions, 73 deletions
diff --git a/xmake/actions/addon/main.lua b/xmake/actions/addon/main.lua
index c2ecdb892..bf6f27f5d 100644
--- a/xmake/actions/addon/main.lua
+++ b/xmake/actions/addon/main.lua
@@ -240,10 +240,6 @@ function _search()
end
-- collect the installed addons from the addons registry
---
--- we always rescan the install directory here to repair the registry,
--- e.g. the user may remove some addon directories manually
---
function _collect_installed_addons()
local entries = {}
for name, addoninfo in table.orderpairs(addon.addons()) do
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua
index 43cb81edf..15786c62f 100644
--- a/xmake/core/package/addon.lua
+++ b/xmake/core/package/addon.lua
@@ -770,53 +770,5 @@ function addon.reload()
addon._GLOBALMODULES = nil
end
--- rescan the install directory and rebuild the registry
---
--- it's only used to repair the registry file, e.g. the user removed some addon directories manually
---
-function addon.rescan()
- local oldregistry = addon._registry()
- local registry = {}
- for _, versiondir in ipairs(os.dirs(path.join(addon.installdir(), "*", "*"))) do
- local payloads = addon.payloads_of(versiondir)
- if #payloads > 0 then
- local dirname = path.filename(path.directory(versiondir))
- local version = path.filename(versiondir)
- local oldentry = oldregistry[dirname]
- local oldaddoninfo = oldentry and oldentry.versions and oldentry.versions[version]
- local description, deps
- if oldaddoninfo then
- -- we need to keep them, we cannot get them from the installed payloads
- description = oldaddoninfo.description
- deps = oldaddoninfo.deps
- end
- -- but the packages also install their own manifest, we can reuse it
- local name
- local manifestfile = path.join(versiondir, "manifest.txt")
- if os.isfile(manifestfile) then
- local manifest = io.load(manifestfile)
- if manifest then
- name = manifest.name ~= dirname and manifest.name or nil
- description = manifest.description or description
- end
- end
- local entry = registry[dirname]
- if entry == nil then
- entry = {versions = {}}
- registry[dirname] = entry
- end
- entry.versions[version] = {version = version, name = name or (oldaddoninfo and oldaddoninfo.name),
- description = description, deps = deps, payloads = payloads,
- plugins = addon._plugins_of(versiondir), templates = addon._templates_of(versiondir)}
- -- we keep the active version if it's still installed, otherwise we use the last one
- if entry.active == nil or (oldentry and oldentry.active == version) then
- entry.active = version
- end
- end
- end
- addon._save(registry)
- return addon.addons()
-end
-
-- return module
return addon
diff --git a/xmake/core/project/addons.lua b/xmake/core/project/addons.lua
index 3b105840e..169b7d033 100644
--- a/xmake/core/project/addons.lua
+++ b/xmake/core/project/addons.lua
@@ -35,8 +35,7 @@ local addon = require("package/addon")
-- we load the project, e.g. includes("@addon/esp32-devel/board")
--
-- e.g.
--- add_addons("esp32-devel 1.0.x")
--- add_addons("serial-tools", {optional = true})
+-- add_addons("esp32-devel 1.0.x", "serial-tools")
-- add_repositories("myrepo [email protected]:me/myrepo.git")
--
function addons.filename()
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 3b975cccd..4f82ccd53 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -335,7 +335,10 @@ function project._load(opt)
-- @note we need to check it before the cache, the project file may have been loaded
-- already without them, e.g. by the option menu
--
- if not opt.skip_addons then
+ if opt.skip_addons then
+ -- we do not install them here, but we still need to use the locked versions
+ project._pin_addons()
+ else
local ok, errors = project._install_addons()
if not ok then
return false, errors
diff --git a/xmake/core/sandbox/modules/import/core/package/addon.lua b/xmake/core/sandbox/modules/import/core/package/addon.lua
index 74610c693..9fc7c9f0c 100644
--- a/xmake/core/sandbox/modules/import/core/package/addon.lua
+++ b/xmake/core/sandbox/modules/import/core/package/addon.lua
@@ -39,7 +39,6 @@ sandbox_core_package_addon.addons = addon.addons
sandbox_core_package_addon.versions = addon.versions
sandbox_core_package_addon.pin = addon.pin
sandbox_core_package_addon.addondir = addon.addondir
-sandbox_core_package_addon.rescan = addon.rescan
-- get the manifest of the given addon directory, e.g. <sourcedir>/addon.lua
--
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index 6f55a898d..7b841a018 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -805,19 +805,13 @@ function toolchain.load(name, opt)
configs.plat = opt.plat or config.get("plat") or os.host()
configs.arch = opt.arch or config.get("arch") or os.arch()
- -- get cache
- local cache = toolchain._memcache()
- -- @note we need the addon prefix here, the different addons may provide the same toolchain name
- local cachekey = toolchain._cachekey((parseinfo.addon_prefix or "") .. name, configs)
-
- -- get it directly from cache dirst
- local instance = cache:get(cachekey)
- if instance then
- return instance
- end
-
-- find the toolchain script path
- local scriptpath = nil
+ --
+ -- @note we need to resolve the addon reference before the cache, `@self/` depends on
+ -- the addon which owns the caller script, and the different addons may provide
+ -- the same toolchain name
+ --
+ local scriptpath, addon_prefix
if parseinfo.addon_prefix then
-- e.g. set_toolchains("@addon/esp32/xtensa"), set_toolchains("@self/xtensa")
local referenceinfo, errors = addon.resolve_reference(parseinfo.addon_prefix .. name, "/", "toolchains",
@@ -825,8 +819,21 @@ function toolchain.load(name, opt)
if not referenceinfo then
return nil, errors
end
+ addon_prefix = "@addon/" .. referenceinfo.addon .. "/"
scriptpath = path.join(referenceinfo.dir, referenceinfo.name, "xmake.lua")
- else
+ end
+
+ -- get cache
+ local cache = toolchain._memcache()
+ local cachekey = toolchain._cachekey((addon_prefix or "") .. name, configs)
+
+ -- get it directly from cache dirst
+ local instance = cache:get(cachekey)
+ if instance then
+ return instance
+ end
+
+ if not addon_prefix then
for _, dir in ipairs(toolchain.directories()) do
scriptpath = path.join(dir, name, "xmake.lua")
if os.isfile(scriptpath) then
@@ -835,10 +842,7 @@ function toolchain.load(name, opt)
end
end
if not scriptpath or not os.isfile(scriptpath) then
- if parseinfo.addon_prefix then
- return nil, string.format("the toolchain %s%s not found!", parseinfo.addon_prefix, name)
- end
- return nil, string.format("the toolchain %s not found!", name)
+ return nil, string.format("the toolchain %s%s not found!", addon_prefix or "", name)
end
-- get interpreter