diff options
| author | ruki <[email protected]> | 2026-07-19 23:12:24 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-19 23:12:24 +0800 |
| commit | c5874deb17f61381d14a6e148488d61c63c8f78f (patch) | |
| tree | 1e0d0db4906b060d5376153c1416347344ec52e3 /xmake/toolchains/emcc/xmake.lua | |
| parent | 64439096a06b65556fff59f3b0b4e6a439b44129 (diff) | |
| parent | 5895b1d179e31a9d41a145159399a7f5cfd5b7bb (diff) | |
refactor emcc detection to support both .exe and .bat on windows
Diffstat (limited to 'xmake/toolchains/emcc/xmake.lua')
| -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) - |
