diff options
| author | ruki <[email protected]> | 2021-01-30 09:32:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-01-30 09:32:47 +0800 |
| commit | 7f0bdcf280e617307a9b5895d3a4953c884e88a3 (patch) | |
| tree | 1302550608b72ae1b7ddd274f0a6d66b00396e99 /xmake/toolchains/zig/xmake.lua | |
| parent | fde1f6f6594af9f5c1855921f0cd2a46628a1c8c (diff) | |
modify test
Diffstat (limited to 'xmake/toolchains/zig/xmake.lua')
| -rw-r--r-- | xmake/toolchains/zig/xmake.lua | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/xmake/toolchains/zig/xmake.lua b/xmake/toolchains/zig/xmake.lua index d2aee0880..a1cd26efe 100644 --- a/xmake/toolchains/zig/xmake.lua +++ b/xmake/toolchains/zig/xmake.lua @@ -30,8 +30,20 @@ toolchain("zig") -- on check on_check(function (toolchain) - -- only for overriding cross.on_check, because we will use `-p cross --cross=xxx` - return true + import("lib.detect.find_tool") + local paths = {} + for _, package in ipairs(toolchain:packages()) do + local envs = package:get("envs") + if envs then + table.join2(paths, envs.PATH) + end + end + local zig = find_tool("zig", {program = get_config("zc"), paths = paths}) + if zig and zig.program then + toolchain:config_set("zig", zig.program) + toolchain:configs_save() + return true + end end) -- on load @@ -39,7 +51,7 @@ toolchain("zig") -- set toolset -- we patch target to `zig cc` to fix has_flags. see https://github.com/xmake-io/xmake/issues/955#issuecomment-766929692 - local zig = get_config("zc") or "zig" + local zig = toolchain:config("zig") toolchain:set("toolset", "cc", zig .. " cc") toolchain:set("toolset", "cxx", zig .. " c++") toolchain:set("toolset", "ld", zig .. " c++") |
