Skip to content

Commit b1fa41d

Browse files
authored
Merge pull request #7478 from xmake-io/toolchain
Improve custom toolchain
2 parents 151d094 + 5522c0c commit b1fa41d

File tree

8 files changed

+16
-1
lines changed

8 files changed

+16
-1
lines changed

tests/apis/custom_toolchain/xmake.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_rules("mode.debug", "mode.release")
22

3-
add_moduledirs("xmake/modules")
43
add_toolchaindirs("xmake/toolchains")
54

65
set_toolchains("my-c6000")

tests/apis/custom_toolchain/xmake/modules/core/tools/ar6x.lua renamed to tests/apis/custom_toolchain/xmake/toolchains/my-c6000/modules/core/tools/ar6x.lua

File renamed without changes.

tests/apis/custom_toolchain/xmake/modules/core/tools/cl6x.lua renamed to tests/apis/custom_toolchain/xmake/toolchains/my-c6000/modules/core/tools/cl6x.lua

File renamed without changes.

tests/apis/custom_toolchain/xmake/modules/core/tools/cl6x/has_flags.lua renamed to tests/apis/custom_toolchain/xmake/toolchains/my-c6000/modules/core/tools/cl6x/has_flags.lua

File renamed without changes.

tests/apis/custom_toolchain/xmake/modules/core/tools/cl6x/parse_deps.lua renamed to tests/apis/custom_toolchain/xmake/toolchains/my-c6000/modules/core/tools/cl6x/parse_deps.lua

File renamed without changes.

tests/apis/custom_toolchain/xmake/modules/detect/tools/find_ar6x.lua renamed to tests/apis/custom_toolchain/xmake/toolchains/my-c6000/modules/detect/tools/find_ar6x.lua

File renamed without changes.

tests/apis/custom_toolchain/xmake/modules/detect/tools/find_cl6x.lua renamed to tests/apis/custom_toolchain/xmake/toolchains/my-c6000/modules/detect/tools/find_cl6x.lua

File renamed without changes.

xmake/core/project/project.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,22 @@ function project._api_add_toolchaindirs(interp, ...)
215215
dir = path.absolute(dir, scriptdir)
216216
end
217217
toolchain.add_directories(dir)
218+
-- auto-register modules directories under each toolchain
219+
-- e.g. toolchains/my-c6000/modules/ will be added as module search path
220+
-- so that custom toolchain can bundle its tool modules together
221+
local toolchain_subdirs = os.dirs(path.join(dir, "*"))
222+
if toolchain_subdirs then
223+
local modulesdirs = {}
224+
for _, toolchain_subdir in ipairs(toolchain_subdirs) do
225+
local modulesdir = path.join(toolchain_subdir, "modules")
226+
if os.isdir(modulesdir) then
227+
table.insert(modulesdirs, modulesdir)
228+
end
229+
end
230+
if #modulesdirs > 0 then
231+
sandbox_module.add_directories(table.unpack(modulesdirs))
232+
end
233+
end
218234
end
219235
end
220236

0 commit comments

Comments
 (0)