summaryrefslogtreecommitdiff
path: root/xmake/core/project/global.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-04-05 09:49:33 +0800
committerruki <[email protected]>2016-04-05 09:49:33 +0800
commitee1293db712b47706496da86e0564010bafdaaa9 (patch)
tree3d39b3830789da4a4d9e7c9b1abfca71ba27b205 /xmake/core/project/global.lua
parentfedf748ddd3353f6065dc2502eaec2e396bc2c2a (diff)
adjust global priority
Diffstat (limited to 'xmake/core/project/global.lua')
-rw-r--r--xmake/core/project/global.lua51
1 files changed, 16 insertions, 35 deletions
diff --git a/xmake/core/project/global.lua b/xmake/core/project/global.lua
index f4e386c08..cd4682e15 100644
--- a/xmake/core/project/global.lua
+++ b/xmake/core/project/global.lua
@@ -34,17 +34,17 @@ local option = require("base/option")
function global._file()
-- get it
- return path.join(global.directory(), "/xmake.conf")
+ return path.join(global.directory(), "xmake.conf")
end
-- get the current given configure from
function global.get(name)
- -- check
- assert(name and global._CONFIGS)
+ -- get configs
+ local configs = global._CONFIGS or {}
-- the value
- local value = global._CONFIGS[name]
+ local value = configs[name]
if type(value) == "string" and value == "auto" then
value = nil
end
@@ -56,35 +56,15 @@ end
-- set the current given configure
function global.set(name, value)
- -- check
- assert(global._CONFIGS and name)
+ -- get configs
+ local configs = global._CONFIGS or {}
+ global._CONFIGS = configs
-- set it
- global._CONFIGS[name] = value
+ configs[name] = value
end
--- clean the global configure
-function global.clean()
-
- -- check
- assert(global._CONFIGS)
-
- -- clean it
- global._CONFIGS = {}
-
- -- save it
- if os.isfile(global._file()) then
- local ok, errors = os.rm(global._file())
- if not ok then
- return false, errors
- end
- end
-
- -- ok
- return true
-end
-
-- get all options
function global.options()
@@ -118,20 +98,21 @@ function global.load()
if os.isfile(filepath) then
-- load configs
- local configs, errors = io.load(filepath)
+ local results, errors = io.load(filepath)
-- error?
- if not configs and errors then
+ if not results and errors then
utils.error(errors)
end
- -- save configs
- global._CONFIGS = configs
+ -- merge the configure
+ for name, value in pairs(results) do
+ if global.get(name) == nil then
+ global.set(name, value)
+ end
+ end
end
- -- init configs
- global._CONFIGS = global._CONFIGS or {}
-
-- ok
return true
end