diff options
| author | ruki <[email protected]> | 2026-03-13 22:41:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-13 22:41:51 +0800 |
| commit | d18d20def0ca10fda04bae01381e61895b970a43 (patch) | |
| tree | 7c3f0bad335e38152d4e9e58a7098f934b10b833 | |
| parent | c03f3c5fbb20377215ea4c1c7240b4fc3da7722f (diff) | |
improve install vcpkg package
| -rw-r--r-- | xmake/modules/package/manager/vcpkg/install_package.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua index e7c0fa930..c0db41d1b 100644 --- a/xmake/modules/package/manager/vcpkg/install_package.lua +++ b/xmake/modules/package/manager/vcpkg/install_package.lua @@ -22,6 +22,7 @@ import("core.base.option") import("core.base.json") import("core.base.semver") +import("core.base.utils") import("lib.detect.find_tool") import("package.manager.vcpkg.configurations") @@ -56,9 +57,24 @@ function _install_for_classic(vcpkg, name, opt) table.insert(argv, "--debug") end - -- allow rebuilding packages when features change + -- check if the base package is already installed with different features, + -- if so, prompt user before rebuilding with --recurse -- @see https://github.com/xmake-io/xmake/issues/7388 - table.insert(argv, "--recurse") + local basename = name:gsub("%[.-%]", "") + if basename ~= name then + local listinfo = try { function () + return os.iorunv(vcpkg, {"list", basename .. ":" .. triplet}) + end} + if listinfo and listinfo:trim() ~= "" then + local confirm = utils.confirm({default = true, + description = format("%s:%s is already installed with other features, installing %s will rebuild it and its dependencies, continue?", basename, triplet, name)}) + if confirm then + table.insert(argv, "--recurse") + else + raise("install %s:%s cancelled!", name, triplet) + end + end + end -- install package os.vrunv(vcpkg, argv) |
