summaryrefslogtreecommitdiff
path: root/xmake/core/project/project.lua
diff options
context:
space:
mode:
authorbakabaka9405 <[email protected]>2026-05-14 17:35:52 +0800
committerbakabaka9405 <[email protected]>2026-05-14 17:53:22 +0800
commit22ee4e17de8f06f5c8dcd76c80867b1b06b2d201 (patch)
treedf94f6a5dbe4ff39dfff2232392a222758db5e05 /xmake/core/project/project.lua
parent027524d15cb05aad924b6cdc0a35c1d2b54551d8 (diff)
fix: expand builtin variables before calling path.is_absolute in add_moduledirs
Diffstat (limited to 'xmake/core/project/project.lua')
-rw-r--r--xmake/core/project/project.lua33
1 files changed, 13 insertions, 20 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 2ea22e655..ff770ced0 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -168,27 +168,28 @@ function project._api_get_config(interp, name)
return value
end
+-- translate directory path for custom project apis
+function project._translate_directory(interp, dir)
+ dir = interp:filter():handle(dir)
+ if not path.is_absolute(dir) then
+ dir = path.absolute(dir, interp:scriptdir())
+ end
+ return dir
+end
+
-- add module directories
function project._api_add_moduledirs(interp, ...)
- local scriptdir = project.interpreter():scriptdir()
for _, dir in ipairs({...}) do
- local dir = dir
- if not path.is_absolute(dir) then
- dir = path.absolute(dir, scriptdir)
- end
+ local dir = project._translate_directory(interp, dir)
sandbox_module.add_directories(dir)
end
end
-- add plugin directories load all plugins from the given directories
function project._api_add_plugindirs(interp, ...)
- local scriptdir = project.interpreter():scriptdir()
local plugindirs = {}
for _, dir in ipairs({...}) do
- local dir = dir
- if not path.is_absolute(dir) then
- dir = path.absolute(dir, scriptdir)
- end
+ local dir = project._translate_directory(interp, dir)
table.insert(plugindirs, dir .. "/*")
end
interp:api_builtin_includes(plugindirs)
@@ -196,24 +197,16 @@ end
-- add platform directories
function project._api_add_platformdirs(interp, ...)
- local scriptdir = project.interpreter():scriptdir()
for _, dir in ipairs({...}) do
- local dir = dir
- if not path.is_absolute(dir) then
- dir = path.absolute(dir, scriptdir)
- end
+ local dir = project._translate_directory(interp, dir)
platform.add_directories(dir)
end
end
-- add toolchain directories
function project._api_add_toolchaindirs(interp, ...)
- local scriptdir = project.interpreter():scriptdir()
for _, dir in ipairs({...}) do
- local dir = dir
- if not path.is_absolute(dir) then
- dir = path.absolute(dir, scriptdir)
- end
+ local dir = project._translate_directory(interp, dir)
toolchain.add_directories(dir)
-- auto-register modules directories under each toolchain
-- e.g. toolchains/my-c6000/modules/ will be added as module search path