本文档翻译自: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 or
conanfile.txt) or to a recipe file. e.g.,
./my_project/conanfile.txt. It could also be a
reference
optional arguments:
-h, --help show this help message and exit
--paths Show package paths in local cache
-bo BUILD_ORDER, --build-order BUILD_ORDER
given a modified reference, return an ordered list to
build (CI). [DEPRECATED: use 'conan graph build-order
...' instead]
-g GRAPH, --graph GRAPH
Creates file with project dependencies graph. It will
generate a DOT or HTML file depending on the filename
extension
-if INSTALL_FOLDER, --install-folder INSTALL_FOLDER
local folder containing the conaninfo.txt and
conanbuildinfo.txt files (from a previous conan
install execution). Defaulted to current folder,
unless --profile, -s or -o is specified. If you
specify both install-folder and any setting/option it
will raise an error.
-j [JSON], --json [JSON]
Path to a json file where the information will be
written
-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 only
references.
--package-filter [PACKAGE_FILTER]
Print information only for packages that match the
filter pattern e.g., MyPackage/1.2@user/channel or
MyPackage*
-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 of
packages that would be built from sources during the
install command
-r REMOTE, --remote REMOTE
Look 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_HOST
Environment variables that will be set during the
package build (host machine). e.g.: -e
CXX=/usr/bin/clang++
-e:b ENV_BUILD, --env:build ENV_BUILD
Environment variables that will be set during the
package build (build machine). e.g.: -e:b
CXX=/usr/bin/clang++
-e:h ENV_HOST, --env:host ENV_HOST
Environment variables that will be set during the
package build (host machine). e.g.: -e:h
CXX=/usr/bin/clang++
-o OPTIONS_HOST, --options OPTIONS_HOST
Define options values (host machine), e.g.: -o
Pkg:with_qt=true
-o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
Define options values (build machine), e.g.: -o:b
Pkg:with_qt=true
-o:h OPTIONS_HOST, --options:host OPTIONS_HOST
Define options values (host machine), e.g.: -o:h
Pkg:with_qt=true
-pr PROFILE_HOST, --profile PROFILE_HOST
Apply the specified profile to the host machine
-pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
Apply the specified profile to the build machine
-pr:h PROFILE_HOST, --profile:host PROFILE_HOST
Apply the specified profile to the host machine
-s SETTINGS_HOST, --settings SETTINGS_HOST
Settings to build the package, overwriting the
defaults (host machine). e.g.: -s compiler=gcc
-s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
Settings to build the package, overwriting the
defaults (build machine). e.g.: -s:b compiler=gcc
-s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
Settings to build the package, overwriting the
defaults (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/channel
ID: 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
BuildID: None
Remote: None
URL: http://...
License: MIT
Description: A common dependency
Updates: Version not checked
Creation date: 2017-10-31 14:45:34
Required by:
hello/1.0@user/channel
hello/1.0@user/channel
ID: 5ab84d6acfe1f23c4fa5ab84d6acfe1f23c4fa8
BuildID: None
Remote: None
URL: http://...
License: MIT
Description: Hello World!
Updates: Version not checked
Required by:
Project
Requires:
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=x86
bzip2/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/channel
ID: 6af9cc7cb931c5ad942174fd7838eb655717c709
BuildID: None
export_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/export
source_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/source
build_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/build/6af9cc7cb931c5ad942174fd7838eb655717c709
package_folder: /home/conan/.conan/data/foobar/1.0.0/user/channel/package/6af9cc7cb931c5ad942174fd7838eb655717c709
Remote: None
License: MIT
Description: Foobar project
Author: Dummy
Topics: None
Recipe: Cache
Binary: Cache
Binary remote: None
Creation date: 2019-09-03 11:22:17