diff options
| author | kanren3 <[email protected]> | 2026-03-19 21:58:47 +0800 |
|---|---|---|
| committer | kanren3 <[email protected]> | 2026-03-20 14:41:33 +0800 |
| commit | c7be1fac279fce8e0b5b02576d33f23f7cd73215 (patch) | |
| tree | 2c88d7c744cef056ac7fa02f56113072f7ab8219 | |
| parent | 101c700f7b5339ea4850a928e354471e9e9c0d8f (diff) | |
Move need_manifest to utils and fix install_package.lua.
| -rw-r--r-- | xmake/modules/package/manager/vcpkg/find_package.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/package/manager/vcpkg/install_package.lua | 18 | ||||
| -rw-r--r-- | xmake/modules/package/manager/vcpkg/utils.lua | 22 |
3 files changed, 22 insertions, 34 deletions
diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua index ab65cf21d..c36ba37f9 100644 --- a/xmake/modules/package/manager/vcpkg/find_package.lua +++ b/xmake/modules/package/manager/vcpkg/find_package.lua @@ -29,18 +29,6 @@ import("package.manager.vcpkg.configurations") import("package.manager.vcpkg.utils", {alias = "vcpkg_utils"}) import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"}) --- need manifest mode? -function _need_manifest(opt) - local require_version = opt.require_version - if require_version ~= nil and require_version ~= "latest" then - return true - end - local configs = opt.configs - if configs and (configs.features or configs.default_features == false or configs.baseline) then - return true - end -end - -- extract required features from both package name and configs.features. local function _required_features(name, configs) local features = {} @@ -174,7 +162,7 @@ function _find_package(vcpkg, vcpkgdir, name, opt) local configs = opt.configs or {} -- is need manifest mode? - local manifest_mode = _need_manifest(opt) + local manifest_mode = vcpkg_utils.need_manifest(opt) -- manifest mode requires installdir to run vcpkg commands in the context of the manifest if manifest_mode and not opt.installdir then @@ -212,7 +200,7 @@ function _find_package(vcpkg, vcpkgdir, name, opt) -- check that required features are installed -- @see https://github.com/xmake-io/xmake/issues/7388 - if required_features and not vcpkg_utils.has_installed_features(vcpkg, name, triplet, required_features, manifest_mode, opt) then + if required_features and not vcpkg_utils.has_installed_features(vcpkg, name, triplet, required_features, opt) then return end diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua index 2c2c520f3..a8546e5d0 100644 --- a/xmake/modules/package/manager/vcpkg/install_package.lua +++ b/xmake/modules/package/manager/vcpkg/install_package.lua @@ -26,18 +26,6 @@ import("lib.detect.find_tool") import("package.manager.vcpkg.configurations") import("package.manager.vcpkg.utils", {alias = "vcpkg_utils"}) --- need manifest mode? -function _need_manifest(opt) - local require_version = opt.require_version - if require_version ~= nil and require_version ~= "latest" then - return true - end - local configs = opt.configs - if configs and (configs.features or configs.default_features == false or configs.baseline) then - return true - end -end - -- install for classic mode function _install_for_classic(vcpkg, name, opt) @@ -62,8 +50,8 @@ function _install_for_classic(vcpkg, name, opt) -- @see https://github.com/xmake-io/xmake/issues/7388 local basename = name:gsub("%[.-%]", "") if basename ~= name then - if not vcpkg_utils.is_installed(vcpkg, name, triplet) then - if vcpkg_utils.is_installed(vcpkg, basename, triplet) then + if not vcpkg_utils.is_installed(vcpkg, name, triplet, opt) then + if vcpkg_utils.is_installed(vcpkg, basename, triplet, opt) then local confirm = utils.confirm({default = true, description = format("%s:%s is already installed (possibly with different features). Installing %s will require a rebuild of it and its dependencies. Continue?", basename, triplet, name)}) if confirm then @@ -168,7 +156,7 @@ function main(name, opt) -- do install opt = opt or {} - if _need_manifest(opt) then + if vcpkg_utils.need_manifest(opt) then _install_for_manifest(vcpkg.program, name, opt) else _install_for_classic(vcpkg.program, name, opt) diff --git a/xmake/modules/package/manager/vcpkg/utils.lua b/xmake/modules/package/manager/vcpkg/utils.lua index 7829a311e..fdd85d501 100644 --- a/xmake/modules/package/manager/vcpkg/utils.lua +++ b/xmake/modules/package/manager/vcpkg/utils.lua @@ -19,14 +19,26 @@ -- -- check if a package (with optional features) is installed for the given triplet --- e.g. is_installed(vcpkg, "curl", "x64-windows-static-md") --- is_installed(vcpkg, "curl[mbedtls]", "x64-windows-static-md") +-- e.g. is_installed(vcpkg, "curl", "x64-windows-static-md", opt) +-- is_installed(vcpkg, "curl[mbedtls]", "x64-windows-static-md", opt) -- -- @see https://github.com/xmake-io/xmake/issues/7388 -- -function is_installed(vcpkg, name, triplet, manifest_mode, opt) +function need_manifest(opt) + local require_version = opt.require_version + if require_version ~= nil and require_version ~= "latest" then + return true + end + local configs = opt.configs + if configs and (configs.features or configs.default_features == false or configs.baseline) then + return true + end +end + +function is_installed(vcpkg, name, triplet, opt) local argv = {"list", name .. ":" .. triplet, "--x-full-desc"} + local manifest_mode = need_manifest(opt) -- pass feature flags to depend-info when in manifest mode, otherwise depend-info will not show the complete dependency tree with features if manifest_mode then @@ -53,9 +65,9 @@ end -- -- @see https://github.com/xmake-io/xmake/issues/7388 -- -function has_installed_features(vcpkg, name, triplet, required_features, manifest_mode, opt) +function has_installed_features(vcpkg, name, triplet, required_features, opt) for _, feature in ipairs(required_features) do - if not is_installed(vcpkg, name .. "[" .. feature .. "]", triplet, manifest_mode, opt) then + if not is_installed(vcpkg, name .. "[" .. feature .. "]", triplet, opt) then return false end end |
