diff options
| author | ruki <[email protected]> | 2025-11-12 12:03:45 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-12 12:03:45 +0800 |
| commit | 14493739113bfb4b38f5c93a530a1d8a5bea5ef0 (patch) | |
| tree | 1d82264392eee5dc03dfa07bbcf80a224f8f6a7f /xmake/plugins | |
| parent | 1122e6fe0f3c8724cef76b7b48c1f27d4257916a (diff) | |
| parent | a2bd19bd10182105ac020c1654f241551feec5b3 (diff) | |
Merge pull request #7016 from xmake-io/vsxmake
fix project default config in vsxmake #7014
Diffstat (limited to 'xmake/plugins')
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 21 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vsutils.lua | 38 | ||||
| -rw-r--r-- | xmake/plugins/project/vsxmake/getinfo.lua | 22 |
3 files changed, 42 insertions, 39 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index bc31acbbe..35bece8b3 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -400,25 +400,8 @@ function make(outputdir, vsinfo) -- reload config, project and platform if mode ~= config.mode() or arch ~= config.arch() then - -- modify config - config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64 - config.set("mode", mode, {readonly = true, force = true}) - config.set("arch", arch, {readonly = true, force = true}) - - -- clear all options - for _, opt in pairs(project.options()) do - if not config.readonly(opt:fullname()) then - opt:clear() - end - end - - -- clear cache - memcache.clear() - localcache.clear("detect") - localcache.clear("option") - localcache.clear("package") - localcache.clear("toolchain") - localcache.clear("cxxmodules") + -- reset project configs and caches + vsutils.reset_config_and_caches() -- check platform platform.load(config.plat(), arch):check() diff --git a/xmake/plugins/project/vstudio/impl/vsutils.lua b/xmake/plugins/project/vstudio/impl/vsutils.lua index fa78be0f7..c931b7b5b 100644 --- a/xmake/plugins/project/vstudio/impl/vsutils.lua +++ b/xmake/plugins/project/vstudio/impl/vsutils.lua @@ -18,6 +18,13 @@ -- @file vsutils.lua -- +-- imports +import("core.base.option") +import("core.project.config") +import("core.project.project") +import("core.cache.memcache") +import("core.cache.localcache") + -- escape special chars in msbuild file function escape(str) if not str then @@ -56,3 +63,34 @@ end function translate_path(filepath) return (filepath:gsub("::", "#")) end + +function reset_config_and_caches() + -- reload config, project and platform + -- modify config + config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64 + config.set("mode", mode, {readonly = true, force = true}) + config.set("arch", arch, {readonly = true, force = true}) + + -- clear all options + for _, opt in pairs(project.options()) do + if not config.readonly(opt:fullname()) then + opt:clear() + end + end + -- merge the project options after default options + for name, value in pairs(project.get("config")) do + value = table.unwrap(value) + assert(type(value) == "string" or type(value) == "boolean" or type(value) == "number", "set_config(%s): unsupported value type(%s)", name, type(value)) + if not config.readonly(name) then + config.set(name, value) + end + end + + -- clear cache + memcache.clear() + localcache.clear("detect") + localcache.clear("option") + localcache.clear("package") + localcache.clear("toolchain") + localcache.clear("cxxmodules") +end diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 67bc8c968..0258bc28b 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -449,26 +449,8 @@ function main(outputdir, vsinfo) -- trace print("checking for %s.%s ...", mode, arch) - -- reload config, project and platform - -- modify config - config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64 - config.set("mode", mode, {readonly = true, force = true}) - config.set("arch", arch, {readonly = true, force = true}) - - -- clear all options - for _, opt in pairs(project.options()) do - if not config.readonly(opt:fullname()) then - opt:clear() - end - end - - -- clear cache - memcache.clear() - localcache.clear("detect") - localcache.clear("option") - localcache.clear("package") - localcache.clear("toolchain") - localcache.clear("cxxmodules") + -- reset project configs and caches + vsutils.reset_config_and_caches() -- check platform platform.load(config.plat(), arch):check() |
