summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/gcc/has_flags.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-22 23:17:06 +0800
committerruki <[email protected]>2020-06-22 13:42:41 +0800
commitce6d63d5a4ea3df28fc21db6b4501d4b65480584 (patch)
treefd1ab981ab8c102c173a4679fcbac218f6c79311 /xmake/modules/detect/tools/gcc/has_flags.lua
parent4e18de04e01386bf7304bbf9d08ec826a1fa6285 (diff)
fix mingw/gcc envs
Diffstat (limited to 'xmake/modules/detect/tools/gcc/has_flags.lua')
-rw-r--r--xmake/modules/detect/tools/gcc/has_flags.lua12
1 files changed, 5 insertions, 7 deletions
diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua
index 28b4cd254..04956998b 100644
--- a/xmake/modules/detect/tools/gcc/has_flags.lua
+++ b/xmake/modules/detect/tools/gcc/has_flags.lua
@@ -37,11 +37,9 @@ function _islinker(flags, opt)
end
-- try running
-function _try_running(...)
-
- local argv = {...}
+function _try_running(program, argv, opt)
local errors = nil
- return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors
+ return try { function () os.runv(program, argv, opt); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors
end
-- attempt to check it from the argument list
@@ -67,7 +65,7 @@ function _check_from_arglist(flags, opt, islinker)
-- get argument list
allflags = {}
- local arglist = os.iorunv(opt.program, {"--help"})
+ local arglist = os.iorunv(opt.program, {"--help"}, {envs = opt.envs})
if arglist then
for arg in arglist:gmatch("%s+(%-[%-%a%d]+)%s+") do
allflags[arg] = true
@@ -98,12 +96,12 @@ function _check_try_running(flags, opt, islinker)
-- check flags for linker
if islinker then
- return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile))
+ return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile), opt)
end
-- check flags for compiler
-- @note we cannot use os.nuldev() as the output file, maybe run failed for some flags, e.g. --coverage
- return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile))
+ return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile), opt)
end
-- has_flags(flags)?