diff options
| author | iFarbod <[email protected]> | 2026-07-19 17:27:17 +0330 |
|---|---|---|
| committer | iFarbod <[email protected]> | 2026-07-19 17:27:17 +0330 |
| commit | 5895b1d179e31a9d41a145159399a7f5cfd5b7bb (patch) | |
| tree | 7afaee55ac8f3a6b2b5c70e1b00198f401a36f57 /xmake/toolchains | |
| parent | 0cb38ea4d9823ee49d15debb7a94a2fc9e72d3cc (diff) | |
refactor emcc detection to support both .exe and .bat on windows
Fixes #7658
Diffstat (limited to 'xmake/toolchains')
| -rw-r--r-- | xmake/toolchains/emcc/xmake.lua | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/xmake/toolchains/emcc/xmake.lua b/xmake/toolchains/emcc/xmake.lua index 3d64019e6..8313cd226 100644 --- a/xmake/toolchains/emcc/xmake.lua +++ b/xmake/toolchains/emcc/xmake.lua @@ -25,14 +25,25 @@ toolchain("emcc") set_kind("standalone") - local suffix = is_host("windows") and ".bat" or "" - set_toolset("cc", "emcc" .. suffix) - set_toolset("cxx", "emcc" .. suffix, "em++" .. suffix) - set_toolset("ld", "em++" .. suffix, "emcc" .. suffix) - set_toolset("sh", "em++" .. suffix, "emcc" .. suffix) - set_toolset("ar", "emar" .. suffix) - set_toolset("as", "emcc" .. suffix) - set_toolset("ranlib", "emranlib" .. suffix) + local function toolnames(...) + local result = {} + for _, basename in ipairs({...}) do + if is_host("windows") then + table.insert(result, basename .. ".exe") + table.insert(result, basename .. ".bat") + else + table.insert(result, basename) + end + end + return table.unpack(result) + end + set_toolset("cc", toolnames("emcc")) + set_toolset("cxx", toolnames("emcc", "em++")) + set_toolset("ld", toolnames("em++", "emcc")) + set_toolset("sh", toolnames("em++", "emcc")) + set_toolset("ar", toolnames("emar")) + set_toolset("as", toolnames("emcc")) + set_toolset("ranlib", toolnames("emranlib")) on_check(function (toolchain) import("lib.detect.find_tool") @@ -82,4 +93,3 @@ toolchain("emcc") end end end) - |
