summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-05 11:20:58 +0800
committerruki <[email protected]>2015-06-05 11:20:58 +0800
commit4fd209354ecf8a6f90b5a19a18e2268e3c9d649f (patch)
treed2a8ee6f98686abfc14259ca6dee7ab736551c9f /xmake/scripts/base
parent12ce7dea3c7a74f77e9792236cb85bab4fd001e4 (diff)
fix some bug for config
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/config.lua35
-rw-r--r--xmake/scripts/base/global.lua42
-rw-r--r--xmake/scripts/base/main.lua72
3 files changed, 90 insertions, 59 deletions
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