diff options
| author | ruki <[email protected]> | 2015-05-12 08:50:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-12 08:50:21 +0800 |
| commit | a0185c1df5558103ca4c510036088a17bf379c94 (patch) | |
| tree | 878a6c107ffed11cb93f28d831920825ef472fe7 /xmake/scripts | |
| parent | 3b93e699c16862a1c29c2047425ce3d8a4827ea7 (diff) | |
add _DEFAULTS options
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/action/config.lua | 5 | ||||
| -rw-r--r-- | xmake/scripts/base/main.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/base/option.lua | 8 |
3 files changed, 6 insertions, 11 deletions
diff --git a/xmake/scripts/action/config.lua b/xmake/scripts/action/config.lua index d8767171b..e12ac898c 100644 --- a/xmake/scripts/action/config.lua +++ b/xmake/scripts/action/config.lua @@ -49,7 +49,7 @@ function config._save_option(file, option) for k, v in pairs(option) do -- skip --project and --file - if k ~= "project" and k ~= "file" and k ~= "verbose" and k ~= "_ACTION" then + if type(k) == "string" and not k:startswith("_") and k ~= "project" and k ~= "file" and k ~= "verbose" then -- save separator file:write(utils.ifelse(i == 0, " ", ", "), k, " = ") @@ -146,9 +146,6 @@ function config._load() -- update configs to xmake._OPTIONS xmake._OPTIONS = configs - else - -- error - utils.error("%s not found!", path) end end diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index eb1a57c3d..811f0a650 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -265,12 +265,12 @@ function main._done_option() assert(options) -- init the project directory - options.project = options.project or _PROJECT_DIR + options.project = options.project or options._DEFAULTS.project or _PROJECT_DIR options.project = path.absolute(options.project) assert(options.project) -- init the xmake.lua file path - options.file = options.file or "xmake.lua" + options.file = options.file or options._DEFAULTS.file or "xmake.lua" options.file = path.absolute(options.file, options.project) assert(options.file) diff --git a/xmake/scripts/base/option.lua b/xmake/scripts/base/option.lua index 0a6f4dd92..13ac012d9 100644 --- a/xmake/scripts/base/option.lua +++ b/xmake/scripts/base/option.lua @@ -38,6 +38,7 @@ function option.init(argv, menu) -- init _OPTIONS xmake._OPTIONS = {} + xmake._OPTIONS._DEFAULTS = {} -- save menu option._MENU = menu @@ -240,11 +241,8 @@ function option.init(argv, menu) local key = o[2] or o[1] assert(key) - -- exists the default value? - if not xmake._OPTIONS[key] and o[4] then - -- save the default value - xmake._OPTIONS[key] = o[4] - end + -- save the default value + xmake._OPTIONS._DEFAULTS[key] = o[4] end end |
