From 8d8601bb1655094e1c711f8a48150453f076b5d1 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 11 Apr 2026 20:15:02 +0800 Subject: improve custom toolchain --- xmake/core/project/project.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'xmake/core/project/project.lua') diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index beab21a22..5376f406d 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -215,6 +215,18 @@ function project._api_add_toolchaindirs(interp, ...) dir = path.absolute(dir, scriptdir) end toolchain.add_directories(dir) + -- auto-register modules directories under each toolchain + -- e.g. toolchains/my-c6000/modules/ will be added as module search path + -- so that custom toolchain can bundle its tool modules together + local toolchain_subdirs = os.dirs(path.join(dir, "*")) + if toolchain_subdirs then + for _, toolchain_subdir in ipairs(toolchain_subdirs) do + local modulesdir = path.join(toolchain_subdir, "modules") + if os.isdir(modulesdir) then + sandbox_module.add_directories(modulesdir) + end + end + end end end -- cgit v1.3.1 From 5522c0c028562b4ede39bd5dbc5ee0aba91b4049 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 11 Apr 2026 21:37:20 +0800 Subject: improve moduledirs --- xmake/core/project/project.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'xmake/core/project/project.lua') diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 5376f406d..2ea22e655 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -220,12 +220,16 @@ function project._api_add_toolchaindirs(interp, ...) -- so that custom toolchain can bundle its tool modules together local toolchain_subdirs = os.dirs(path.join(dir, "*")) if toolchain_subdirs then + local modulesdirs = {} for _, toolchain_subdir in ipairs(toolchain_subdirs) do local modulesdir = path.join(toolchain_subdir, "modules") if os.isdir(modulesdir) then - sandbox_module.add_directories(modulesdir) + table.insert(modulesdirs, modulesdir) end end + if #modulesdirs > 0 then + sandbox_module.add_directories(table.unpack(modulesdirs)) + end end end end -- cgit v1.3.1