summaryrefslogtreecommitdiff
path: root/xmake/core/base/global.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-02 21:06:09 +0800
committerruki <[email protected]>2016-03-02 21:06:09 +0800
commit4fa3ca927a032f57aaae44156ceeec6732c159f6 (patch)
tree1091a3ad18f67ac43262899fa49ea529c67beeff /xmake/core/base/global.lua
parent8ee46b185347f31fa6f4380c887974cdbafbb1d1 (diff)
add option and global module for sandbox
Diffstat (limited to 'xmake/core/base/global.lua')
-rw-r--r--xmake/core/base/global.lua71
1 files changed, 34 insertions, 37 deletions
diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua
index 2e1afcb13..0be86e136 100644
--- a/xmake/core/base/global.lua
+++ b/xmake/core/base/global.lua
@@ -106,7 +106,7 @@ function global.directory()
return dir
end
--- save xmake.conf
+-- save the global configure
function global.save()
-- the configs
@@ -117,52 +117,47 @@ function global.save()
return io.save(global._file(), configs)
end
--- load xmake.conf
+-- load the global configure
function global.load()
- -- the options
- local options = option.options()
- assert(options)
+ -- load configure from the file first
+ local filepath = global._file()
+ if os.isfile(filepath) then
- -- check
- assert(option._MENU)
- assert(option._MENU.global)
+ -- load configs
+ local configs, errors = io.load(filepath)
- -- get all configure names
- local i = 1
- local configures = {}
- for _, o in ipairs(option._MENU.global.options) do
- local name = o[2]
- if global._need(name) then
- configures[i] = name
- i = i + 1
+ -- error?
+ if not configs and errors then
+ utils.error(errors)
end
+
+ -- save configs
+ global._CONFIGS = configs
end
- -- does not clean the cached configure?
- if not option.get("clean") then
+ -- init configs
+ global._CONFIGS = global._CONFIGS or {}
- -- load and execute the xmake.conf
- local filepath = global._file()
- if os.isfile(filepath) then
+ -- make the current configs
+ global._CURRENT = global._make(global._CONFIGS)
- -- load the configure file
- local configs, errors = io.load(filepath)
+ -- ok
+ return true
- -- exists local configures?
- if configs then
- -- save configs
- global._CONFIGS = configs
- elseif errors then
- -- error
- utils.error(errors)
- end
- end
+ --[[
+ -- the options
+ local options = option.options()
+ assert(options)
+
+ -- does not clean the cached configure?
+ if not option.get("clean") then
+
+ TODO
end
+ ]]
- -- init configs
- global._CONFIGS = global._CONFIGS or {}
- local configs = global._CONFIGS
+ --[[
-- xmake global?
if option.task() == "global" then
@@ -198,12 +193,13 @@ function global.load()
end
end
end
+ ]]
- -- make the current global
- global._make()
end
+-- TODO move into probe()
-- clear up and remove all auto values
+--[[
function global.clearup()
-- clear up the current configure
@@ -226,6 +222,7 @@ function global.clearup()
end
end
end
+]]
-- dump the current configure
function global.dump()