diff options
| author | ruki <[email protected]> | 2023-04-04 23:26:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-04-04 23:26:27 +0800 |
| commit | 0118c90a5cdab98f61e700f4d06006d8f3861892 (patch) | |
| tree | da7192d98210101376c3f507fa0d03c2efd5133f /xmake/modules/private/check/checkers/api/api_checker.lua | |
| parent | f95a9574c033c90a914cc98e1a21a094694c2648 (diff) | |
improve to check flags
Diffstat (limited to 'xmake/modules/private/check/checkers/api/api_checker.lua')
| -rw-r--r-- | xmake/modules/private/check/checkers/api/api_checker.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/xmake/modules/private/check/checkers/api/api_checker.lua b/xmake/modules/private/check/checkers/api/api_checker.lua index 10b63d19c..caa82a1df 100644 --- a/xmake/modules/private/check/checkers/api/api_checker.lua +++ b/xmake/modules/private/check/checkers/api/api_checker.lua @@ -138,6 +138,39 @@ function _check_target(target, apiname, valueset, level, opt) end end +-- check flag +-- @see https://github.com/xmake-io/xmake/issues/3594 +function check_flag(target, toolinst, flagkind, flag) + local extraconf = target:extraconf(flagkind) + + -- does this flag belong to this tool? + -- @see https://github.com/xmake-io/xmake/issues/3022 + -- + -- e.g. + -- for all: add_cxxflags("-g") + -- only for clang: add_cxxflags("clang::-stdlib=libc++") + -- only for clang and multiple flags: add_cxxflags("-stdlib=libc++", "-DFOO", {tools = "clang"}) + -- + local for_this_tool = true + local flagconf = extraconf and extraconf[flag] + if type(flag) == "string" and flag:find("::", 1, true) then + for_this_tool = false + local splitinfo = flag:split("::", {plain = true}) + local toolname = splitinfo[1] + if toolname == toolinst:name() then + flag = splitinfo[2] + for_this_tool = true + end + elseif flagconf and flagconf.tools then + for_this_tool = table.contains(table.wrap(flagconf.tools), toolinst:name()) + end + if for_this_tool then + return toolinst:has_flags(flag) + else + return true + end +end + -- check api configuration in targets function check_targets(apiname, opt) opt = opt or {} |
