summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-26 00:50:28 +0800
committerruki <[email protected]>2026-03-26 00:50:28 +0800
commitc6a54f8a734efdb7df32251e97bb24e9129a28a9 (patch)
treea50615a4cf2d0ea1e1793ade041682961f175919
parent61c20bbce2d4a50cb21095369246c0d13bd2c2e3 (diff)
improve clang-cl has_flags
-rw-r--r--xmake/modules/core/tools/cl/has_flags.lua6
-rw-r--r--xmake/modules/core/tools/clang_cl/has_flags.lua15
2 files changed, 3 insertions, 18 deletions
diff --git a/xmake/modules/core/tools/cl/has_flags.lua b/xmake/modules/core/tools/cl/has_flags.lua
index 5d24818be..dfef0e1c2 100644
--- a/xmake/modules/core/tools/cl/has_flags.lua
+++ b/xmake/modules/core/tools/cl/has_flags.lua
@@ -39,11 +39,7 @@ function _check_from_arglist(flags, opt)
global_detectcache:set2(key, flagskey, allflags)
global_detectcache:save()
end
- local flag = flags[1]:gsub("/", "-")
- if flag:startswith("-D") or flag:startswith("-I") then
- return true
- end
- return allflags[flag]
+ return allflags[flags[1]:gsub("/", "-")]
end
-- get extension
diff --git a/xmake/modules/core/tools/clang_cl/has_flags.lua b/xmake/modules/core/tools/clang_cl/has_flags.lua
index 7d6e8c742..924fb0f3e 100644
--- a/xmake/modules/core/tools/clang_cl/has_flags.lua
+++ b/xmake/modules/core/tools/clang_cl/has_flags.lua
@@ -25,33 +25,22 @@ import("core.tools.cl.check_knownargs")
-- attempt to check it from the argument list
function _check_from_arglist(flags, opt)
-
- -- only one flag?
if #flags > 1 then
return
end
-
- -- make cache key
local key = "core.tools.clang_cl.has_flags"
-
- -- make allflags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
-
- -- get all allflags from argument list
local allflags = detectcache:get2(key, flagskey)
if not allflags then
-
- -- get argument list
allflags = {}
- local arglist = os.iorunv(opt.program, {"-?"})
+ local arglist = os.iorunv(opt.program, {"-?"}, {envs = opt.envs})
if arglist then
for arg in arglist:gmatch("(/[%-%a%d]+)%s+") do
allflags[arg:gsub("/", "-")] = true
end
end
-
- -- save cache
detectcache:set2(key, flagskey, allflags)
+ detectcache:save()
end
return allflags[flags[1]:gsub("/", "-")]
end