diff options
| author | ruki <[email protected]> | 2017-07-19 08:39:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-19 08:39:04 +0800 |
| commit | bfe4432515a8816edc1d32ccfe646096b3ff9c95 (patch) | |
| tree | 9dd3a14003bb8aed40fd392e6bffbe10e2e8145a | |
| parent | 7910713ed804fb60fa8f13b0a4ce915347fc879a (diff) | |
improve global action
| -rw-r--r-- | xmake/actions/config/main.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/global/main.lua | 25 | ||||
| -rw-r--r-- | xmake/core/base/global.lua | 16 | ||||
| -rw-r--r-- | xmake/core/project/config.lua | 8 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/global.lua | 12 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/config.lua | 11 |
6 files changed, 31 insertions, 47 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 92c5e492b..835eb4845 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -184,8 +184,11 @@ function main() -- -- priority: option > option_cache > global > option_default > config_check > project_check > config_cache -- + local override = false if not option.get("clean") then - config.load() + if not config.load() then + override = true + end end -- enter cache scope @@ -201,7 +204,6 @@ function main() end -- override configure from the options or cache - local override = false if not option.get("clean") then options = options or cache.get("options_" .. targetname) end diff --git a/xmake/actions/global/main.lua b/xmake/actions/global/main.lua index 13bf19354..412e0fe6e 100644 --- a/xmake/actions/global/main.lua +++ b/xmake/actions/global/main.lua @@ -29,16 +29,24 @@ import("core.base.global") -- main function main() - -- init the global configure + -- load the global configure -- -- priority: option > option_default > config_check > global_cache -- - global.init() + local override = false + if not option.get("clean") then + if not global.load() then + override = true + end + end -- override the option configure for name, value in pairs(option.options()) do if name ~= "verbose" then - global.set(name, value) + if global.get(name) ~= value then + global.set(name, value) + override = true + end end end @@ -49,14 +57,11 @@ function main() end end - -- merge the checked configure - global.check() - - -- merge the cached configure - if not option.get("clean") then - global.load() + -- check the global configure + if override then + global.check() end - + -- save it global.save() diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua index daa6a6e54..3bf93bde7 100644 --- a/xmake/core/base/global.lua +++ b/xmake/core/base/global.lua @@ -88,6 +88,7 @@ end function global.load() -- load configure from the file first + local ok = false local filepath = global._file() if os.isfile(filepath) then @@ -97,19 +98,20 @@ function global.load() -- error? if not results then utils.error(errors) - return true + return false end -- merge the configure for name, value in pairs(results) do if global.get(name) == nil then global.set(name, value) + ok = true end end end - -- ok - return true + -- ok? + return ok end -- save the global configure @@ -126,14 +128,6 @@ function global.save() return io.save(global._file(), options) end --- init the config -function global.init() - - -- clear it - global._CONFIGS = {} - -end - -- dump the configure function global.dump() diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 235118146..643665173 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -144,18 +144,20 @@ function config.load(targetname) local results, errors = config._load(targetname) if not results then utils.error(errors) - return true + return false end -- merge the target configure first + local ok = false for name, value in pairs(results) do if config.get(name) == nil then config.set(name, value) + ok = true end end - -- ok - return true + -- ok? + return ok end -- save the project configure diff --git a/xmake/core/sandbox/modules/import/core/base/global.lua b/xmake/core/sandbox/modules/import/core/base/global.lua index 925fcbf78..377f3384b 100644 --- a/xmake/core/sandbox/modules/import/core/base/global.lua +++ b/xmake/core/sandbox/modules/import/core/base/global.lua @@ -48,12 +48,7 @@ end -- load the configure function sandbox_core_base_global.load() - - -- load it - local ok, errors = global.load() - if not ok then - raise(errors) - end + return global.load() end -- save the configure @@ -66,11 +61,6 @@ function sandbox_core_base_global.save() end end --- init the configure -function sandbox_core_base_global.init() - global.init() -end - -- check the configure function sandbox_core_base_global.check() diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index 1c1674938..3bf6d1e62 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -68,26 +68,17 @@ end -- get the given configure from the current function sandbox_core_project_config.get(name) - - -- get it return config.get(name) end -- set the given configure to the current function sandbox_core_project_config.set(name, value) - - -- set it return config.set(name, value) end -- load the configure function sandbox_core_project_config.load(targetname) - - -- load it - local ok, errors = config.load(targetname) - if not ok then - raise(errors) - end + return config.load(targetname) end -- save the configure |
