summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShifftC <[email protected]>2025-09-24 11:05:41 +0200
committerShifftC <[email protected]>2025-09-29 11:24:56 +0200
commit4d0f2e29c75179d2efd4f5536821f8212556411c (patch)
tree7200b0f2d17cd7494db3935de9a8d0e5012f5632
parent6d7e810e07d1ec1d86c829fdd3cd7b73a27dde79 (diff)
add package kind api checker
-rw-r--r--xmake/modules/private/check/checker.lua2
-rw-r--r--xmake/modules/private/check/checkers/api/package/kind.lua42
2 files changed, 44 insertions, 0 deletions
diff --git a/xmake/modules/private/check/checker.lua b/xmake/modules/private/check/checker.lua
index 8080b608d..923c35809 100644
--- a/xmake/modules/private/check/checker.lua
+++ b/xmake/modules/private/check/checker.lua
@@ -26,6 +26,8 @@ function checkers()
local checkers = _g._CHECKERS
if not checkers then
checkers = {
+ -- package api checkers
+ ["api.package.kind"] = {description = "Check kind configuration in package.", load = true},
-- target api checkers
["api.target.version"] = {description = "Check version configuration in target."},
["api.target.kind"] = {description = "Check kind configuration in target.", build = true},
diff --git a/xmake/modules/private/check/checkers/api/package/kind.lua b/xmake/modules/private/check/checkers/api/package/kind.lua
new file mode 100644
index 000000000..4a9c309e3
--- /dev/null
+++ b/xmake/modules/private/check/checkers/api/package/kind.lua
@@ -0,0 +1,42 @@
+--!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, Xmake Open Source Community.
+--
+-- @author Shiffted
+-- @file kind.lua
+--
+
+import(".api_checker")
+
+function main(opt)
+ opt = opt or {}
+ api_checker.check_packages("kind", table.join(opt, {check = function(package, value)
+ if value == "library" then
+ local extraconf = package:extraconf("kind", "library")
+ if extraconf then
+ if extraconf.headeronly and extraconf.moduleonly then
+ return false, "a library package cannot be set as both 'headeronly' and 'moduleonly'"
+ end
+ for key, _ in pairs(extraconf) do
+ if key ~= "headeronly" and key ~= "moduleonly" then
+ return false, string.format("unknown kind configuration '%s'", key)
+ end
+ end
+ end
+ return true
+ end
+ return value == "binary" or value == "toolchain" or value == "template"
+ end}))
+end