summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-15 00:30:07 +0800
committerruki <[email protected]>2026-08-15 00:30:07 +0800
commit1e22f6cb910b9359bdf08aa291f7932f30113c56 (patch)
tree8c32f3c1bfc933d9cfd64758754e0be4963f86da
parentea1af59107ffd962ad8e063577e7546908d5a731 (diff)
improve to parse addons
-rw-r--r--xmake/core/project/addons.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/xmake/core/project/addons.lua b/xmake/core/project/addons.lua
index 21fb9fbcf..d2f6eaf1a 100644
--- a/xmake/core/project/addons.lua
+++ b/xmake/core/project/addons.lua
@@ -133,7 +133,7 @@ function addons.load(projectdir)
filepath, requirestr)
end
- local name = requirestr:split("%s")[1]
+ local name = addons.requirename(requirestr)
if name == "addon" or name == "self" then
return nil, string.format("%s: the addon name(%s) is reserved by xmake for the addon references, please rename it!",
filepath, name)
@@ -152,9 +152,14 @@ function addons.load(projectdir)
return addonsinfo
end
--- split the given declaration, e.g. "esp32-devel 1.0.x" -> "esp32-devel", "1.0.x"
+-- split the given declaration into the name and the version
+--
+-- @note the version can be a range with spaces, so everything after the name belongs to it,
+-- e.g. "esp32-devel 1.0.x", "esp32-devel >=1.0 <2.0", "esp32-devel master || >1.4",
+-- @see xmake/modules/private/utils/package.lua
+--
function addons.requirename(requirestr)
- local splitinfo = requirestr:split("%s")
+ local splitinfo = requirestr:split("%s+", {limit = 2})
return splitinfo[1], splitinfo[2]
end