本文档翻译自:https://docs.conan.io/en/latest/reference/commands/consumer/info.html
$ conan info [-h] [--paths] [-bo BUILD_ORDER] [-g GRAPH][-if INSTALL_FOLDER] [-j [JSON]] [-n ONLY][--package-filter [PACKAGE_FILTER]] [-db [DRY_BUILD]][-b [BUILD]] [-r REMOTE] [-u] [-l [LOCKFILE]] [-e ENV_HOST][-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST][-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST] [-pr PROFILE_HOST][-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST][-s SETTINGS_HOST] [-s:b SETTINGS_BUILD][-s:h SETTINGS_HOST]path_or_reference
获取有关配方的依赖关系图的信息。
它可以与本地缓存中任何现有软件包的配方或参考一起使用。
positional arguments:path_or_reference Path to a folder containing a recipe (conanfile.py orconanfile.txt) or to a recipe file. e.g.,./my_project/conanfile.txt. It could also be areferenceoptional arguments:-h, --help show this help message and exit--paths Show package paths in local cache-bo BUILD_ORDER, --build-order BUILD_ORDERgiven a modified reference, return an ordered list tobuild (CI). [DEPRECATED: use 'conan graph build-order...' instead]-g GRAPH, --graph GRAPHCreates file with project dependencies graph. It willgenerate a DOT or HTML file depending on the filenameextension-if INSTALL_FOLDER, --install-folder INSTALL_FOLDERlocal folder containing the conaninfo.txt andconanbuildinfo.txt files (from a previous conaninstall execution). Defaulted to current folder,unless --profile, -s or -o is specified. If youspecify both install-folder and any setting/option itwill raise an error.-j [JSON], --json [JSON]Path to a json file where the information will bewritten-n ONLY, --only ONLY Show only the specified fields: "id", "build_id","remote", "url", "license", "requires", "update","required", "date", "author", "description", "None". '--paths' information can also be filtered with options"export_folder", "build_folder", "package_folder","source_folder". Use '--only None' to show onlyreferences.--package-filter [PACKAGE_FILTER]Print information only for packages that match thefilter pattern e.g., MyPackage/1.2@user/channel orMyPackage*-db [DRY_BUILD], --dry-build [DRY_BUILD]Apply the --build argument to output the information,as it would be done by the install command-b [BUILD], --build [BUILD]Given a build policy, return an ordered list ofpackages that would be built from sources during theinstall command-r REMOTE, --remote REMOTELook in the specified remote server-u, --update Check updates exist from upstream remotes-l [LOCKFILE], --lockfile [LOCKFILE]Path to a lockfile or folder containing 'conan.lock'file. Lockfile can be updated if packages change-e ENV_HOST, --env ENV_HOSTEnvironment variables that will be set during thepackage build (host machine). e.g.: -eCXX=/usr/bin/clang++-e:b ENV_BUILD, --env:build ENV_BUILDEnvironment variables that will be set during thepackage build (build machine). e.g.: -e:bCXX=/usr/bin/clang++-e:h ENV_HOST, --env:host ENV_HOSTEnvironment variables that will be set during thepackage build (host machine). e.g.: -e:hCXX=/usr/bin/clang++-o OPTIONS_HOST, --options OPTIONS_HOSTDefine options values (host machine), e.g.: -oPkg:with_qt=true-o:b OPTIONS_BUILD, --options:build OPTIONS_BUILDDefine options values (build machine), e.g.: -o:bPkg:with_qt=true-o:h OPTIONS_HOST, --options:host OPTIONS_HOSTDefine options values (host machine), e.g.: -o:hPkg:with_qt=true-pr PROFILE_HOST, --profile PROFILE_HOSTApply the specified profile to the host machine-pr:b PROFILE_BUILD, --profile:build PROFILE_BUILDApply the specified profile to the build machine-pr:h PROFILE_HOST, --profile:host PROFILE_HOSTApply the specified profile to the host machine-s SETTINGS_HOST, --settings SETTINGS_HOSTSettings to build the package, overwriting thedefaults (host machine). e.g.: -s compiler=gcc-s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILDSettings to build the package, overwriting thedefaults (build machine). e.g.: -s:b compiler=gcc-s:h SETTINGS_HOST, --settings:host SETTINGS_HOSTSettings to build the package, overwriting thedefaults (host machine). e.g.: -s:h compiler=gcc
Examples:
$ conan info .$ conan info myproject_folder$ conan info myproject_folder/conanfile.py$ conan info hello/1.0@user/channel
输出将如下所示:
Dependency/0.1@user/channelID: 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9BuildID: NoneRemote: NoneURL: http://...License: MITDescription: A common dependencyUpdates: Version not checkedCreation date: 2017-10-31 14:45:34Required by:hello/1.0@user/channelhello/1.0@user/channelID: 5ab84d6acfe1f23c4fa5ab84d6acfe1f23c4fa8BuildID: NoneRemote: NoneURL: http://...License: MITDescription: Hello World!Updates: Version not checkedRequired by:ProjectRequires:hello0/0.1@user/channel
conan info可以像conan install那样构建完整的依赖关系图。 主要区别在于,它不会尝试安装或构建二进制文件,但如有必要,将从远程获取软件包的配方。**
需要特别注意的是,info命令输出给定配置(设置,选项)的依赖关系图,因为依赖关系图对于不同的配置可能是不同的。 然后,conan info命令的输入与conan install相同,可以直接使用设置和选项或使用配置文件指定配置。
另外,如果以前使用特定配置进行 conan install,或者使用不同配置进行了不同的安装,则可以使用--install-folder参数重用该信息:
$ # dir with a conanfile.txt$ mkdir build_release && cd build_release$ conan install .. --profile=gcc54release$ cd .. && mkdir build_debug && cd build_debug$ conan install .. --profile=gcc54debug$ cd ..$ conan info . --install-folder=build_release> info for the release dependency graph install$ conan info . --install-folder=build_debug> info for the debug dependency graph install
可以使用conan info命令为持续集成系统提取有用的信息。 更准确地说,它具有--build-order,-bo选项(弃用conan lock构建顺序),它将生成机器可读的输出,其中包含应按顺序构建的包引用列表 。 例如,假设我们有一个项目依赖于Boost和Poco,而后者又间接依赖于OpenSSL和zlib。 因此,我们可以使用已更改的引用来查询我们的项目(很可能是由于对该包的git push):
$ conan info . -bo zlib/1.2.11@[zlib/1.2.11], [openssl/1.0.2u], [boost/1.71.0, poco/1.9.4]
注意结果是列表列表。 如果列表之一中包含多个元素,则意味着它们是分离的项目,并且可以由CI系统并行构建。
如果只想计算整个依赖关系图的构建顺序,也可以指定--build-order=ALL参数。
$ conan info . --build-order=ALL> [zlib/1.2.11], [openssl/1.0.2u], [boost/1.71.0, poco/1.9.4]
另外,您还可以获得在安装命令中使用--build参数指定构建策略的要构建(模拟)的节点的列表。
例如,如果我尝试使用--build缺少构建策略和arch=x86来安装boost/1.71.0配方,将构建哪些库?
$ conan info boost/1.71.0@ --build missing -s arch=x86bzip2/1.0.8, zlib/1.2.11, boost/1.71.0
您可以以点或html格式生成依赖关系图:
$ conan info .. --graph=file.html$ file.html # or open the file, double-click

