summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-02 00:53:26 +0800
committerruki <[email protected]>2020-06-01 23:20:38 +0800
commit1c11bcdcccf8cf183d9840b56bd003890f0df66b (patch)
tree8f2d49a1cca3a737bf5568afd94537d1c1b35552
parentc9c6aec399bbf0e069f2e5ca2c6596bfb0b80e83 (diff)
show target
-rw-r--r--xmake/core/sandbox/modules/import/core/project/template.lua16
-rw-r--r--xmake/plugins/show/info/target.lua62
-rw-r--r--xmake/plugins/show/lists/packages.lua30
-rw-r--r--xmake/plugins/show/lists/themes.lua28
-rw-r--r--xmake/plugins/show/main.lua13
-rw-r--r--xmake/plugins/show/xmake.lua3
6 files changed, 135 insertions, 17 deletions
diff --git a/xmake/core/sandbox/modules/import/core/project/template.lua b/xmake/core/sandbox/modules/import/core/project/template.lua
index 6671542d2..bfd229687 100644
--- a/xmake/core/sandbox/modules/import/core/project/template.lua
+++ b/xmake/core/sandbox/modules/import/core/project/template.lua
@@ -27,24 +27,12 @@ local raise = require("sandbox/modules/raise")
-- get all languages
function sandbox_core_project_template.languages()
-
- -- get it
- local languages = template.languages()
- assert(languages)
-
- -- ok
- return languages
+ return assert(template.languages())
end
-- load all templates from the given language
function sandbox_core_project_template.templates(language)
-
- -- get it
- local templates = template.templates(language)
- assert(templates)
-
- -- ok
- return templates
+ return assert(template.templates(language))
end
-- return module
diff --git a/xmake/plugins/show/info/target.lua b/xmake/plugins/show/info/target.lua
new file mode 100644
index 000000000..c80b31585
--- /dev/null
+++ b/xmake/plugins/show/info/target.lua
@@ -0,0 +1,62 @@
+--!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 target.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("core.project.project")
+import("core.language.language")
+
+-- show target info
+function main(name)
+
+ -- get target
+ config.load()
+ local target = assert(project.target(name), "target(%s) not found!", name)
+
+ -- show target information
+ print("The information of target(%s):", name)
+ cprint(" ${color.dump.string}kind${clear}: %s", target:targetkind())
+ cprint(" ${color.dump.string}targetfile${clear}: %s", target:targetfile())
+ cprint(" ${color.dump.string}deps${clear}: %s", table.concat(table.wrap(target:get("deps")), ", "))
+ cprint(" ${color.dump.string}rules${clear}: %s", table.concat(table.wrap(target:get("rules")), ", "))
+ cprint(" ${color.dump.string}options${clear}: %s", table.concat(table.wrap(target:get("options")), ", "))
+ cprint(" ${color.dump.string}packages${clear}: %s", table.concat(table.wrap(target:get("packages")), ", "))
+ for _, apiname in ipairs(table.join(language.apis().values, language.apis().pathes)) do
+ if apiname:startswith("target.") then
+ local valuename = apiname:split('.add_', {plain = true})[2]
+ if valuename then
+ local values = target:get(valuename)
+ if values then
+ cprint(" ${color.dump.string}%s${clear}: %s", valuename, table.concat(table.wrap(values), ", "))
+ end
+ end
+ end
+ end
+ cprint(" ${color.dump.string}at${clear}: %s", path.join(target:scriptdir(), "xmake.lua"))
+ for _, sourcebatch in pairs(target:sourcebatches()) do
+ cprint(" ${color.dump.string}sourcebatch${clear}(%s): with rule(%s)", sourcebatch.sourcekind, sourcebatch.rulename)
+ for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ cprint(" -> %s", sourcefile)
+ cprint(" ${dim}-> %s", sourcebatch.objectfiles[idx])
+ cprint(" ${dim}-> %s", sourcebatch.dependfiles[idx])
+ end
+ end
+end
diff --git a/xmake/plugins/show/lists/packages.lua b/xmake/plugins/show/lists/packages.lua
new file mode 100644
index 000000000..fe1e00d4e
--- /dev/null
+++ b/xmake/plugins/show/lists/packages.lua
@@ -0,0 +1,30 @@
+--!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 packages.lua
+--
+
+-- imports
+import("core.project.config")
+import("require.list", {rootdir = path.join(os.programdir(), "actions"), alias = "show_packages"})
+import(".showlist")
+
+-- show all packages
+function main()
+ config.load()
+ show_packages()
+end
diff --git a/xmake/plugins/show/lists/themes.lua b/xmake/plugins/show/lists/themes.lua
new file mode 100644
index 000000000..85030e048
--- /dev/null
+++ b/xmake/plugins/show/lists/themes.lua
@@ -0,0 +1,28 @@
+--!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 themes.lua
+--
+
+-- imports
+import("core.theme.theme")
+import(".showlist")
+
+-- show all themes
+function main()
+ showlist(theme.names())
+end
diff --git a/xmake/plugins/show/main.lua b/xmake/plugins/show/main.lua
index 816ca30a3..08f169a21 100644
--- a/xmake/plugins/show/main.lua
+++ b/xmake/plugins/show/main.lua
@@ -23,7 +23,7 @@ import("core.base.option")
-- show list
function _show_list(name)
- return assert(import("lists." .. name, {try = true, anonymous = true}), "unknown list name(%s)", name)()
+ assert(import("lists." .. name, {try = true, anonymous = true}), "unknown list name(%s)", name)()
end
-- main entry
@@ -32,6 +32,15 @@ function main()
-- show list?
local listname = option.get("list")
if listname then
- return _show_list(listname)
+ _show_list(listname)
+ else
+ for _, filepath in ipairs(os.files(path.join(os.scriptdir(), "info", "*.lua"))) do
+ local name = path.basename(filepath)
+ if option.get(name) then
+ local show_info = assert(import("info." .. name, {try = true, anonymous = true}), "unknown list name(%s)", name)
+ show_info(option.get(name))
+ break
+ end
+ end
end
end
diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua
index 180b2140d..729d2eece 100644
--- a/xmake/plugins/show/xmake.lua
+++ b/xmake/plugins/show/xmake.lua
@@ -41,7 +41,8 @@ task("show")
{'l', "list" , "kv" , nil , "Show the values list of the given name."
, values = function (complete, opt)
return import("list").lists()
- end}
+ end},
+ {'t', "target" , "kv" , nil , "Show the information of the given target."}
}
}