summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-16 23:49:59 +0800
committerruki <[email protected]>2020-03-16 16:59:55 +0800
commit9380776bfeeb904ce9ed09347809aa1f929c28cc (patch)
tree74ae000c8cf9ea70d8b028341529db81eadaffd5
parent9669ee1d0a0aaa19e5e63c9fd94eb3a9e49ac965 (diff)
add dump_targets
-rw-r--r--xmake/modules/private/diagnosis/dump_buildjobs.lua2
-rw-r--r--xmake/modules/private/diagnosis/dump_targets.lua73
2 files changed, 74 insertions, 1 deletions
diff --git a/xmake/modules/private/diagnosis/dump_buildjobs.lua b/xmake/modules/private/diagnosis/dump_buildjobs.lua
index 01ba42d7b..191e28a66 100644
--- a/xmake/modules/private/diagnosis/dump_buildjobs.lua
+++ b/xmake/modules/private/diagnosis/dump_buildjobs.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
--- @file object.lua
+-- @file dump_buildjobs.lua
--
-- imports
diff --git a/xmake/modules/private/diagnosis/dump_targets.lua b/xmake/modules/private/diagnosis/dump_targets.lua
new file mode 100644
index 000000000..865d67daf
--- /dev/null
+++ b/xmake/modules/private/diagnosis/dump_targets.lua
@@ -0,0 +1,73 @@
+--!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 dump_targets.lua
+--
+
+-- imports
+import("core.base.hashset")
+import("core.project.config")
+import("core.project.project")
+
+-- get targets
+function _get_targets(targetname)
+
+ -- get targets
+ local targets = {}
+ if targetname then
+ table.insert(targets, project.target(targetname))
+ else
+ for _, target in pairs(project.targets()) do
+ table.insert(targets, target)
+ end
+ end
+ return targets
+end
+
+-- dump the build jobs, e.g. xmake l private.diagnosis.dump_buildjobs [targetname]
+function main(targetname)
+ config.load()
+ for _, target in ipairs(_get_targets(targetname)) do
+ print("target(%s): %s", target:name(), target:targetkind())
+ local deps = target:get("deps")
+ if deps then
+ cprint(" ${color.dump.string}deps:")
+ cprint(" ${yellow}->${clear} %s", table.concat(table.wrap(deps), ", "))
+ end
+ local options = {}
+ for _, optname in ipairs(target:get("options")) do
+ if not optname:startswith("__") then
+ table.insert(options, optname)
+ end
+ end
+ if #options > 0 then
+ cprint(" ${color.dump.string}options:")
+ cprint(" ${yellow}->${clear} %s", table.concat(table.wrap(options), ", "))
+ end
+ local packages = target:get("packages")
+ if packages then
+ cprint(" ${color.dump.string}packages:")
+ cprint(" ${yellow}->${clear} %s", table.concat(table.wrap(packages), ", "))
+ end
+ local rules = target:get("rules")
+ if rules then
+ cprint(" ${color.dump.string}rules:")
+ cprint(" ${yellow}->${clear} %s", table.concat(table.wrap(rules), ", "))
+ end
+ end
+end
+