diff options
| author | ruki <[email protected]> | 2026-07-27 15:58:21 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-27 15:58:21 +0800 |
| commit | e440a9168b0d2c3151daa8ab0db4bf4e44ff70ba (patch) | |
| tree | 2f0dec9766b10408050d5262a4071305c1b0b851 /xmake/modules/package/manager/vcpkg/utils.lua | |
| parent | ddfd397d81a4283a74425f2418e1337cc2e04037 (diff) | |
| parent | 451a46e86a2651ffb326870b07cc27952fbe6505 (diff) | |
Merge pull request #7666 from xmake-io/vcpkg3
improve to find vcpkg packages
Diffstat (limited to 'xmake/modules/package/manager/vcpkg/utils.lua')
| -rw-r--r-- | xmake/modules/package/manager/vcpkg/utils.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/xmake/modules/package/manager/vcpkg/utils.lua b/xmake/modules/package/manager/vcpkg/utils.lua index fdd85d501..1c83323b4 100644 --- a/xmake/modules/package/manager/vcpkg/utils.lua +++ b/xmake/modules/package/manager/vcpkg/utils.lua @@ -36,6 +36,22 @@ function need_manifest(opt) end end +-- get a neutral empty directory to run classic-mode vcpkg commands in. +-- +-- vcpkg switches to manifest mode when a vcpkg.json exists in the current working directory, and +-- in manifest mode it rejects individual package arguments ("In manifest mode, `vcpkg install` +-- does not support individual package arguments"). so classic-mode commands (install/list/ +-- depend-info, which pass `<pkg>:<triplet>`) must not run from a project directory that ships its +-- own vcpkg.json. +-- @see https://github.com/xmake-io/xmake/issues/7660 +function classic_curdir() + local dir = path.join(os.tmpdir(), "vcpkg", "classic") + if not os.isdir(dir) then + os.mkdir(dir) + end + return dir +end + function is_installed(vcpkg, name, triplet, opt) local argv = {"list", name .. ":" .. triplet, "--x-full-desc"} local manifest_mode = need_manifest(opt) @@ -46,7 +62,7 @@ function is_installed(vcpkg, name, triplet, opt) end local listinfo = try { function () - return os.iorunv(vcpkg, argv, manifest_mode and {curdir = opt.installdir} or nil) + return os.iorunv(vcpkg, argv, {curdir = manifest_mode and opt.installdir or classic_curdir()}) end} if listinfo then local exact_prefix = name .. ":" .. triplet |
