Skip to content

Conversation

ras0219
Copy link
Contributor

@ras0219 ras0219 commented Aug 10, 2020

This PR lifts the --x-json switch from vcpkg list to an ambient flag; in the longer term, to support tooling around vcpkg we need to generally have an option for machine-parsable output.

This PR also implements another example of potentially supporting tooling: x-package-info. This command abstracts away CONTROL vs vcpkg.json, the status database, list files, and dependency trees.

Example 1: zlib has a CONTROL file, not a vcpkg.json

PS C:\src\vcpkg> ./vcpkg x-package-info --x-json zlib
{
  "results": {
    "zlib": {
      "name": "zlib",
      "version-string": "1.2.11",
      "port-version": 7,
      "description": "A compression library",
      "homepage": "https://www.zlib.net/"
    }
  }
}

Example 2: getting files owned by a package and (some) usage information

PS C:\src\vcpkg> ./vcpkg x-package-info --x-json zlib:x86-windows --x-installed
{
  "results": {
    "zlib:x86-windows": {
      "version-string": "1.2.11",
      "port-version": 7,
      "triplet": "x86-windows",
      "abi": "d9c4c982f4ec42210fef297e317168827fb73ca4",
      "usage": "The package zlib is compatible with built-in CMake targets:\r\n\r\n    find_package(ZLIB REQUIRED)\r\n    target_link_libraries(main PRIVATE ZLIB::ZLIB)\r\n\n",
      "owns": [
        "x86-windows/",
        "x86-windows/bin/",
        "x86-windows/bin/zlib.pdb",
        "x86-windows/bin/zlib1.dll",
...
        "x86-windows/share/zlib/usage",
        "x86-windows/share/zlib/vcpkg_abi_info.txt"
      ]
    }
  }
}

Example 3: transitive closure over installed packages

PS C:\src\vcpkg> ./vcpkg x-package-info --x-json openssl:arm64-windows --x-installed --x-transitive
{
  "results": {
    "openssl:arm64-windows": {
      "version-string": "1.1.1g",
      "port-version": 0,
      "triplet": "arm64-windows",
      "abi": "a50275670693cb68fd00e6c4c0e2c9e85a8ba30c",
      "dependencies": [
        "openssl-windows:arm64-windows"
      ],
      "usage": "The package openssl is compatible with built-in CMake targets:\r\n\r\n    find_package(OpenSSL REQUIRED)\r\n    target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)\r\n\n",
      "owns": [
        "arm64-windows/",
        "arm64-windows/share/",
        "arm64-windows/share/openssl/",
        "arm64-windows/share/openssl/usage",
        "arm64-windows/share/openssl/vcpkg_abi_info.txt"
      ]
    },
    "openssl-windows:arm64-windows": {
      "version-string": "1.1.1g",
      "port-version": 0,
      "triplet": "arm64-windows",
      "abi": "7dedc997aea0d1396d6113397e56de1f44040322",
      "usage": "The package openssl is compatible with built-in CMake targets:\r\n\r\n    find_package(OpenSSL REQUIRED)\r\n    target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)\r\n\n",
      "owns": [
        "arm64-windows/",
        "arm64-windows/bin/",
        "arm64-windows/bin/c_rehash.pl",
        "arm64-windows/bin/libcrypto-1_1-arm64.dll",
        "arm64-windows/bin/libcrypto-1_1-arm64.pdb",
...
        "arm64-windows/tools/openssl/",
        "arm64-windows/tools/openssl/libcrypto-1_1-arm64.dll",
        "arm64-windows/tools/openssl/libssl-1_1-arm64.dll",
        "arm64-windows/tools/openssl/openssl.cnf",
        "arm64-windows/tools/openssl/openssl.exe"
      ]
    }
  }
}

The consumer (say, some custom buildsystem) can then iterate over all the results and not worry about whether openssl directly owns libcrypto-1_1-arm64.dll or whether it is actually provided by some transitive package.

@JackBoosY JackBoosY added category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal labels Aug 11, 2020
@petersteneteg
Copy link
Contributor

This is great! I've been looking for this feature in the help for some time!
A suggestion, would it be possible to also include licence/copyright information/file in the json? I guess one can look for a copyright file(s) among the list of owned files. but having it explicit would be even better. The reason being that I need to be able to retrieve all the copyright files for my about dialog.

@ras0219-msft
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ras0219
Copy link
Contributor Author

ras0219 commented Aug 14, 2020

@petersteneteg We require that for every port, it puts a file at /share/<port>/copyright; ports may optionally also have copyright information in the manifest section (SPDX). For your purposes, I think just picking up the copyright files is the best approach.

remz1337 pushed a commit to remz1337/vcpkg that referenced this pull request Aug 23, 2020
…-package-info` command (microsoft#12845)

* [vcpkg] Improve error reporting in vcpkg::Json

* [vcpkg] Lift --x-json to a common option

* [vcpkg] Address warnings-as-errors in VS2015

* [vcpkg] Remove unused local

* [vcpkg] Extract vcpkg::Install::get_cmake_usage

* [vcpkg] Implement vcpkg::serialize_ipv(ipv, paths)

* [vcpkg] Implement x-package-info to enable tooling

* [vcpkg] Fixup tests to respect new cli mode

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
…-package-info` command (microsoft#12845)

* [vcpkg] Improve error reporting in vcpkg::Json

* [vcpkg] Lift --x-json to a common option

* [vcpkg] Address warnings-as-errors in VS2015

* [vcpkg] Remove unused local

* [vcpkg] Extract vcpkg::Install::get_cmake_usage

* [vcpkg] Implement vcpkg::serialize_ipv(ipv, paths)

* [vcpkg] Implement x-package-info to enable tooling

* [vcpkg] Fixup tests to respect new cli mode

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
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

Successfully merging this pull request may close these issues.

6 participants