diff options
| author | ruki <[email protected]> | 2023-02-02 22:35:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-02 22:35:45 +0800 |
| commit | 3ccae48c676e8a08e811b421676ba682e32ec8a7 (patch) | |
| tree | 500051a06590e38f7c6fdf8a8091338262c83f88 /xmake/plugins | |
| parent | 1804f783f3b7fa873e9a0f745788cf86518dda26 (diff) | |
improve symbols checker
Diffstat (limited to 'xmake/plugins')
| -rw-r--r-- | xmake/plugins/check/checker.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/check/checkers/api/api_checker.lua | 18 | ||||
| -rw-r--r-- | xmake/plugins/check/checkers/api/target/fpmodels.lua | 26 | ||||
| -rw-r--r-- | xmake/plugins/check/checkers/api/target/strip.lua | 26 | ||||
| -rw-r--r-- | xmake/plugins/check/checkers/api/target/symbols.lua | 33 |
5 files changed, 103 insertions, 3 deletions
diff --git a/xmake/plugins/check/checker.lua b/xmake/plugins/check/checker.lua index b49233328..d15655629 100644 --- a/xmake/plugins/check/checker.lua +++ b/xmake/plugins/check/checker.lua @@ -28,7 +28,10 @@ function checkers() checkers = { -- target api checkers ["api.target.version"] = {description = "Check version configuration in target."}, + ["api.target.strip"] = {description = "Check strip configuration in target."}, ["api.target.optimize"] = {description = "Check optimize configuration in target."}, + ["api.target.symbols"] = {description = "Check symbols configuration in target."}, + ["api.target.fpmodels"] = {description = "Check fpmodels configuration in target."}, ["api.target.warnings"] = {description = "Check warnings configuration in target."}, ["api.target.languages"] = {description = "Check languages configuration in target."}, ["api.target.packages"] = {description = "Check packages configuration in target."}, diff --git a/xmake/plugins/check/checkers/api/api_checker.lua b/xmake/plugins/check/checkers/api/api_checker.lua index 52a494a47..44cecad28 100644 --- a/xmake/plugins/check/checkers/api/api_checker.lua +++ b/xmake/plugins/check/checkers/api/api_checker.lua @@ -93,8 +93,20 @@ end function check_targets(apiname, opt) opt = opt or {} local level = opt.level or "warning" - local valueset = opt.values and hashset.from(opt.values) or hashset.new() + local valueset + if opt.values and type(opt.values) ~= "function" then + valueset = hashset.from(opt.values) + else + valueset = hashset.new() + end for _, target in pairs(project.targets()) do + local target_valueset = valueset + if type(opt.values) == "function" then + local target_values = opt.values(target) + if target_values then + target_valueset = hashset.from(target_values) + end + end local values = target:get(apiname) for _, value in ipairs(values) do if opt.check then @@ -105,8 +117,8 @@ function check_targets(apiname, opt) checker.update_stats(level) end end - elseif not valueset:has(value) then - local reported = _show(apiname, value, target, {valueset = valueset, level = level}) + elseif not target_valueset:has(value) then + local reported = _show(apiname, value, target, {valueset = target_valueset, level = level}) if reported then checker.update_stats(level) end diff --git a/xmake/plugins/check/checkers/api/target/fpmodels.lua b/xmake/plugins/check/checkers/api/target/fpmodels.lua new file mode 100644 index 000000000..25c6c239b --- /dev/null +++ b/xmake/plugins/check/checkers/api/target/fpmodels.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file fpmodels.lua +-- + +-- imports +import(".api_checker") + +function main() + api_checker.check_targets("fpmodels", {values = {"none", "precise", "fast", "strict", "except", "noexcept"}}) +end diff --git a/xmake/plugins/check/checkers/api/target/strip.lua b/xmake/plugins/check/checkers/api/target/strip.lua new file mode 100644 index 000000000..cf14c607b --- /dev/null +++ b/xmake/plugins/check/checkers/api/target/strip.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file strip.lua +-- + +-- imports +import(".api_checker") + +function main() + api_checker.check_targets("strip", {values = {"none", "debug", "all"}}) +end diff --git a/xmake/plugins/check/checkers/api/target/symbols.lua b/xmake/plugins/check/checkers/api/target/symbols.lua new file mode 100644 index 000000000..8f4472a9b --- /dev/null +++ b/xmake/plugins/check/checkers/api/target/symbols.lua @@ -0,0 +1,33 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file symbols.lua +-- + +-- imports +import(".api_checker") + +function main() + api_checker.check_targets("symbols", {values = function (target) + local values = {"none", "debug", "hidden", "hidden_cxx"} + if target:is_plat("windows") and (target:has_tool("cc", "cl") or target:has_tool("cxx", "cl")) then + table.insert(values, "edit") + table.insert(values, "embed") + end + return values + end}) +end |
