summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-21 00:46:12 +0800
committerruki <[email protected]>2022-04-21 00:46:12 +0800
commit9aa2955ff1e5a865a5d02c8be5219fa959b9a562 (patch)
tree205098263c3639673a2bb80d968af28f6d115496
parentac4e75aa8863be23f984a44a3b05f5855251441a (diff)
improve to import configs
-rw-r--r--xmake/actions/config/main.lua28
1 files changed, 16 insertions, 12 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index f665fe47f..62c259219 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -305,6 +305,22 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
end
end
+ -- merge options from the given import file
+ local importfile = option.get("import")
+ if importfile then
+ assert(os.isfile(importfile), "%s not found!", importfile)
+ -- we need use readonly, @see https://github.com/xmake-io/xmake/issues/2278
+ local import_configs = io.load(importfile)
+ if import_configs then
+ for name, value in pairs(import_configs) do
+ options = options or {}
+ if options[name] == nil then
+ options[name] = value
+ end
+ end
+ end
+ end
+
-- override configuration from the options or cache
local options_history = {}
if not option.get("clean") and not autogen then
@@ -312,24 +328,12 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
options = options or options_history
end
for name, value in pairs(options) do
-
-- options is changed by argument options?
options_changed = options_changed or options_history[name] ~= value
-
-- @note override it and mark as readonly (highest priority)
config.set(name, value, {readonly = true})
end
- -- merge configuration from the given import file
- local importfile = option.get("import")
- 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, {force = true, readonly = true}) then
- options_changed = true
- end
- end
-
-- merge the cached configuration
--
-- @note we cannot load cache config when switching platform, arch ..