diff options
| author | ruki <[email protected]> | 2015-05-12 09:47:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-12 09:47:58 +0800 |
| commit | fc66b05d2d238830106890447db7ed3808375de1 (patch) | |
| tree | 68a1947e2a98e59a3d6b1f0b056551d4be076cde | |
| parent | 7a187d3be10e1aeced3b1cc84a1d3b458ecfc53d (diff) | |
merge defaults to configs
| -rw-r--r-- | xmake/scripts/action/config.lua | 43 | ||||
| -rw-r--r-- | xmake/scripts/base/main.lua | 19 |
2 files changed, 43 insertions, 19 deletions
diff --git a/xmake/scripts/action/config.lua b/xmake/scripts/action/config.lua index fb822422e..663877ff4 100644 --- a/xmake/scripts/action/config.lua +++ b/xmake/scripts/action/config.lua @@ -136,14 +136,25 @@ function config._load() -- check assert(configs and type(configs) == "table") - -- ok? merge xmake._OPTIONS to configs + -- merge xmake._OPTIONS to configs for k, v in pairs(xmake._OPTIONS) do - if type(k) == "string" then + + -- check + assert(type(k) == "string") + + -- merge it + configs[k] = v + end + + -- merge xmake._OPTIONS._DEFAULTS to configs + for k, v in pairs(xmake._OPTIONS._DEFAULTS) do + + -- check + assert(type(k) == "string") + + -- merge it + if not configs[k] then configs[k] = v - else - -- error - utils.error("invalid option type: %s", type(k)) - return end end @@ -151,6 +162,16 @@ function config._load() xmake._OPTIONS = configs end end + +-- dump options +function config._dump() + + -- dump + for k, v in pairs(xmake._OPTIONS) do + utils.printf("%s = %s", k, v) + end + +end -- done the given config function config.done() @@ -158,16 +179,16 @@ function config.done() -- attempt to load configs to xmake._OPTIONS from the configure file config._load() + -- TODO + + -- dump options + config._dump() + -- save options to the configure file if not config._save() then return false end - -- dump - for k, v in pairs(xmake._OPTIONS) do - utils.printf("%s = %s", k, v) - end - -- ok return true end diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index ff4ddfaac..9a032f5a8 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -141,9 +141,10 @@ local menu = { {'p', "plat", "kv", "auto", "Compile for the given platform." } , {'a', "arch", "kv", "auto", "Compile for the given architecture." } - , {'d', "debug", "k", nil, "Compile for the debugging mode." } - , {'s', "small", "k", nil, "Compile for the small mode." } - , {nil, "profile", "k", nil, "Compile for the profiling mode and disable the debugging mode."} + , {'m', "mode", "kv", "release", "Compile for the given mode." + , " - debug" + , " - release" + , " - profile" } , {} , {'o', "output", "kv", "build", "Set the build directory" } @@ -277,20 +278,18 @@ function main._done_option() assert(options.file) -- load and execute the xmake.lua script of the given project + local errors = nil local script = loadfile(options.file) if script then -- execute it local ok, err = pcall(script) if not ok then -- error - utils.error("load %s failed!", options.file) - utils.error(err) - return false + errors = err end else -- error - utils.error("%s not found!", options.file) - return false + errors = string.format("%s not found!", options.file) end -- done help @@ -317,6 +316,10 @@ function main._done_option() -- ok return true + elseif errors then + -- error + utils.error(errors) + return false end -- done action |
