summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2020-11-08 11:07:41 +0800
committerruki <[email protected]>2020-11-08 11:07:41 +0800
commitea6afc015b3c3f391761ba13a03c966daedd6db4 (patch)
tree5ad9183da6470ba09542bd8b6634d149a9647fb0 /xmake/rules
parent8b032f72b8f3972fe702b6f3f20d07d2d1696739 (diff)
add check_licenses
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/c++/xmake.lua3
-rw-r--r--xmake/rules/utils/check_licenses/check_licenses.lua42
-rw-r--r--xmake/rules/utils/check_licenses/xmake.lua24
-rw-r--r--xmake/rules/utils/check_targets/check_targets.lua2
4 files changed, 70 insertions, 1 deletions
diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua
index 5a68ab3e8..51b5d355f 100644
--- a/xmake/rules/c++/xmake.lua
+++ b/xmake/rules/c++/xmake.lua
@@ -60,3 +60,6 @@ rule("c++")
-- check targets
add_deps("utils.check.targets")
+
+ -- check licenses
+ add_deps("utils.check.licenses")
diff --git a/xmake/rules/utils/check_licenses/check_licenses.lua b/xmake/rules/utils/check_licenses/check_licenses.lua
new file mode 100644
index 000000000..2d356f61a
--- /dev/null
+++ b/xmake/rules/utils/check_licenses/check_licenses.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-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_licenses.lua
+--
+
+-- check licenses
+function _check_licenses_for_package(target_name, target_license, package_name, package_licenses)
+ -- TODO
+end
+
+-- check licenses for all dependent packages
+--
+-- @see https://github.com/xmake-io/xmake/issues/1016
+--
+function _check_licenses_for_packages(target)
+ local target_license = target:get("license")
+ if target_license then
+ for _, pkg in ipairs(target:orderpkgs()) do
+ _check_licenses_for_package(target:name(), target_license, pkg:name(), pkg:get("license"))
+ end
+ end
+end
+
+-- main entry
+function main(target)
+ _check_licenses_for_packages(target)
+end
diff --git a/xmake/rules/utils/check_licenses/xmake.lua b/xmake/rules/utils/check_licenses/xmake.lua
new file mode 100644
index 000000000..c007e07d9
--- /dev/null
+++ b/xmake/rules/utils/check_licenses/xmake.lua
@@ -0,0 +1,24 @@
+--!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-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define rule: utils.check.licenses
+rule("utils.check.licenses")
+ before_build("check_licenses")
+
diff --git a/xmake/rules/utils/check_targets/check_targets.lua b/xmake/rules/utils/check_targets/check_targets.lua
index d92345faf..a01899ba7 100644
--- a/xmake/rules/utils/check_targets/check_targets.lua
+++ b/xmake/rules/utils/check_targets/check_targets.lua
@@ -32,7 +32,7 @@ function main(target)
for _, value in ipairs(_get_values_from_target(target, name)) do
if not os.isdir(value) then
local sourceinfo = (target:get("__sourceinfo_" .. name) or {})[value] or {}
- cprint("${color.warning}${text.warning}: %s(%s).add_%s(\"%s\") path not found at %s:%d", target:type(), target:name(), name, value, sourceinfo.file or "", sourceinfo.line or -1)
+ wprint("%s(%s).add_%s(\"%s\") path not found at %s:%d", target:type(), target:name(), name, value, sourceinfo.file or "", sourceinfo.line or -1)
end
end
end