本文档翻译自:https://docs.conan.io/en/latest/reference/commands/consumer/info.html

    1. $ conan info [-h] [--paths] [-bo BUILD_ORDER] [-g GRAPH]
    2. [-if INSTALL_FOLDER] [-j [JSON]] [-n ONLY]
    3. [--package-filter [PACKAGE_FILTER]] [-db [DRY_BUILD]]
    4. [-b [BUILD]] [-r REMOTE] [-u] [-l [LOCKFILE]] [-e ENV_HOST]
    5. [-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST]
    6. [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST] [-pr PROFILE_HOST]
    7. [-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST]
    8. [-s SETTINGS_HOST] [-s:b SETTINGS_BUILD]
    9. [-s:h SETTINGS_HOST]
    10. path_or_reference

    获取有关配方的依赖关系图的信息。
    它可以与本地缓存中任何现有软件包的配方或参考一起使用。

    1. positional arguments:
    2. path_or_reference Path to a folder containing a recipe (conanfile.py or
    3. conanfile.txt) or to a recipe file. e.g.,
    4. ./my_project/conanfile.txt. It could also be a
    5. reference
    6. optional arguments:
    7. -h, --help show this help message and exit
    8. --paths Show package paths in local cache
    9. -bo BUILD_ORDER, --build-order BUILD_ORDER
    10. given a modified reference, return an ordered list to
    11. build (CI). [DEPRECATED: use 'conan graph build-order
    12. ...' instead]
    13. -g GRAPH, --graph GRAPH
    14. Creates file with project dependencies graph. It will
    15. generate a DOT or HTML file depending on the filename
    16. extension
    17. -if INSTALL_FOLDER, --install-folder INSTALL_FOLDER
    18. local folder containing the conaninfo.txt and
    19. conanbuildinfo.txt files (from a previous conan
    20. install execution). Defaulted to current folder,
    21. unless --profile, -s or -o is specified. If you
    22. specify both install-folder and any setting/option it
    23. will raise an error.
    24. -j [JSON], --json [JSON]
    25. Path to a json file where the information will be
    26. written
    27. -n ONLY, --only ONLY Show only the specified fields: "id", "build_id",
    28. "remote", "url", "license", "requires", "update",
    29. "required", "date", "author", "description", "None". '
    30. --paths' information can also be filtered with options
    31. "export_folder", "build_folder", "package_folder",
    32. "source_folder". Use '--only None' to show only
    33. references.
    34. --package-filter [PACKAGE_FILTER]
    35. Print information only for packages that match the
    36. filter pattern e.g., MyPackage/1.2@user/channel or
    37. MyPackage*
    38. -db [DRY_BUILD], --dry-build [DRY_BUILD]
    39. Apply the --build argument to output the information,
    40. as it would be done by the install command
    41. -b [BUILD], --build [BUILD]
    42. Given a build policy, return an ordered list of
    43. packages that would be built from sources during the
    44. install command
    45. -r REMOTE, --remote REMOTE
    46. Look in the specified remote server
    47. -u, --update Check updates exist from upstream remotes
    48. -l [LOCKFILE], --lockfile [LOCKFILE]
    49. Path to a lockfile or folder containing 'conan.lock'
    50. file. Lockfile can be updated if packages change
    51. -e ENV_HOST, --env ENV_HOST
    52. Environment variables that will be set during the
    53. package build (host machine). e.g.: -e
    54. CXX=/usr/bin/clang++
    55. -e:b ENV_BUILD, --env:build ENV_BUILD
    56. Environment variables that will be set during the
    57. package build (build machine). e.g.: -e:b
    58. CXX=/usr/bin/clang++
    59. -e:h ENV_HOST, --env:host ENV_HOST
    60. Environment variables that will be set during the
    61. package build (host machine). e.g.: -e:h
    62. CXX=/usr/bin/clang++
    63. -o OPTIONS_HOST, --options OPTIONS_HOST
    64. Define options values (host machine), e.g.: -o
    65. Pkg:with_qt=true
    66. -o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
    67. Define options values (build machine), e.g.: -o:b
    68. Pkg:with_qt=true
    69. -o:h OPTIONS_HOST, --options:host OPTIONS_HOST
    70. Define options values (host machine), e.g.: -o:h
    71. Pkg:with_qt=true
    72. -pr PROFILE_HOST, --profile PROFILE_HOST
    73. Apply the specified profile to the host machine
    74. -pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
    75. Apply the specified profile to the build machine
    76. -pr:h PROFILE_HOST, --profile:host PROFILE_HOST
    77. Apply the specified profile to the host machine
    78. -s SETTINGS_HOST, --settings SETTINGS_HOST
    79. Settings to build the package, overwriting the
    80. defaults (host machine). e.g.: -s compiler=gcc
    81. -s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
    82. Settings to build the package, overwriting the
    83. defaults (build machine). e.g.: -s:b compiler=gcc
    84. -s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
    85. Settings to build the package, overwriting the
    86. defaults (host machine). e.g.: -s:h compiler=gcc

    Examples:

    1. $ conan info .
    2. $ conan info myproject_folder
    3. $ conan info myproject_folder/conanfile.py
    4. $ conan info hello/1.0@user/channel

    输出将如下所示:

    1. Dependency/0.1@user/channel
    2. ID: 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    3. BuildID: None
    4. Remote: None
    5. URL: http://...
    6. License: MIT
    7. Description: A common dependency
    8. Updates: Version not checked
    9. Creation date: 2017-10-31 14:45:34
    10. Required by:
    11. hello/1.0@user/channel
    12. hello/1.0@user/channel
    13. ID: 5ab84d6acfe1f23c4fa5ab84d6acfe1f23c4fa8
    14. BuildID: None
    15. Remote: None
    16. URL: http://...
    17. License: MIT
    18. Description: Hello World!
    19. Updates: Version not checked
    20. Required by:
    21. Project
    22. Requires:
    23. hello0/0.1@user/channel

    conan info可以像conan install那样构建完整的依赖关系图。 主要区别在于,它不会尝试安装或构建二进制文件,但如有必要,将从远程获取软件包的配方。**
    需要特别注意的是,info命令输出给定配置(设置,选项)的依赖关系图,因为依赖关系图对于不同的配置可能是不同的。 然后,conan info命令的输入与conan install相同,可以直接使用设置和选项或使用配置文件指定配置。
    另外,如果以前使用特定配置进行 conan install,或者使用不同配置进行了不同的安装,则可以使用--install-folder参数重用该信息:

    1. $ # dir with a conanfile.txt
    2. $ mkdir build_release && cd build_release
    3. $ conan install .. --profile=gcc54release
    4. $ cd .. && mkdir build_debug && cd build_debug
    5. $ conan install .. --profile=gcc54debug
    6. $ cd ..
    7. $ conan info . --install-folder=build_release
    8. > info for the release dependency graph install
    9. $ conan info . --install-folder=build_debug
    10. > info for the debug dependency graph install

    可以使用conan info命令为持续集成系统提取有用的信息。 更准确地说,它具有--build-order,-bo选项(弃用conan lock构建顺序),它将生成机器可读的输出,其中包含应按顺序构建的包引用列表 。 例如,假设我们有一个项目依赖于Boost和Poco,而后者又间接依赖于OpenSSL和zlib。 因此,我们可以使用已更改的引用来查询我们的项目(很可能是由于对该包的git push):

    1. $ conan info . -bo zlib/1.2.11@
    2. [zlib/1.2.11], [openssl/1.0.2u], [boost/1.71.0, poco/1.9.4]

    注意结果是列表列表。 如果列表之一中包含多个元素,则意味着它们是分离的项目,并且可以由CI系统并行构建。
    如果只想计算整个依赖关系图的构建顺序,也可以指定--build-order=ALL参数。

    1. $ conan info . --build-order=ALL
    2. > [zlib/1.2.11], [openssl/1.0.2u], [boost/1.71.0, poco/1.9.4]

    另外,您还可以获得在安装命令中使用--build参数指定构建策略的要构建(模拟)的节点的列表。
    例如,如果我尝试使用--build缺少构建策略和arch=x86来安装boost/1.71.0配方,将构建哪些库?

    1. $ conan info boost/1.71.0@ --build missing -s arch=x86
    2. bzip2/1.0.8, zlib/1.2.11, boost/1.71.0

    您可以以点或html格式生成依赖关系图:

    1. $ conan info .. --graph=file.html
    2. $ file.html # or open the file, double-click

    image.png
    生成的html输出包含指向第三方资源vis.js库的链接(2个文件:vis.min.js,vis.min.css)。 默认情况下,它们是从cloudfare中检索的。 但是,对于没有Internet连接的环境,也可以从本地缓存中使用这些文件,并通过将这些文件放在配置文件夹的根目录中,并通过conan config install进行安装:

    无需修改生成的html文件。 如果存在,conan将自动使用本地路径到缓存文件,如果没有,则使用Internet路径。
    您可以使用参数—paths查找软件包在缓存中的安装位置:

    1. $ conan info foobar/1.0.0@user/channel --paths

    输出将如下所示:

    1. foobar/1.0.0@user/channel
    2. ID: 6af9cc7cb931c5ad942174fd7838eb655717c709
    3. BuildID: None
    4. export_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/export
    5. source_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/source
    6. build_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/build/6af9cc7cb931c5ad942174fd7838eb655717c709
    7. package_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/package/6af9cc7cb931c5ad942174fd7838eb655717c709
    8. Remote: None
    9. License: MIT
    10. Description: Foobar project
    11. Author: Dummy
    12. Topics: None
    13. Recipe: Cache
    14. Binary: Cache
    15. Binary remote: None
    16. Creation date: 2019-09-03 11:22:17