diff options
| author | ruki <[email protected]> | 2025-01-25 00:00:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-25 00:00:55 +0800 |
| commit | 7f01ecf6da7e040d4b0e27efaa035a8f27533e5e (patch) | |
| tree | 8e4dc0f9aa67562012ac427b3dcd64c81b3cf77f | |
| parent | 493ece8e6cc9373187692109d3a9ffb0b7a9e866 (diff) | |
add toolchain dirs
| -rw-r--r-- | tests/apis/custom_toolchain/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 12 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/tool/toolchain.lua | 3 | ||||
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 9 |
4 files changed, 24 insertions, 2 deletions
diff --git a/tests/apis/custom_toolchain/xmake.lua b/tests/apis/custom_toolchain/xmake.lua index e67603129..03d2b5344 100644 --- a/tests/apis/custom_toolchain/xmake.lua +++ b/tests/apis/custom_toolchain/xmake.lua @@ -1,7 +1,7 @@ add_rules("mode.debug", "mode.release") -includes("xmake/toolchains/my-c6000") add_moduledirs("xmake/modules") +add_toolchaindirs("xmake/toolchains") set_toolchains("my-c6000") diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 20b0a171b..7b42d47ea 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -202,6 +202,17 @@ function project._api_add_platformdirs(interp, ...) end end +-- add toolchain directories +function project._api_add_toolchaindirs(interp, ...) + local scriptdir = project.interpreter():scriptdir() + for _, dir in ipairs({...}) do + if not path.is_absolute(dir) then + dir = path.absolute(dir, scriptdir) + end + toolchain.add_directories(dir) + end +end + -- load the project file function project._load(force, disable_filter) @@ -658,6 +669,7 @@ function project.apis() , {"add_moduledirs", project._api_add_moduledirs } , {"add_plugindirs", project._api_add_plugindirs } , {"add_platformdirs", project._api_add_platformdirs } + , {"add_toolchaindirs", project._api_add_toolchaindirs } } } end diff --git a/xmake/core/sandbox/modules/import/core/tool/toolchain.lua b/xmake/core/sandbox/modules/import/core/tool/toolchain.lua index 46bd9fb1d..48867300e 100644 --- a/xmake/core/sandbox/modules/import/core/tool/toolchain.lua +++ b/xmake/core/sandbox/modules/import/core/tool/toolchain.lua @@ -28,7 +28,8 @@ local project = require("project/project") local raise = require("sandbox/modules/raise") -- inherit some builtin interfaces -sandbox_core_tool_toolchain.apis = toolchain.apis +sandbox_core_tool_toolchain.apis = toolchain.apis +sandbox_core_tool_toolchain.directories = toolchain.directories -- get all toolchains list function sandbox_core_tool_toolchain.list() diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index a19413d34..1085df198 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -640,6 +640,15 @@ function toolchain.directories() return dirs end +-- add toolchain directories +function toolchain.add_directories(...) + local dirs = toolchain.directories() + for _, dir in ipairs({...}) do + table.insert(dirs, 1, dir) + end + toolchain._DIRS = table.unique(dirs) +end + -- load toolchain function toolchain.load(name, opt) |
