Skip to content

Commit

Permalink
zig cc: fix wrapper in Git Bash
Browse files Browse the repository at this point in the history
  • Loading branch information
Doekin committed Dec 28, 2024
1 parent 4f408eb commit dbee063
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function sandbox_lib_detect_find_program._check(program, opt)
if not opt.shell and not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then
findname = program .. ".exe"
end
elseif os.subhost() == "msys" and os.isfile(program) and os.filesize(program) < 256 then
elseif os.subhost() == "msys" and os.isfile(program) and os.filesize(program) < 256 and not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then
-- only a sh script on msys2? e.g. c:/msys64/usr/bin/7z
-- we need to use sh to wrap it, otherwise os.exec cannot run it
program = "sh " .. program
Expand Down
5 changes: 4 additions & 1 deletion xmake/modules/package/tools/autoconf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ end
function _translate_windows_bin_path(bin_path)
if bin_path then
local argv = os.argv(bin_path)
argv[1] = path.unix(argv[1]) .. ".exe"
argv[1] = path.unix(argv[1])
if not argv[1]:endswith(".exe") and not argv[1]:endswith(".cmd") and not argv[1]:endswith(".bat") then
argv[1] = argv[1] .. ".exe"
end
return os.args(argv)
end
end
Expand Down
2 changes: 1 addition & 1 deletion xmake/toolchains/zig/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ toolchain("zig")
local wrapper_path = path.join(os.tmpdir(), "zigcc", tool) .. script_suffix
if not os.isfile(wrapper_path) then
if is_host("windows") then
io.writefile(wrapper_path, ("@echo off\n\"%s\" %s %%*"):format(zig, tool))
io.writefile(wrapper_path, ("@echo off || true\n" .. [["%s" %s %%* || exec "zig" c++ "$@"]]):format(zig, tool))
else
io.writefile(wrapper_path, ("#!/bin/bash\nexec \"%s\" %s \"$@\""):format(zig, tool))
os.runv("chmod", {"+x", wrapper_path})
Expand Down

0 comments on commit dbee063

Please sign in to comment.