diff options
| author | ruki <[email protected]> | 2021-06-15 22:47:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-06-15 22:47:49 +0800 |
| commit | debc652cd0448967a9a2c5425a1d1ae7c6235af0 (patch) | |
| tree | 2f8d8283242ff5af3129cc6b256f19d6aa655325 /xmake/actions/config/main.lua | |
| parent | b820270442536da435f5fb5582bf56b8bde53011 (diff) | |
add import/export configs
Diffstat (limited to 'xmake/actions/config/main.lua')
| -rw-r--r-- | xmake/actions/config/main.lua | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 61f497c77..68f8ab531 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -48,6 +48,8 @@ function _option_filter(name) , verbose = true , diagnosis = true , require = true + , export = true + , import = true } return not options[name] end @@ -189,6 +191,14 @@ function _config_targets(targetname) end end +-- export configs +function _export_configs() + local exportfile = option.get("export") + if exportfile then + config.save(exportfile, {public = true}) + end +end + -- main entry function main(opt) @@ -229,7 +239,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- the target name local targetname = option.get("target") or "all" - -- load the project configure + -- load the project configuration -- -- priority: option > option_cache > global > option_default > config_check > project_check > config_cache -- @@ -243,7 +253,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end end - -- override configure from the options or cache + -- override configuration from the options or cache local options_history = {} if not option.get("clean") and not autogen then options_history = localcache.get("config", "options") or {} @@ -258,7 +268,15 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) config.set(name, value, {readonly = true}) end - -- merge the cached configure + -- merge configuration from the given import file + local importfile = option.get("import") + if importfile and os.isfile(importfile) then + if config.load(importfile) then + options_changed = true + end + end + + -- merge the cached configuration -- -- @note we cannot load cache config when switching platform, arch .. -- so we need known whether options have been changed @@ -268,7 +286,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) configcache_loaded = config.load() end - -- merge the global configure + -- merge the global configuration for name, value in pairs(global.options()) do if config.get(name) == nil then config.set(name, value) @@ -299,7 +317,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- load platform instance local instance_plat = platform.load(plat, arch) - -- merge the checked configure + -- merge the checked configuration local recheck = _need_check(options_changed or not configcache_loaded or autogen) if recheck then @@ -364,6 +382,11 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) config.dump() end + -- export configs + if option.get("export") then + _export_configs() + end + -- save options and config cache localcache.set("config", "recheck", false) localcache.set("config", "mtimes", project.mtimes()) |
