summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-24 21:09:46 +0800
committerruki <[email protected]>2016-02-24 21:09:46 +0800
commitac6323f24c35b446c1f550378c19aad9b6a6940f (patch)
treef1a8eb0939970df62c8ad12c930b911a1e352087
parent00958c7b39c53a7e597ff6705ae9b1e2baeece4b (diff)
show submenu for task
-rw-r--r--xmake/core/base/action.lua4
-rw-r--r--xmake/core/base/config.lua8
-rw-r--r--xmake/core/base/global.lua2
-rw-r--r--xmake/core/base/main.lua4
-rw-r--r--xmake/core/base/option.lua68
-rwxr-xr-xxmake/core/tasks/build.lua7
6 files changed, 45 insertions, 48 deletions
diff --git a/xmake/core/base/action.lua b/xmake/core/base/action.lua
index 2cb7c71cf..c84d43b3c 100644
--- a/xmake/core/base/action.lua
+++ b/xmake/core/base/action.lua
@@ -63,7 +63,7 @@ function action._load_project()
end
-- xmake config or marked as "reconfig"?
- if options._ACTION == "config" or config._RECONFIG then
+ if options._TASK == "config" or config._RECONFIG then
-- probe the current project
project.probe()
@@ -102,7 +102,7 @@ function action.done(name)
end
-- probe the platform
- if _action.need("platform") and (options._ACTION == "config" or config._RECONFIG) then
+ if _action.need("platform") and (options._TASK == "config" or config._RECONFIG) then
if not platform.probe(false) then
return false
end
diff --git a/xmake/core/base/config.lua b/xmake/core/base/config.lua
index 80928c091..3f7b1d8b1 100644
--- a/xmake/core/base/config.lua
+++ b/xmake/core/base/config.lua
@@ -237,7 +237,7 @@ function config.load()
config._CONFIGS = { __rebuild = true }
-- mark as "reconfig" if the current action is not "config"
- if options._ACTION ~= "config" then
+ if options._TASK ~= "config" then
config._RECONFIG = true
end
end
@@ -275,7 +275,7 @@ function config.load()
config._CONFIGS = { __rebuild = true }
-- mark as "reconfig" if the current action is not "config"
- if options._ACTION ~= "config" then
+ if options._TASK ~= "config" then
config._RECONFIG = true
end
end
@@ -292,7 +292,7 @@ function config.load()
local defaults = nil
if not configs._DEFAULTS then
if config._RECONFIG then defaults = option.defaults("config")
- elseif options._ACTION == "config" then defaults = options._DEFAULTS
+ elseif options._TASK == "config" then defaults = options._DEFAULTS
end
if defaults then
for k, v in pairs(defaults) do
@@ -323,7 +323,7 @@ function config.load()
assert(target and type(target) == "table")
-- merge xmake._OPTIONS to target
- if options._ACTION == "config" then
+ if options._TASK == "config" then
for k, v in pairs(options) do
-- check
diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua
index fa890817e..f93f6a4c8 100644
--- a/xmake/core/base/global.lua
+++ b/xmake/core/base/global.lua
@@ -169,7 +169,7 @@ function global.load()
local configs = global._CONFIGS
-- xmake global?
- if options._ACTION == "global" then
+ if options._TASK == "global" then
-- merge xmake._OPTIONS to the global configure
for k, v in pairs(options) do
diff --git a/xmake/core/base/main.lua b/xmake/core/base/main.lua
index 3e8289ba9..7d6ecb8f5 100644
--- a/xmake/core/base/main.lua
+++ b/xmake/core/base/main.lua
@@ -56,7 +56,7 @@ function main._done_help()
if options.help then
-- print menu
- option.print_menu(options._ACTION)
+ option.print_menu(options._TASK)
-- ok
return true
@@ -92,7 +92,7 @@ function main._done_option()
end
-- done action
- return action.done(options._ACTION or "build")
+ return action.done(options._TASK or "build")
end
-- the init function for main
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 08269397d..8ceca5a33 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -30,7 +30,7 @@ local table = require("base/table")
-- translate the menu
function option._translate(menu)
- -- translate the action menus if exists function
+ -- translate the menus if exists function
local submenus_all = {}
for k, submenu in pairs(menu) do
if type(submenu) == "function" then
@@ -139,7 +139,7 @@ function option.init(argv, menu)
print("invalid option: " .. arg)
-- print menu
- option.print_menu(xmake._OPTIONS._ACTION)
+ option.print_menu(xmake._OPTIONS._TASK)
-- failed
return false
@@ -150,7 +150,7 @@ function option.init(argv, menu)
-- find this option
local opt = nil
- for _, o in ipairs(menu[xmake._OPTIONS._ACTION or "main"].options) do
+ for _, o in ipairs(menu[xmake._OPTIONS._TASK or "main"].options) do
-- check
assert(o)
@@ -173,7 +173,7 @@ function option.init(argv, menu)
print("invalid option: " .. arg)
-- print menu
- option.print_menu(xmake._OPTIONS._ACTION)
+ option.print_menu(xmake._OPTIONS._TASK)
-- failed
return false
@@ -193,7 +193,7 @@ function option.init(argv, menu)
print("invalid option: " .. utils.ifelse(idx, arg, key))
-- print menu
- option.print_menu(xmake._OPTIONS._ACTION)
+ option.print_menu(xmake._OPTIONS._TASK)
-- failed
return false
@@ -210,7 +210,7 @@ function option.init(argv, menu)
print("invalid option: " .. arg)
-- print menu
- option.print_menu(xmake._OPTIONS._ACTION)
+ option.print_menu(xmake._OPTIONS._TASK)
-- failed
return false
@@ -226,28 +226,28 @@ function option.init(argv, menu)
-- save option
xmake._OPTIONS[utils.ifelse(prefix == 1 and opt[2], opt[2], key)] = value
- -- action?
+ -- task?
elseif idx == 1 then
- -- find this action
- for _, action in ipairs(main.actions) do
+ -- find the current task
+ for taskname, taskinfo in pairs(main.tasks) do
-- check
- assert(menu[action])
+ assert(menu[taskname])
-- ok?
- if action == key or menu[action].shortname == key then
- -- save this action
- xmake._OPTIONS._ACTION = action
+ if taskname == key or menu[taskname].shortname == key then
+ -- save this task
+ xmake._OPTIONS._TASK = taskname
break
end
end
-- not found?
- if not xmake._OPTIONS._ACTION or not menu[xmake._OPTIONS._ACTION] then
+ if not xmake._OPTIONS._TASK or not menu[xmake._OPTIONS._TASK] then
- -- invalid action
- print("invalid action: " .. key)
+ -- invalid task
+ print("invalid task: " .. key)
-- print the main menu
option.print_main()
@@ -262,7 +262,7 @@ function option.init(argv, menu)
-- find a value option with name
local opt = nil
- for _, o in ipairs(menu[xmake._OPTIONS._ACTION or "main"].options) do
+ for _, o in ipairs(menu[xmake._OPTIONS._TASK or "main"].options) do
-- the mode
local mode = o[3]
@@ -312,7 +312,7 @@ function option.init(argv, menu)
print("invalid option: " .. arg)
-- print menu
- option.print_menu(xmake._OPTIONS._ACTION)
+ option.print_menu(xmake._OPTIONS._TASK)
-- failed
return false
@@ -322,7 +322,7 @@ function option.init(argv, menu)
end
-- init the default value
- for _, o in ipairs(menu[xmake._OPTIONS._ACTION or "main"].options) do
+ for _, o in ipairs(menu[xmake._OPTIONS._TASK or "main"].options) do
-- key=value?
if o[3] == "kv" then
@@ -376,14 +376,14 @@ function option.find(argv, name, shortname)
end
end
--- get all default options from the given action
-function option.defaults(action)
+-- get all default options from the given task
+function option.defaults(task)
-- make defaults
local defaults = {}
-- init the default value
- for _, o in ipairs(option._MENU[action or "main"].options) do
+ for _, o in ipairs(option._MENU[task or "main"].options) do
-- key=value?
if o[3] == "kv" then
@@ -406,10 +406,10 @@ function option.defaults(action)
end
-- print the menu
-function option.print_menu(action)
+function option.print_menu(task)
- -- no action? print main menu
- if not action then
+ -- no task? print main menu
+ if not task then
option.print_main()
return
end
@@ -418,9 +418,9 @@ function option.print_menu(action)
local menu = option._MENU
assert(menu)
- -- the action
- action = menu[action]
- assert(action)
+ -- the task menu
+ local taskmenu = menu[task]
+ assert(taskmenu)
-- print title
if menu.title then
@@ -433,20 +433,20 @@ function option.print_menu(action)
end
-- print usage
- if action.usage then
+ if taskmenu.usage then
print("")
- print("Usage: " .. action.usage)
+ print("Usage: " .. taskmenu.usage)
end
-- print description
- if action.description then
+ if taskmenu.description then
print("")
- print(action.description)
+ print(taskmenu.description)
end
-- print options
- if action.options then
- option.print_options(action.options)
+ if taskmenu.options then
+ option.print_options(taskmenu.options)
end
end
diff --git a/xmake/core/tasks/build.lua b/xmake/core/tasks/build.lua
index 7c18028d3..abe643e93 100755
--- a/xmake/core/tasks/build.lua
+++ b/xmake/core/tasks/build.lua
@@ -7,13 +7,10 @@ task("build")
-- set menu
set_task_menu({
-- usage
- usage = "xmake [action] [options] [target]"
+ usage = "xmake [task] [options] [target]"
-- description
- , description = "Build the project if no given action."
-
- -- actions
- -- , actions = function () return task.menu(true) end
+ , description = "Build the project if no given tasks."
-- options
, options =