summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/find_gzip.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/detect/tools/find_gzip.lua')
-rw-r--r--xmake/modules/detect/tools/find_gzip.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/find_gzip.lua b/xmake/modules/detect/tools/find_gzip.lua
index ea0b97408..a3e456673 100644
--- a/xmake/modules/detect/tools/find_gzip.lua
+++ b/xmake/modules/detect/tools/find_gzip.lua
@@ -40,6 +40,18 @@ function main(opt)
-- init options
opt = opt or {}
+ opt.check = opt.check or function (program)
+ local ok = try { function () os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end }
+ if not ok then
+ -- some gzip do not support `--version`, so we fall back to compressing a temporary file to check it
+ local tmpfile = os.tmpfile()
+ io.writefile(tmpfile, "")
+ os.runv(program, {"-f", tmpfile}, {envs = opt.envs, shell = opt.shell})
+ os.rm(tmpfile .. ".gz")
+ os.rm(tmpfile)
+ end
+ end
+
-- find program
local program = find_program(opt.program or "gzip", opt)