From dd46b5b5089cfa1edda87347628c5e40e34b0efb Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 18 Sep 2025 23:25:45 +0800 Subject: improve cl has_flags --- xmake/modules/core/tools/cl/has_flags.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xmake/modules/core/tools/cl/has_flags.lua b/xmake/modules/core/tools/cl/has_flags.lua index 487338a0b..fe0429cda 100644 --- a/xmake/modules/core/tools/cl/has_flags.lua +++ b/xmake/modules/core/tools/cl/has_flags.lua @@ -25,6 +25,14 @@ import("core.cache.global_detectcache") -- attempt to check it from known flags function _check_from_knownargs(flags, opt) local flag = flags[1]:gsub("/", "-") + local known_flags = _g.known_flags + if known_flags == nil then + known_flags = hashset.from({"-Ox", "-O1", "-O2", "-Od", "-MT", "-MD", "-MTd", "-MDd", "-EHsc"}) + _g.known_flags = known_flags + end + if known_flags:has(flag) then + return true + end if flag:startswith("-D") or flag:startswith("-U") or flag:startswith("-I") then @@ -105,10 +113,10 @@ function main(flags, opt) -- attempt to check it from the argument list opt = opt or {} if not opt.tryrun then - if _check_from_arglist(flags, opt) then + if _check_from_knownargs(flags, opt) then return true end - if _check_from_knownargs(flags, opt) then + if _check_from_arglist(flags, opt) then return true end end -- cgit v1.3.1