8000 depend-info in manifest mode · Issue #36520 · microsoft/vcpkg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

depend-info in manifest mode #36520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Taha-cmd opened this issue Feb 1, 2024 · 18 comments
Open

depend-info in manifest mode #36520

Taha-cmd opened this issue Feb 1, 2024 · 18 comments
Assignees
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Comments

@Taha-cmd
Copy link
Taha-cmd commented Feb 1, 2024

Is your feature request related to a problem? Please describe.

I want to query the dependency graph for an entire project. The current depend-info command only works in classic mode, in which the dependencies are shown for only one port. To query the dependencies for an entire project, one would have to parse the vcpkg.json manifest and call depend-info for each port.

Proposed solution

Provide an (explicit or implicit) manifest mode for the depend-info command.
Examples:

  • vcpkg depend-info <- search for vcpkg.json in current directory
  • vcpkg depend-info vcpkg.json

Describe alternatives you've considered

No response

Additional context

No response

@Taha-cmd Taha-cmd added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Feb 1, 2024
@jimwang118 jimwang118 added category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed and removed category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist labels Feb 2, 2024
@jimwang118
Copy link
Contributor

You can create a new folder newdir in the vcpkg/port directory, and then copy your project's vcpkg.json to the new folder. Then run the following command to get all dependencies.
./vcpkg depend-info newdir --format=tree

@Taha-cmd
Copy link
Author
Taha-cmd commented Feb 6, 2024

That worked indeed. However, this is not really appropriate for automated build processes and pipelines scenario, as it would require modifying the vcpkg installation directory.

@jimwang118
Copy link
Contributor

That worked indeed. However, this is not really appropriate for automated build processes and pipelines scenario, as it would require modifying the vcpkg installation directory.

Yes, this is just a temporary solution, I will try to modify to read the vcpkg.json file directly to show the dependencies.

@dg0yt
Copy link
Contributor
dg0yt commented Feb 6, 2024

As a mitigation, you can try vcpkg install --dry-run.

@horenmar
Copy link
Contributor

I'll note two things here

  • The simplest way of hacking around the current limitation is an overlay port: vcpkg depend-info my-app --overlay-ports=.
  • The information returned from the trick above can be wrong, because the versions it selects are not done according to the manifest, nor is it a simple checkout of the registries (we have a private vcpkg registry).

@bmanga
Copy link
bmanga commented May 22, 2024

Any progress on this? I would also be interested in this functionality

@sharadhr
Copy link
Contributor

+1. This is very useful and I hope it is implemented. It makes no sense that depend-info works for packages but not for the top-level vcpkg.json; the logic is already present and it is a matter of wiring together the appropriate command-line.

@j-hap
Copy link
j-hap commented Jun 20, 2024

Currently the only way to install a specific package version is via manifest mode. There is no way to define a package version on the classic command line install. There is none for depend-info either. To to see the dependencies of a specific package version, would be nice if depend-info either works with the manifest file or if there was a way to specify the package version on the command line.

@jimwang118
Copy link
Contributor

@BillyONeal Can vcpkg query dependent packages in manifest mode?

@dg0yt
Copy link
Contributor
dg0yt commented Jun 23, 2024

To to see the dependencies of a specific package version, would be nice if depend-info either works with the manifest file

What works is #36520 (comment).

@jimwang118
Copy link
Contributor

Use the command vcpkg install --dry-run to achieve the results you need. I will close this issue. If you have new issue, please submit a new issue.

@dg0yt
Copy link
Contributor
dg0yt commented Aug 1, 2024

Please reopen.

@jimwang118 jimwang118 reopened this Aug 1, 2024
@Samt43
Copy link
Samt43 commented Nov 7, 2024

vcpkg install --dry-run does NOT permit to have parent/children relationship. This feature is needed.
All good package manager permit to do this.

@trifonov-borislav
Copy link

vcpkg install --dry-run does NOT permit to have parent/children relationship. This feature is needed. All good package manager permit to do this.

Adding my vote for this

@reitowo
Copy link
Contributor
reitowo commented Mar 27, 2025

Want this.

