summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-15 19:17:21 +0800
committerruki <[email protected]>2026-08-15 19:19:02 +0800
commit4c7c17c10f8a4270b27d90958544ce2886dc6052 (patch)
treedea5d0bcf229a272289dd94cd47b2b206929f1e3
parent0a32ec18d737259052271fa3be5cfdb50dbd1d15 (diff)
fix addon install
-rw-r--r--xmake/core/package/addon.lua4
-rw-r--r--xmake/core/sandbox/modules/import/core/package/addon.lua1
-rw-r--r--xmake/modules/private/action/require/impl/actions/install.lua7
3 files changed, 10 insertions, 2 deletions
diff --git a/xmake/core/package/addon.lua b/xmake/core/package/addon.lua
index 15786c62f..71af9aceb 100644
--- a/xmake/core/package/addon.lua
+++ b/xmake/core/package/addon.lua
@@ -198,7 +198,7 @@ function addon._parents(name)
end
-- unregister the given addon or only one of its versions
-function addon._unregister(name, version)
+function addon.unregister(name, version)
local dirname = addon.dirname(name)
local registry = addon._registry()
local entry = registry[dirname]
@@ -754,7 +754,7 @@ function addon.remove(name, opt)
if not ok then
return false, errors
end
- addon._unregister(name)
+ addon.unregister(name)
return true
end
diff --git a/xmake/core/sandbox/modules/import/core/package/addon.lua b/xmake/core/sandbox/modules/import/core/package/addon.lua
index 9fc7c9f0c..47d2b7793 100644
--- a/xmake/core/sandbox/modules/import/core/package/addon.lua
+++ b/xmake/core/sandbox/modules/import/core/package/addon.lua
@@ -39,6 +39,7 @@ 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.unregister = addon.unregister
-- get the manifest of the given addon directory, e.g. <sourcedir>/addon.lua
--
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua
index 7ddb66cca..c07add337 100644
--- a/xmake/modules/private/action/require/impl/actions/install.lua
+++ b/xmake/modules/private/action/require/impl/actions/install.lua
@@ -618,6 +618,13 @@ function main(package)
end
os.tryrm(installdir)
+ -- the addon is registered before testing it, its `on_test` needs to use it,
+ -- e.g. xmake create -t esp32.blink, so we need to unregister it again here,
+ -- otherwise it would be seen as installed while its files are gone
+ if package:is_addon() then
+ addon.unregister(package:name(), package:version_str() or "latest")
+ end
+
-- is not last scheme? we can fallback to next scheme and try reinstall it again
local current_scheme = package:current_scheme()
local schemes_orderlist = package:schemes_orderlist()