diff options
| author | ruki <[email protected]> | 2016-05-28 19:30:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-05-28 19:30:26 +0800 |
| commit | 7a0445c0612e9065461c1dff3eab6e992d742e4d (patch) | |
| tree | bde652f9383c8b73e7e724b17654d2abe612ecd6 | |
| parent | 125c23d12e9983234c328b805c8da5b8f78ab898 (diff) | |
pass task arguments
| -rw-r--r-- | xmake/core/base/option.lua | 29 | ||||
| -rw-r--r-- | xmake/core/project/task.lua | 4 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/task.lua | 4 | ||||
| -rwxr-xr-x | xmake/plugins/hello/xmake.lua | 4 |
4 files changed, 23 insertions, 18 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua index 9acf1b48b..5e1ee1adf 100644 --- a/xmake/core/base/option.lua +++ b/xmake/core/base/option.lua @@ -481,25 +481,30 @@ function option.defaults(task) return option._context().defaults end + -- the task menu + local taskmenu = option._taskmenu(task) + -- get the default options for the given task local defaults = {} - for _, o in ipairs(option._taskmenu(task).options) do + if taskmenu then + for _, o in ipairs(taskmenu.options) do - -- key=value? - if o[3] == "kv" then + -- key=value? + if o[3] == "kv" then - -- the key - local key = o[2] or o[1] - assert(key) + -- the key + local key = o[2] or o[1] + assert(key) - -- save the default value - defaults[key] = o[4] + -- save the default value + defaults[key] = o[4] - -- value with name? - elseif o[3] == "v" and o[2] then + -- value with name? + elseif o[3] == "v" and o[2] then - -- save the default value - defaults[o[2]] = o[4] + -- save the default value + defaults[o[2]] = o[4] + end end end diff --git a/xmake/core/project/task.lua b/xmake/core/project/task.lua index 101a5ca64..2bdc7c353 100644 --- a/xmake/core/project/task.lua +++ b/xmake/core/project/task.lua @@ -357,7 +357,7 @@ function task.tasks() end -- run task with given name -function task.run(name) +function task.run(name, ...) -- check assert(name) @@ -382,7 +382,7 @@ function task.run(name) end -- run task - return sandbox.load(taskinfo.run) + return sandbox.load(taskinfo.run, ...) end -- the menu diff --git a/xmake/core/sandbox/modules/import/core/project/task.lua b/xmake/core/sandbox/modules/import/core/project/task.lua index 99ef6ea24..599c67c9e 100644 --- a/xmake/core/sandbox/modules/import/core/project/task.lua +++ b/xmake/core/sandbox/modules/import/core/project/task.lua @@ -33,7 +33,7 @@ local task = require("project/task") local raise = require("sandbox/modules/raise") -- run the given task -function sandbox_core_project_task.run(taskname, options) +function sandbox_core_project_task.run(taskname, options, ...) -- init options options = table.wrap(options) @@ -54,7 +54,7 @@ function sandbox_core_project_task.run(taskname, options) end -- run the task - local ok, errors = task.run(taskname) + local ok, errors = task.run(taskname, ...) if not ok then raise(errors) end diff --git a/xmake/plugins/hello/xmake.lua b/xmake/plugins/hello/xmake.lua index 23657f832..fb6bfb320 100755 --- a/xmake/plugins/hello/xmake.lua +++ b/xmake/plugins/hello/xmake.lua @@ -28,7 +28,7 @@ task("hello") -- on run on_run(function () - + -- trace print("hello xmake!") @@ -44,4 +44,4 @@ task("hello") -- options , options = {} - }) + }) |
