summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-06-23 10:10:37 +0800
committerruki <[email protected]>2016-06-23 10:10:37 +0800
commit9927780525ca16f6c77a86c50b51f6a4fa8eb21a (patch)
treecc9f5df10475a2fad2865d694540bed6234307b7
parente5be4eb9b765b7b3aea3e3d603059e5480e1c7bb (diff)
fix configure and cache bug
-rwxr-xr-xxmake/actions/config/main.lua14
-rw-r--r--xmake/core/project/config.lua66
2 files changed, 27 insertions, 53 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 8146fbdbd..b042793af 100755
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -169,15 +169,21 @@ function main()
raise("unknown target: %s", targetname)
end
- -- save options
+ -- save options and configure for the given target
+ config.save(targetname)
cache.set("options_" .. targetname, options)
+ -- save options and configure for each targets if be all
+ if targetname == "all" then
+ for _, target in pairs(project.targets()) do
+ config.save(target:name())
+ cache.set("options_" .. target:name(), options)
+ end
+ end
+
-- flush cache
cache.flush()
- -- save the project configure
- config.save(targetname)
-
-- make the config.h
config_h.make()
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index a732baed3..86055d05c 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -98,7 +98,7 @@ end
-- load the project configure
function config.load(targetname)
- -- get the target name
+ -- check
targetname = targetname or "all"
-- load configure from the file first
@@ -115,20 +115,13 @@ function config.load(targetname)
end
-- merge the target configure first
- if targetname ~= "all" and results._TARGETS then
+ 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
end
-
- -- merge the root configure
- for name, value in pairs(results) do
- if config.get(name) == nil then
- config.set(name, value)
- end
- end
end
-- ok
@@ -138,46 +131,32 @@ end
-- save the project configure
function config.save(targetname)
- -- get the target name
+ -- check
targetname = targetname or "all"
- -- load configure from the file first
+ -- load the previous results from configure
local results = {}
local filepath = config._file()
if os.isfile(filepath) then
results = io.load(filepath) or {}
end
- -- add version
- results.__version = xmake._VERSION_SHORT
-
- -- update options for the given target
- local target = nil
- if targetname ~= "all" then
-
- -- the targets
- local targets = results._TARGETS or {}
- results._TARGETS = targets
+ -- the targets
+ local targets = results._TARGETS or {}
+ results._TARGETS = targets
- -- clear target and get it
- targets[targetname] = {}
- target = targets[targetname]
- else
-
- -- the targets
- local targets = results._TARGETS
-
- -- clear the root target and get it
- results = {_TARGETS = targets}
- target = results
-
- end
+ -- clear target first
+ targets[targetname] = {}
-- update target
+ local target = targets[targetname]
for name, value in pairs(config.options()) do
target[name] = value
end
+ -- add version
+ results.__version = xmake._VERSION_SHORT
+
-- save it
return io.save(config._file(), results)
end
@@ -201,7 +180,7 @@ end
-- the configure has been changed for the given target?
function config.changed(targetname)
- -- get the target name
+ -- check
targetname = targetname or "all"
-- load configure from the file
@@ -211,20 +190,9 @@ function config.changed(targetname)
-- load it
local results = io.load(filepath)
- if results then
-
- -- get the target configure first
- if targetname ~= "all" and results._TARGETS then
- for name, value in pairs(table.wrap(results._TARGETS[targetname])) do
- fileinfo[name] = value
- end
- end
-
- -- merge the root configure
- for name, value in pairs(results) do
- if fileinfo[name] == nil then
- fileinfo[name] = value
- end
+ if results and results._TARGETS then
+ for name, value in pairs(table.wrap(results._TARGETS[targetname])) do
+ fileinfo[name] = value
end
end
end