summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-02 22:48:12 +0800
committerruki <[email protected]>2023-02-02 22:48:12 +0800
commit1e6070141e6fd21d7dc4cf3e7c70755efd6f0171 (patch)
tree0017b47042f98a2efa42605275d26d113651a241
parent18737c1434786ebf43d37191c52ddb24847bae6d (diff)
check flags
-rw-r--r--xmake/plugins/check/checker.lua5
-rw-r--r--xmake/plugins/check/checkers/api/target/cflags.lua33
-rw-r--r--xmake/plugins/check/checkers/api/target/cxflags.lua33
-rw-r--r--xmake/plugins/check/checkers/api/target/cxxflags.lua33
-rw-r--r--xmake/plugins/check/checkers/api/target/ldflags.lua35
-rw-r--r--xmake/plugins/check/checkers/api/target/shflags.lua35
6 files changed, 174 insertions, 0 deletions
diff --git a/xmake/plugins/check/checker.lua b/xmake/plugins/check/checker.lua
index cbde9c236..bf7b87397 100644
--- a/xmake/plugins/check/checker.lua
+++ b/xmake/plugins/check/checker.lua
@@ -40,6 +40,11 @@ function checkers()
["api.target.linkdirs"] = {description = "Check linkdirs configuration in target."},
["api.target.includedirs"] = {description = "Check includedirs configuration in target."},
["api.target.frameworkdirs"] = {description = "Check frameworkdirs configuration in target."},
+ ["api.target.cflags"] = {description = "Check c compiler flags configuration in target."},
+ ["api.target.cxflags"] = {description = "Check c/c++ compiler flags configuration in target."},
+ ["api.target.cxxflags"] = {description = "Check c++ compiler flags configuration in target."},
+ ["api.target.ldflags"] = {description = "Check binary linker flags configuration in target."},
+ ["api.target.shflags"] = {description = "Check shared library linker flags configuration in target."},
-- clang tidy checker
["clang.tidy"] = {description = "Check project code using clang-tidy.", showstats = false}
}
diff --git a/xmake/plugins/check/checkers/api/target/cflags.lua b/xmake/plugins/check/checkers/api/target/cflags.lua
new file mode 100644
index 000000000..df9a34830
--- /dev/null
+++ b/xmake/plugins/check/checkers/api/target/cflags.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 cflags.lua
+--
+
+-- imports
+import("core.tool.compiler")
+import(".api_checker")
+
+function main()
+ api_checker.check_targets("cflags", {check = function(target, value)
+ local compinst = target:compiler("cc")
+ if not compinst:has_flags(value) then
+ return false, string.format("%s: unknown c compiler flag '%s'", compinst:name(), value)
+ end
+ return true
+ end})
+end
diff --git a/xmake/plugins/check/checkers/api/target/cxflags.lua b/xmake/plugins/check/checkers/api/target/cxflags.lua
new file mode 100644
index 000000000..9c8df747a
--- /dev/null
+++ b/xmake/plugins/check/checkers/api/target/cxflags.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 cxflags.lua
+--
+
+-- imports
+import("core.tool.compiler")
+import(".api_checker")
+
+function main()
+ api_checker.check_targets("cxflags", {check = function(target, value)
+ local compinst = target:compiler("cxx")
+ if not compinst:has_flags(value) then
+ return false, string.format("%s: unknown c/c++ compiler flag '%s'", compinst:name(), value)
+ end
+ return true
+ end})
+end
diff --git a/xmake/plugins/check/checkers/api/target/cxxflags.lua b/xmake/plugins/check/checkers/api/target/cxxflags.lua
new file mode 100644
index 000000000..6756b07d4
--- /dev/null
+++ b/xmake/plugins/check/checkers/api/target/cxxflags.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 cxxflags.lua
+--
+
+-- imports
+import("core.tool.compiler")
+import(".api_checker")
+
+function main()
+ api_checker.check_targets("cxxflags", {check = function(target, value)
+ local compinst = target:compiler("cxx")
+ if not compinst:has_flags(value) then
+ return false, string.format("%s: unknown c++ compiler flag '%s'", compinst:name(), value)
+ end
+ return true
+ end})
+end
diff --git a/xmake/plugins/check/checkers/api/target/ldflags.lua b/xmake/plugins/check/checkers/api/target/ldflags.lua
new file mode 100644
index 000000000..efe176aa5
--- /dev/null
+++ b/xmake/plugins/check/checkers/api/target/ldflags.lua
@@ -0,0 +1,35 @@
+--!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 ldflags.lua
+--
+
+-- imports
+import("core.tool.compiler")
+import(".api_checker")
+
+function main()
+ api_checker.check_targets("ldflags", {check = function(target, value)
+ if target:is_binary() then
+ local linker = target:linker()
+ if not linker:has_flags(value) then
+ return false, string.format("%s: unknown linker flag '%s'", linker:name(), value)
+ end
+ end
+ return true
+ end})
+end
diff --git a/xmake/plugins/check/checkers/api/target/shflags.lua b/xmake/plugins/check/checkers/api/target/shflags.lua
new file mode 100644
index 000000000..bb518015a
--- /dev/null
+++ b/xmake/plugins/check/checkers/api/target/shflags.lua
@@ -0,0 +1,35 @@
+--!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 shflags.lua
+--
+
+-- imports
+import("core.tool.compiler")
+import(".api_checker")
+
+function main()
+ api_checker.check_targets("shflags", {check = function(target, value)
+ if target:is_shared() then
+ local linker = target:linker()
+ if not linker:has_flags(value) then
+ return false, string.format("%s: unknown linker flag '%s'", linker:name(), value)
+ end
+ end
+ return true
+ end})
+end