summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-20 00:27:09 +0800
committerruki <[email protected]>2022-04-20 00:27:09 +0800
commit77e9c353d2d6c4236465ba343191e162445e884a (patch)
tree1e6b80624e441b0ccdc8821e807cfc0676d22ab9
parent618a5511f0a3b87b157e921359332b69bb409a3b (diff)
improve to import config
-rw-r--r--xmake/actions/config/main.lua4
-rw-r--r--xmake/core/project/config.lua5
2 files changed, 5 insertions, 4 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index bd8b6f8dd..f665fe47f 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -307,7 +307,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
-- override configuration from the options or cache
local options_history = {}
- if not option.get("clean") and not autogen and not option.get("import") then
+ if not option.get("clean") and not autogen then
options_history = localcache.get("config", "options") or {}
options = options or options_history
end
@@ -325,7 +325,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
if importfile then
assert(os.isfile(importfile), "%s not found!", importfile)
-- we need use readonly, @see https://github.com/xmake-io/xmake/issues/2278
- if config.load(importfile, {readonly = true}) then
+ if config.load(importfile, {force = true, readonly = true}) then
options_changed = true
end
end
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index da1ac0ba6..2d0984a91 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -135,9 +135,10 @@ end
-- load the project configuration
--
--- @param opt {readonly = true}
+-- @param opt {readonly = true, force = true}
--
function config.load(filepath, opt)
+ opt = opt or {}
local configs, errors
filepath = filepath or config.filepath()
if os.isfile(filepath) then
@@ -151,7 +152,7 @@ function config.load(filepath, opt)
local ok = false
if configs then
for name, value in pairs(configs) do
- if config.get(name) == nil then
+ if config.get(name) == nil or opt.force then
config.set(name, value, opt)
ok = true
end