summaryrefslogtreecommitdiff
path: root/xmake
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
parent33d020825c90d656d1d1a504039e7d9781784e8b (diff)
fix configure error after host changedv2.0.2
Diffstat (limited to 'xmake')
-rwxr-xr-xxmake/actions/config/main.lua7
-rw-r--r--xmake/core/project/config.lua76
-rw-r--r--xmake/core/sandbox/modules/import/core/project/config.lua7
3 files changed, 67 insertions, 23 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 9b7790f0c..8b46f58a1 100755
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -34,6 +34,11 @@ function _option_filter(name)
return name and name ~= "target" and name ~= "file" and name ~= "project" and name ~= "verbose"
end
+-- host changed?
+function _host_changed(targetname)
+ return os.host() ~= config.read("host", targetname)
+end
+
-- need check
function _need_check()
@@ -194,7 +199,7 @@ function main()
end
-- merge the cached configure
- if not option.get("clean") then
+ if not option.get("clean") and not _host_changed(targetname) then
config.load(targetname)
end
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()
diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua
index 99f48ace0..940cdb472 100644
--- a/xmake/core/sandbox/modules/import/core/project/config.lua
+++ b/xmake/core/sandbox/modules/import/core/project/config.lua
@@ -109,6 +109,13 @@ function sandbox_core_project_config.save(targetname)
end
end
+-- read the value from the configure file directly
+function sandbox_core_project_config.read(name, targetname)
+
+ -- read it
+ return config.read(name, targetname)
+end
+
-- the configure has been changed for the given target?
function sandbox_core_project_config.changed(targetname)