生成的html输出包含指向第三方资源vis.js库的链接(2个文件:vis.min.js,vis.min.css)。 默认情况下,它们是从cloudfare中检索的。 但是,对于没有Internet连接的环境,也可以从本地缓存中使用这些文件,并通过将这些文件放在配置文件夹的根目录中,并通过conan config install进行安装:
- vis.min.js:默认链接为“ https://cdnjs.cloudflare.com/ajax/libs/vis/4.18.1/vis.min.js”
- vis.min.css:默认链接为“ https://cdnjs.cloudflare.com/ajax/libs/vis/4.18.1/vis.min.css”
无需修改生成的html文件。 如果存在,conan将自动使用本地路径到缓存文件,如果没有,则使用Internet路径。
您可以使用参数—paths查找软件包在缓存中的安装位置:
$ conan info foobar/1.0.0@user/channel --paths
输出将如下所示:
foobar/1.0.0@user/channelID: 6af9cc7cb931c5ad942174fd7838eb655717c709BuildID: Noneexport_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/exportsource_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/sourcebuild_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/build/6af9cc7cb931c5ad942174fd7838eb655717c709package_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/package/6af9cc7cb931c5ad942174fd7838eb655717c709Remote: NoneLicense: MITDescription: Foobar projectAuthor: DummyTopics: NoneRecipe: CacheBinary: CacheBinary remote: NoneCreation date: 2019-09-03 11:22:17
