diff options
| author | ruki <[email protected]> | 2026-03-26 00:47:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-26 00:47:44 +0800 |
| commit | f623b0100b7270dcd4b923c929e8cb4629677b7b (patch) | |
| tree | c895eb95558ea0e6de4bd25847ada1c66ab5d935 | |
| parent | a10901bfee2284dacd60c0edc0fb4213011865eb (diff) | |
improve clang-cl has_flags
| -rw-r--r-- | xmake/modules/core/tools/clang_cl/has_flags.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/clang_cl/has_flags.lua b/xmake/modules/core/tools/clang_cl/has_flags.lua index 2f92a8a37..2a670a5ee 100644 --- a/xmake/modules/core/tools/clang_cl/has_flags.lua +++ b/xmake/modules/core/tools/clang_cl/has_flags.lua @@ -21,6 +21,46 @@ -- imports import("core.cache.detectcache") import("core.language.language") +import("core.base.hashset") + +-- 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", "-EHa", "-EHs", + "-W0", "-W1", "-W2", "-W3", "-W4", "-Wall", "-WX", + "-Z7", "-Zi", "-ZI", + "-c", "-nologo", "-FS", "-FC", "-Gm-", + "-GR", "-GR-", "-GS", "-GS-", + "-Gy", "-Gy-", "-GL", + "-Gd", "-Gr", "-Gz", "-Gv", + "-TC", "-TP", + "-utf-8", "-bigobj", "-MP", + "-showIncludes" + }) + _g.known_flags = known_flags + end + if known_flags:has(flag) then + return true + end + -- check flags with known prefixes that always accept values (all versions) + if flag:startswith("-D") or + flag:startswith("-U") or + flag:startswith("-I") or + flag:startswith("-Fo") or + flag:startswith("-Fe") or + flag:startswith("-Fd") or + flag:startswith("-FI") or + flag:startswith("-wd") or + flag:startswith("-we") or + flag:startswith("-wo") then + return true + end +end -- attempt to check it from the argument list function _check_from_arglist(flags, opt) @@ -89,6 +129,12 @@ end -- function main(flags, opt) + -- attempt to check it from known flags + opt = opt or {} + if _check_from_knownargs(flags, opt) then + return true + end + -- attempt to check it from the argument list if _check_from_arglist(flags, opt) then return true |
