diff options
| author | ruki <[email protected]> | 2015-06-05 11:20:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-05 11:20:58 +0800 |
| commit | 4fd209354ecf8a6f90b5a19a18e2268e3c9d649f (patch) | |
| tree | d2a8ee6f98686abfc14259ca6dee7ab736551c9f | |
| parent | 12ce7dea3c7a74f77e9792236cb85bab4fd001e4 (diff) | |
fix some bug for config
| -rw-r--r-- | xmake/scripts/action/_build.lua | 10 | ||||
| -rw-r--r-- | xmake/scripts/action/_clean.lua | 6 | ||||
| -rw-r--r-- | xmake/scripts/base/config.lua | 35 | ||||
| -rw-r--r-- | xmake/scripts/base/global.lua | 42 | ||||
| -rw-r--r-- | xmake/scripts/base/main.lua | 72 | ||||
| -rw-r--r-- | xmake/scripts/platform/android/prober.lua | 1 |
6 files changed, 103 insertions, 63 deletions
diff --git a/xmake/scripts/action/_build.lua b/xmake/scripts/action/_build.lua index 288485fc1..cf5c1ea93 100644 --- a/xmake/scripts/action/_build.lua +++ b/xmake/scripts/action/_build.lua @@ -33,14 +33,18 @@ local makefile = require("base/makefile") -- done the given config function _build.done() + -- the options + local options = xmake._OPTIONS + assert(options) + -- the target name - local target_name = config.get("target") + local target_name = options.target -- rebuild it? - if config.get("rebuild") or config.get("__rebuild") then + if options.rebuild or config.get("__rebuild") then clean.remove(target_name) -- update it? - elseif config.get("update") then + elseif options.update then clean.remove(target_name, true) end diff --git a/xmake/scripts/action/_clean.lua b/xmake/scripts/action/_clean.lua index 8f026c057..5af3604b7 100644 --- a/xmake/scripts/action/_clean.lua +++ b/xmake/scripts/action/_clean.lua @@ -30,8 +30,12 @@ local config = require("base/config") -- done the given config function _clean.done() + -- the options + local options = xmake._OPTIONS + assert(options) + -- clean the current target - if not clean.remove(config.get("target")) then + if not clean.remove(options.target) then return false end diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua index 8ec455de3..cb9f269c2 100644 --- a/xmake/scripts/base/config.lua +++ b/xmake/scripts/base/config.lua @@ -374,8 +374,18 @@ function config.loadxconf() local name = options.target or options._DEFAULTS.target assert(name and type(name) == "string") - -- init configs - config._CONFIGS = config._CONFIGS or {} + -- init configs if not exists + if not config._CONFIGS then + -- clear configs and mark as "rebuild" + config._CONFIGS = { __rebuild = true } + + -- mark as "reconfig" if the current action is not "config" + if options._ACTION ~= "config" then + config._RECONFIG = true + end + end + + -- the configs local configs = config._CONFIGS -- mark as "rebuild" if clean the cached configure @@ -394,21 +404,26 @@ function config.loadxconf() assert(target and type(target) == "table") -- merge xmake._OPTIONS to target - for k, v in pairs(options) do + if options._ACTION == "config" then + for k, v in pairs(options) do - -- check - assert(type(k) == "string") + -- check + assert(type(k) == "string") - -- skip some options - if not k:startswith("_") and config._need(k) then + -- skip some options + if not k:startswith("_") and config._need(k) then - -- save the option to the target - target[k] = v + -- save the option to the target + target[k] = v + end end end -- merge the default configure options to target - local defaults = option.defaults("config") + local defaults = nil + if config._RECONFIG then defaults = option.defaults("config") + elseif options._ACTION == "config" then defaults = options._DEFAULTS + end if defaults then for k, v in pairs(defaults) do diff --git a/xmake/scripts/base/global.lua b/xmake/scripts/base/global.lua index 5b2f774f5..196cbad9c 100644 --- a/xmake/scripts/base/global.lua +++ b/xmake/scripts/base/global.lua @@ -257,32 +257,36 @@ function global.loadxconf() global._CONFIGS = global._CONFIGS or {} local configs = global._CONFIGS - -- merge xmake._OPTIONS to the global configure - for k, v in pairs(options) do + -- xmake global? + if options._ACTION == "global" then + + -- merge xmake._OPTIONS to the global configure + for k, v in pairs(options) do - -- check - assert(type(k) == "string") + -- check + assert(type(k) == "string") - -- need configure it? - if not k:startswith("_") and global._need(k) then - configs[k] = v + -- need configure it? + if not k:startswith("_") and global._need(k) then + configs[k] = v + end end - end - -- merge the default global configure options to the global configure - local defaults = option.defaults("global") - if defaults then - for k, v in pairs(defaults) do + -- merge the default global configure options to the global configure + local defaults = options._DEFAULTS + if defaults then + for k, v in pairs(defaults) do - -- check - assert(type(k) == "string") + -- check + assert(type(k) == "string") - -- need configure it? - if global._need(k) then + -- need configure it? + if global._need(k) then - -- save the default option - if not configs[k] then - configs[k] = v + -- save the default option + if not configs[k] then + configs[k] = v + end end end end diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index 96c3eac00..df9e00105 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -402,6 +402,39 @@ local menu = } } +-- prepare global +function main._prepare_global() + + -- the options + local options = xmake._OPTIONS + assert(options) + + -- load global configure + global.loadxconf() + + -- xmake global? + if options._ACTION == "global" then + + -- wrap the global configure for more convenient to get and set values + local global_wrapped = {} + setmetatable(global_wrapped, + { + __index = function(tbl, key) + return global.get(key) + end, + __newindex = function(tbl, key, val) + global.set(key, val) + end + }) + + -- probe the global platform configure + platform.probe(global_wrapped, true) + end + + -- ok + return true +end + -- prepare project function main._prepare_project() @@ -453,6 +486,11 @@ function main._prepare_project() end + -- merge the default options + for k, v in pairs(options._DEFAULTS) do + if not options[k] then options[k] = v end + end + -- load xmake.xproj file return project.loadxproj(options.file) end @@ -491,35 +529,6 @@ function main._done_help() end end --- done global -function main._done_global() - - -- the options - local options = xmake._OPTIONS - assert(options) - - -- load global configure - global.loadxconf() - - -- wrap the global configure for more convenient to get and set values - local global_wrapped = {} - setmetatable(global_wrapped, - { - __index = function(tbl, key) - return global.get(key) - end, - __newindex = function(tbl, key, val) - global.set(key, val) - end - }) - - -- probe the global platform configure - platform.probe(global_wrapped, true) - - -- done action - return action.done("global") -end - -- done option function main._done_option() @@ -537,9 +546,12 @@ function main._done_option() return action.done("lua") end + -- prepare global + main._prepare_global() + -- done global? if options._ACTION == "global" then - return main._done_global() + return action.done("global") end -- prepare project diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua index e04d49c1e..9e564b0cd 100644 --- a/xmake/scripts/platform/android/prober.lua +++ b/xmake/scripts/platform/android/prober.lua @@ -25,6 +25,7 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local string = require("base/string") +local tools = require("tools/tools") -- define module: prober local prober = prober or {} |
