diff options
| author | ruki <[email protected]> | 2020-05-22 00:30:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-21 21:04:59 +0800 |
| commit | eb098b6358005b1fe52e6efba860ab462977825e (patch) | |
| tree | 372d25214efbb2f7cadeafbd32b6e1f561a67a1d | |
| parent | 158492c9932be3a1bb79dbc1b969de06498dd2d1 (diff) | |
add 'xmake show'
| -rw-r--r-- | xmake/plugins/show/list.lua | 31 | ||||
| -rw-r--r-- | xmake/plugins/show/lists/toolchains.lua | 29 | ||||
| -rw-r--r-- | xmake/plugins/show/main.lua | 37 | ||||
| -rw-r--r-- | xmake/plugins/show/xmake.lua | 49 |
4 files changed, 146 insertions, 0 deletions
diff --git a/xmake/plugins/show/list.lua b/xmake/plugins/show/list.lua new file mode 100644 index 000000000..3d44532bb --- /dev/null +++ b/xmake/plugins/show/list.lua @@ -0,0 +1,31 @@ +--!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 list.lua +-- + +-- imports +import("core.base.option") + +-- get all list values +function lists() + local values = {} + for _, filepath in ipairs(os.files(path.join(os.scriptdir(), "lists", "*.lua"))) do + table.insert(values, path.basename(filepath)) + end + return values +end diff --git a/xmake/plugins/show/lists/toolchains.lua b/xmake/plugins/show/lists/toolchains.lua new file mode 100644 index 000000000..a1b7008e3 --- /dev/null +++ b/xmake/plugins/show/lists/toolchains.lua @@ -0,0 +1,29 @@ +--!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 toolchains.lua +-- + +-- imports +import("core.platform.platform") + +-- get all toolchains +function main() + for _, name in ipairs(platform.toolchains()) do + print(name) + end +end diff --git a/xmake/plugins/show/main.lua b/xmake/plugins/show/main.lua new file mode 100644 index 000000000..816ca30a3 --- /dev/null +++ b/xmake/plugins/show/main.lua @@ -0,0 +1,37 @@ +--!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 main.lua +-- + +-- imports +import("core.base.option") + +-- show list +function _show_list(name) + return assert(import("lists." .. name, {try = true, anonymous = true}), "unknown list name(%s)", name)() +end + +-- main entry +function main() + + -- show list? + local listname = option.get("list") + if listname then + return _show_list(listname) + end +end diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua new file mode 100644 index 000000000..180b2140d --- /dev/null +++ b/xmake/plugins/show/xmake.lua @@ -0,0 +1,49 @@ +--!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 task +task("show") + + -- set category + set_category("plugin") + + -- on run + on_run("main") + + -- set menu + set_menu { + -- usage + usage = "xmake show [options] [arguments]" + + -- description + , description = "Show the given project information." + + -- options + , options = + { + {'l', "list" , "kv" , nil , "Show the values list of the given name." + , values = function (complete, opt) + return import("list").lists() + end} + } + } + + + |
