summaryrefslogtreecommitdiff
path: root/xmake/core/base/task.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-24 16:40:40 +0800
committerruki <[email protected]>2016-02-24 16:40:40 +0800
commitdae473cb200c72b9cd94fcfe04c431e59837012f (patch)
treec10c5d804c50230530e7db8140f2174eb7965824 /xmake/core/base/task.lua
parentbd2b7e61c8053041aae4f54537641529d6c10d49 (diff)
show main menu for tasks
Diffstat (limited to 'xmake/core/base/task.lua')
-rw-r--r--xmake/core/base/task.lua51
1 files changed, 44 insertions, 7 deletions
diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua
index 573d8d0d5..333f58edc 100644
--- a/xmake/core/base/task.lua
+++ b/xmake/core/base/task.lua
@@ -55,6 +55,11 @@ function task._interpreter()
-- register api: task()
interp:api_register_scope("task")
+ -- register api: set_task_category()
+ --
+ -- category: main, action, plugin
+ interp:api_register_set_values("task", "task", "category")
+
-- register api: set_task_menu()
interp:api_register_set_values("task", "task", "menu")
@@ -79,13 +84,6 @@ function task._load(filepath)
utils.error(errors)
end
- -- is plugin? mark it
- if path.basename(path.directory(filepath)) == "plugins" then
- for _, v in pairs(results) do
- v.plugin = true
- end
- end
-
-- ok?
return results
end
@@ -128,6 +126,45 @@ end
-- the menu
function task.menu()
+ -- load tasks
+ local tasks = task.tasks()
+ assert(tasks)
+
+ -- make menu
+ local menu = {}
+ for taskname, taskinfo in pairs(tasks) do
+
+ -- has menu?
+ if taskinfo.menu then
+
+ -- main?
+ if taskinfo.category == "main" then
+ menu.main = taskinfo.menu
+ end
+
+ -- add menu
+ menu[taskname] = taskinfo.menu
+ end
+ end
+
+ -- add tasks to the main menu
+ if menu.main then
+
+ -- make tasks for the main menu
+ menu.main.tasks = menu.main.tasks or {}
+ for taskname, taskinfo in pairs(tasks) do
+
+ -- has menu?
+ if taskinfo.menu then
+
+ -- add task
+ menu.main.tasks[taskname] = taskinfo
+ end
+ end
+ end
+
+ -- ok?
+ return menu
end
-- return module: task