@mheyman
Copy link
Contributor
mheyman commented Apr 4, 2025

With the help of jq, you can run vcpkg depend-info on a local vcpkg.json. The jq command parses the dependencies from the vcpkg.json file and formats them in a way that makes vcpkg depend-info happy. Subtleties include feature parsing and only putting in square brackets when there actually are features.

The following is in the order of ugliest to least ugly 😉 ...

Replace the /path/to/vcpkg and YOUR-VCPKG-... values with what makes sense in your environment.

Windows Cmd

In do a winget install jqlang.jq to get jq then you can run a cmd shell line that looks like:

for /f "tokens=*" %a in ('jq -r "if .dependencies then [ .dependencies[] | if type==""string"" then . else ( .name + ( if ((.features // []) | length) > 0 then (""["" + (((.features // []) | join("",""))) + ""]"") else """" end ) ) end ] | join("" "") else empty end" vcpkg.json') do \path\to\vcpkg depend-info --overlay-ports YOUR-VCPKG-OVERLAY-PORTS --vcpkg-root YOUR-VCPKG-ROOT --format tree %a

You need to make it %%a instead of %a if you put this in a batch file.

Windows Powershell

Using jq (get it like above):

\path\to\vcpkg depend-info --overlay-ports YOUR-VCPKG-OVERLAY-PORTS --vcpkg-root YOUR-VCPKG-ROOT --format tree $(-split $(jq -r "if .dependencies then [ .dependencies[] | if type==\`"string\`" then . else ( .name + ( if ((.features // []) | length) > 0 then (\`"[\`" + (((.features // []) | join(\`",\`"))) + \`"]\`") else \`"\`" end ) ) end ] | join(\`" \`") else empty end" vcpkg.json))

Powershell's subexpressions produce one parameter so the -split is required to get multiple parameters passed into vcpkg depend-info.

or as @sharadhr pointed out, no jq required:

\path\to\vcpkg depend-info --overlay-ports YOUR-VCPKG-OVERLAY-PORTS --vcpkg-root YOUR-VCPKG-ROOT --format tree $(Get-Content -Raw vcpkg.json | ConvertFrom-Json | ForEach-Object { @($_.dependencies) | ForEach-Object { switch ($_) { { $_ -is [string] } { $_ } { $_.features -and $_.features.Count -gt 0 } { "$($_.name)[$($_.features -join ',')]" } default { $_.name } } } })

Linux Bash

You get jq from your package manager (like sudo apt install jq on Ubuntu, etc...)

/path/to/vcpkg depend-info --overlay-ports YOUR-VCPKG-OVERLAY-PORTS --vcpkg-root YOUR-VCPKG-ROOT --format tree  $(jq -r 'if .dependencies then [ .dependencies[] | if type=="string" then . else ( .name + ( if ((.features // []) | length) > 0 then ("[" + (((.features // []) | join(","))) + "]") else "" end ) ) end ] | join(" ") else empty end' vcpkg.json)

@sharadhr
Copy link
Contributor
sharadhr commented Apr 4, 2025

On Windows, no need for a batch file or jq. In PowerShell:

Get-Content -Raw vcpkg.json | ConvertFrom-Json | ForEach-Object {
    @($_.dependencies) | ForEach-Object {
        switch ($_) {
            { $_ -is [string] } { $_ }
            { $_.features -and $_.features.Count -gt 0 } { "$($_.name)[$($_.features -join ',')]" }
            default { $_.name }
        }
    }
}

@JasonDictos
Copy link

Here's some updated jq snafu to take a vcpkg file and flatten it into a one liner for custom vcpkg invocations:

#!/bin/bash
set +e

if [[ -z "$1" ]]; then
  echo "usage parse_vcpkg.sh <path to vcpkg.json>"
  exit 1
fi

JQ_QUERY='."dependencies"[] | ( if type == "object" then .name + "[" + (.features | join(",") + "]") e

readarray -t DEPS < <(cat $1 | jq -r "$JQ_QUERY" 2> /dev/nul
6F3C
l)
vcpkg install "${DEPS[@]/ -/}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
Projects
None yet
Development

No branches or pull requests

0