summaryrefslogtreecommitdiff
path: root/xmake/core/project
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-06 09:12:08 +0800
committerruki <[email protected]>2016-07-06 09:12:08 +0800
commitd24fcddbc2f1093f3943a917d99c5a8989ef2644 (patch)
tree0cfc7af6e4a318148ed4ba4c13884f3b0e9d7f21 /xmake/core/project
parent33d020825c90d656d1d1a504039e7d9781784e8b (diff)
fix configure error after host changedv2.0.2
Diffstat (limited to 'xmake/core/project')
-rw-r--r--xmake/core/project/config.lua76
1 files changed, 54 insertions, 22 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index 86055d05c..9772f0d6e 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -39,6 +39,32 @@ function config._file()
return path.join(config.directory(), "xmake.conf")
end
+-- load the project configure
+function config._load(targetname)
+
+ -- check
+ targetname = targetname or "all"
+
+ -- load configure from the file first
+ local filepath = config._file()
+ if os.isfile(filepath) then
+
+ -- load it
+ local results, errors = io.load(filepath)
+ if not results then
+ return nil, errors
+ end
+
+ -- load the target configure
+ if results._TARGETS then
+ return table.wrap(results._TARGETS[targetname])
+ end
+ end
+
+ -- empty
+ return {}
+end
+
-- get the current given configure
function config.get(name)
@@ -98,29 +124,16 @@ end
-- load the project configure
function config.load(targetname)
- -- check
- targetname = targetname or "all"
-
- -- load configure from the file first
- local filepath = config._file()
- if os.isfile(filepath) then
-
- -- load it
- local results, errors = io.load(filepath)
+ local results, errors = config._load(targetname)
+ if not results then
+ utils.error(errors)
+ return true
+ end
- -- error?
- if not results then
- utils.error(errors)
- return true
- end
-
- -- merge the target configure first
- if results._TARGETS then
- for name, value in pairs(table.wrap(results._TARGETS[targetname])) do
- if config.get(name) == nil then
- config.set(name, value)
- end
- end
+ -- merge the target configure first
+ for name, value in pairs(results) do
+ if config.get(name) == nil then
+ config.set(name, value)
end
end
@@ -161,6 +174,25 @@ function config.save(targetname)
return io.save(config._file(), results)
end
+-- read value from the configure file directly
+function config.read(name, targetname)
+
+ -- load configs
+ local configs = config._load(targetname)
+
+ -- get it
+ local value = nil
+ if configs then
+ value = configs[name]
+ if type(value) == "string" and value == "auto" then
+ value = nil
+ end
+ end
+
+ -- ok?
+ return value
+end
+
-- init the config
function config.init()