diff options
| author | ruki <[email protected]> | 2024-01-22 23:40:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-25 12:09:58 +0800 |
| commit | ad109d0818b38889e703a038514a3acb0d90cdd7 (patch) | |
| tree | b3a8b4d6aa7b798f82cba1b6298e3599745750c8 | |
| parent | 9f76e77a010c835f17a8a4ed65254df84e38d7e7 (diff) | |
rename vs_runtime to runtimes in package configs
| -rw-r--r-- | tests/projects/package/depconfigs/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/package/manager/conan/v1/install_package.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/manager/conan/v2/install_package.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/package/manager/vcpkg/configurations.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 39 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/xrepo.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/export.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/fetch.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/import.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/info.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/install.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/remove.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 32 |
15 files changed, 62 insertions, 52 deletions
diff --git a/tests/projects/package/depconfigs/xmake.lua b/tests/projects/package/depconfigs/xmake.lua index 377c8899b..11623755c 100644 --- a/tests/projects/package/depconfigs/xmake.lua +++ b/tests/projects/package/depconfigs/xmake.lua @@ -1,5 +1,5 @@ -add_requires("libpng", {system = false, configs = {vs_runtime = "MD"}}) -add_requires("libtiff", {system = false, configs = {vs_runtime = "MD", zlib = true}}) +add_requires("libpng", {system = false, configs = {runtimes = "MD"}}) +add_requires("libtiff", {system = false, configs = {runtimes = "MD", zlib = true}}) add_requireconfs("libpng.zlib", {system = false, override = true, configs = {cxflags = "-DTEST1"}, version = "1.2.10"}) add_requireconfs("libtiff.*|cmake", {system = false, configs = {cxflags = "-DTEST2"}}) diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 3d23c0998..15ef721d0 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -170,15 +170,15 @@ function nf_optimize(self, level) end -- make vs runtime flag -function nf_runtime(self, vs_runtime) - if self:is_plat("windows") and vs_runtime then +function nf_runtime(self, runtime) + if self:is_plat("windows") and runtime then local maps = { MT = '-Xcompiler "-MT"', MD = '-Xcompiler "-MD"', MTd = '-Xcompiler "-MTd"', MDd = '-Xcompiler "-MDd"' } - return maps[vs_runtime] + return maps[runtime] end end diff --git a/xmake/modules/package/manager/conan/v1/install_package.lua b/xmake/modules/package/manager/conan/v1/install_package.lua index e443e585b..3475a21b3 100644 --- a/xmake/modules/package/manager/conan/v1/install_package.lua +++ b/xmake/modules/package/manager/conan/v1/install_package.lua @@ -211,9 +211,9 @@ function main(conan, name, opt) table.insert(argv, "compiler=Visual Studio") table.insert(argv, "-s") table.insert(argv, "compiler.version=" .. assert(vsvers[vs], "unknown msvc version!")) - if configs.vs_runtime then + if configs.runtimes then table.insert(argv, "-s") - table.insert(argv, "compiler.runtime=" .. configs.vs_runtime) + table.insert(argv, "compiler.runtime=" .. configs.runtimes) end elseif opt.plat == "iphoneos" then local target_minver = nil diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index eb4299d83..bf561124e 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -182,10 +182,10 @@ function _conan_generate_compiler_profile(profile, configs, opt) if tonumber(vs) >= 2015 then profile:print("compiler.cppstd=14") end - local vs_runtime = configs.vs_runtime - if vs_runtime then - profile:print("compiler.runtime=" .. (vs_runtime:startswith("MD") and "dynamic" or "static")) - profile:print("compiler.runtime_type=" .. (vs_runtime:endswith("d") and "Debug" or "Release")) + local runtimes = configs.runtimes + if runtimes then + profile:print("compiler.runtime=" .. (runtimes:startswith("MD") and "dynamic" or "static")) + profile:print("compiler.runtime_type=" .. (runtimes:endswith("d") and "Debug" or "Release")) end elseif plat == "iphoneos" then local target_minver = nil diff --git a/xmake/modules/package/manager/vcpkg/configurations.lua b/xmake/modules/package/manager/vcpkg/configurations.lua index 997f8fa35..cb81e560a 100644 --- a/xmake/modules/package/manager/vcpkg/configurations.lua +++ b/xmake/modules/package/manager/vcpkg/configurations.lua @@ -52,7 +52,7 @@ function triplet(configs, plat, arch) local triplet = arch .. "-" .. plat if plat == "windows" and configs.shared ~= true then triplet = triplet .. "-static" - if configs.vs_runtime and configs.vs_runtime:startswith("MD") then + if configs.runtimes and configs.runtimes:startswith("MD") then triplet = triplet .. "-md" end elseif plat == "mingw" then diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 8bbeeee45..7a9d89bf8 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -152,6 +152,13 @@ function _load_require(require_str, requires_extra, parentinfo) require_build_configs.debug = true end + -- vs_runtime is deprecated, we should use runtimes + if require_build_configs and require_build_configs.vs_runtime then + require_build_configs.runtimes = require_build_configs.vs_runtime + require_build_configs.vs_runtime = nil + wprint("add_requires(%s): vs_runtime is deprecated, please use runtimes!", require_str) + end + -- require packge in the current host platform if require_extra.host then if is_subhost(core_package.targetplat()) and os.subarch() == core_package.targetarch() then @@ -346,8 +353,10 @@ function _add_package_configurations(package) if package:extraconf("configs", "asan", "default") == nil then package:add("configs", "asan", {builtin = true, description = "Enable the address sanitizer.", type = "boolean"}) end - if package:extraconf("configs", "vs_runtime", "default") == nil then - package:add("configs", "vs_runtime", {builtin = true, description = "Set vs compiler runtime.", values = {"MT", "MTd", "MD", "MDd"}}) + if package:extraconf("configs", "runtimes", "default") == nil then + package:add("configs", "runtimes", {builtin = true, description = "Set the compiler runtimes.", values = { + "MT", "MTd", "MD", "MDd", + "c++_static", "c++_shared", "stdc++_static", "stdc++_shared"}}) end if package:extraconf("configs", "toolchains", "default") == nil then package:add("configs", "toolchains", {builtin = true, description = "Set package toolchains only for cross-compilation."}) @@ -513,9 +522,9 @@ function _init_requireinfo(requireinfo, package, opt) requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain") end end - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") + requireinfo.configs.runtimes = requireinfo.configs.runtimes or project.get("target.runtimes") if project.policy("package.inherit_external_configs") then - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime") + requireinfo.configs.runtimes = requireinfo.configs.runtimes or get_config("runtimes") or get_config("vs_runtime") end if requireinfo.configs.lto == nil then requireinfo.configs.lto = project.policy("build.optimization.lto") @@ -527,7 +536,7 @@ function _init_requireinfo(requireinfo, package, opt) -- but we will ignore some configs for buildhash in the headeronly and host/binary package -- @note on_test still need these configs, @see https://github.com/xmake-io/xmake/issues/4124 if package:is_headeronly() or (package:is_binary() and not package:is_cross()) then - requireinfo.ignored_configs_for_buildhash = {"vs_runtime", "toolchains", "lto", "asan", "pic"} + requireinfo.ignored_configs_for_buildhash = {"runtimes", "toolchains", "lto", "asan", "pic"} end end @@ -542,8 +551,8 @@ function _finish_requireinfo(requireinfo, package) end requireinfo.configs = requireinfo.configs or {} if not package:is_headeronly() then - if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then - requireinfo.configs.vs_runtime = "MT" + if requireinfo.configs.runtimes == nil and package:is_plat("windows") then + requireinfo.configs.runtimes = "MT" end end -- we need to ensure readonly configs @@ -568,9 +577,9 @@ end -- merge requireinfo from `add_requireconfs()` -- --- add_requireconfs("*", {system = false, configs = {vs_runtime = "MD"}}) --- add_requireconfs("lib*", {system = false, configs = {vs_runtime = "MD"}}) --- add_requireconfs("libwebp", {system = false, configs = {vs_runtime = "MD"}}) +-- add_requireconfs("*", {system = false, configs = {runtimes = "MD"}}) +-- add_requireconfs("lib*", {system = false, configs = {runtimes = "MD"}}) +-- add_requireconfs("libwebp", {system = false, configs = {runtimes = "MD"}}) -- add_requireconfs("libpng.zlib", {system = false, override = true, configs = {cxflags = "-DTEST1"}, version = "1.2.10"}) -- add_requireconfs("libtiff.*", {system = false, configs = {cxflags = "-DTEST2"}}) -- add_requireconfs("libwebp.**|cmake|autoconf", {system = false, configs = {cxflags = "-DTEST3"}}) -- recursive deps @@ -660,15 +669,15 @@ function _get_packagelock_key(requireinfo) end -- inherit some builtin configs of parent package if these config values are not default value --- e.g. add_requires("libpng", {configs = {vs_runtime = "MD", pic = false}}) +-- e.g. add_requires("libpng", {configs = {runtimes = "MD", pic = false}}) -- function _inherit_parent_configs(requireinfo, package, parentinfo) if package:is_library() then local requireinfo_configs = requireinfo.configs or {} local parentinfo_configs = parentinfo.configs or {} if not requireinfo_configs.shared then - if requireinfo_configs.vs_runtime == nil then - requireinfo_configs.vs_runtime = parentinfo_configs.vs_runtime + if requireinfo_configs.runtimes == nil then + requireinfo_configs.runtimes = parentinfo_configs.runtimes end if requireinfo_configs.pic == nil then requireinfo_configs.pic = parentinfo_configs.pic @@ -681,7 +690,7 @@ function _inherit_parent_configs(requireinfo, package, parentinfo) requireinfo.arch = parentinfo.arch end requireinfo_configs.toolchains = requireinfo_configs.toolchains or parentinfo_configs.toolchains - requireinfo_configs.vs_runtime = requireinfo_configs.vs_runtime or parentinfo_configs.vs_runtime + requireinfo_configs.runtimes = requireinfo_configs.runtimes or parentinfo_configs.runtimes requireinfo_configs.lto = requireinfo_configs.lto or parentinfo_configs.lto requireinfo_configs.asan = requireinfo_configs.asan or parentinfo_configs.asan requireinfo.configs = requireinfo_configs @@ -838,7 +847,7 @@ function _load_package(packagename, requireinfo, opt) -- merge requireinfo from `add_requireconfs()` _merge_requireinfo(requireinfo, opt.requirepath) - -- inherit some builtin configs of parent package, e.g. vs_runtime, pic + -- inherit some builtin configs of parent package, e.g. runtimes, pic if opt.parentinfo then _inherit_parent_configs(requireinfo, package, opt.parentinfo) end diff --git a/xmake/modules/private/action/trybuild/xrepo.lua b/xmake/modules/private/action/trybuild/xrepo.lua index cfb63e553..31d866d58 100644 --- a/xmake/modules/private/action/trybuild/xrepo.lua +++ b/xmake/modules/private/action/trybuild/xrepo.lua @@ -111,9 +111,10 @@ function _get_common_configs(argv) if config.get("toolchain") then table.insert(argv, "--toolchain=" .. config.get("toolchain")) end - if config.get("vs_runtime") then + local runtimes = config.get("runtimes") or config.get("vs_runtime") + if runtimes then table.insert(argv, "-f") - table.insert(argv, "vs_runtime='" .. config.get("vs_runtime") .. "'") + table.insert(argv, "runtimes='" .. runtimes .. "'") end end diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index 5a9347922..b2e421f24 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -49,7 +49,7 @@ function menu_options() {nil, "show", "k", nil, "Only show environment information." }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo env -f \"vs_runtime='MD'\" zlib cmake ..", + " - xrepo env -f \"runtimes='MD'\" zlib cmake ..", " - xrepo env -f \"regex=true,thread=true\" \"zlib,boost\" cmake .."}, {nil, "add", "k", nil, "Add global environment config.", "e.g.", diff --git a/xmake/modules/private/xrepo/action/export.lua b/xmake/modules/private/xrepo/action/export.lua index 551d978a3..4c718bcb0 100644 --- a/xmake/modules/private/xrepo/action/export.lua +++ b/xmake/modules/private/xrepo/action/export.lua @@ -39,7 +39,7 @@ function menu_options() values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo export -f \"vs_runtime='MD'\" zlib", + " - xrepo export -f \"runtimes='MD'\" zlib", " - xrepo export -f \"regex=true,thread=true\" boost"}, {}, {nil, "includes", "kv", nil, "Includes extra lua configuration files."}, diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua index b54294a68..4455d21e7 100644 --- a/xmake/modules/private/xrepo/action/fetch.lua +++ b/xmake/modules/private/xrepo/action/fetch.lua @@ -38,7 +38,7 @@ function menu_options() values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo fetch --configs=\"vs_runtime='MD'\" zlib", + " - xrepo fetch --configs=\"runtimes='MD'\" zlib", " - xrepo fetch --configs=\"regex=true,thread=true\" boost"}, {nil, "system", "k", "false", "Only fetch package on current system."}, {}, diff --git a/xmake/modules/private/xrepo/action/import.lua b/xmake/modules/private/xrepo/action/import.lua index 8c32e2c0f..7ad0a1759 100644 --- a/xmake/modules/private/xrepo/action/import.lua +++ b/xmake/modules/private/xrepo/action/import.lua @@ -39,7 +39,7 @@ function menu_options() values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo import -f \"vs_runtime='MD'\" zlib", + " - xrepo import -f \"runtimes='MD'\" zlib", " - xrepo import -f \"regex=true,thread=true\" boost"}, {}, {'i', "packagedir", "kv", "packages","Set the imported packages directory."}, diff --git a/xmake/modules/private/xrepo/action/info.lua b/xmake/modules/private/xrepo/action/info.lua index 3bc547b94..e89ac80af 100644 --- a/xmake/modules/private/xrepo/action/info.lua +++ b/xmake/modules/private/xrepo/action/info.lua @@ -38,7 +38,7 @@ function menu_options() values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo fetch --configs=\"vs_runtime='MD'\" zlib", + " - xrepo fetch --configs=\"runtimes='MD'\" zlib", " - xrepo fetch --configs=\"regex=true,thread=true\" boost"}, {}, {nil, "packages", "vs", nil, "The packages list.", diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua index dfcaadf80..81420f51f 100644 --- a/xmake/modules/private/xrepo/action/install.lua +++ b/xmake/modules/private/xrepo/action/install.lua @@ -38,7 +38,7 @@ function menu_options() values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo install -f \"vs_runtime='MD'\" zlib", + " - xrepo install -f \"runtimes='MD'\" zlib", " - xrepo install -f \"regex=true,thread=true\" boost"}, {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs."}, diff --git a/xmake/modules/private/xrepo/action/remove.lua b/xmake/modules/private/xrepo/action/remove.lua index dd850deb6..38be707fb 100644 --- a/xmake/modules/private/xrepo/action/remove.lua +++ b/xmake/modules/private/xrepo/action/remove.lua @@ -39,7 +39,7 @@ function menu_options() values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", - " - xrepo remove -f \"vs_runtime='MD'\" zlib", + " - xrepo remove -f \"runtimes='MD'\" zlib", " - xrepo remove -f \"regex=true,thread=true\" boost"}, {nil, "toolchain", "kv", nil, "Set the toolchain name." }, {}, diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index ddef34471..6fcf38313 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -753,31 +753,31 @@ function _add_target_symbols(cmakelists, target) end end --- add target vs runtime +-- add target runtimes -- -- https://github.com/xmake-io/xmake/issues/1661#issuecomment-927979489 -- https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html -- -function _add_target_vs_runtime(cmakelists, target) +function _add_target_runtimes(cmakelists, target) local cmake_minver = _get_cmake_minver() if cmake_minver:ge("3.15.0") then - local vs_runtime = target:get("runtimes") + local runtimes = target:get("runtimes") cmakelists:print("if(MSVC)") - if vs_runtime then - if vs_runtime == "MT" then - vs_runtime = "MultiThreaded" - elseif vs_runtime == "MTd" then - vs_runtime = "MultiThreadedDebug" - elseif vs_runtime == "MD" then - vs_runtime = "MultiThreadedDLL" - elseif vs_runtime == "MDd" then - vs_runtime = "MultiThreadedDebugDLL" + if runtimes then + if runtimes == "MT" then + runtimes = "MultiThreaded" + elseif runtimes == "MTd" then + runtimes = "MultiThreadedDebug" + elseif runtimes == "MD" then + runtimes = "MultiThreadedDLL" + elseif runtimes == "MDd" then + runtimes = "MultiThreadedDebugDLL" end else - vs_runtime = "MultiThreaded$<$<CONFIG:Debug>:Debug>" + runtimes = "MultiThreaded$<$<CONFIG:Debug>:Debug>" end cmakelists:print(' set_property(TARGET %s PROPERTY', target:name()) - cmakelists:print(' MSVC_RUNTIME_LIBRARY "%s")', vs_runtime) + cmakelists:print(' MSVC_RUNTIME_LIBRARY "%s")', runtimes) cmakelists:print("endif()") end end @@ -1047,8 +1047,8 @@ function _add_target(cmakelists, target, outputdir) -- add target symbols _add_target_symbols(cmakelists, target) - -- add vs runtime for msvc - _add_target_vs_runtime(cmakelists, target) + -- add target runtimes + _add_target_runtimes(cmakelists, target) -- add target link libraries _add_target_link_libraries(cmakelists, target, outputdir) |
