本文档翻译自:https://docs.conan.io/en/latest/reference/commands/misc/graph.html
$ conan graph [-h] {update-lock,build-order,clean-modified,lock} ...
生成和操作锁定文件。
positional arguments:{update-lock,build-order,clean-modified,lock}sub-command helpupdate-lock merge two lockfilesbuild-order Returns build-orderclean-modified Clean modifiedlock create a lockfileoptional arguments:-h, --help show this help message and exit
conan graph update-lock
$ conan graph update-lock [-h] old_lockfile new_lockfile
使用new_lockfiles的内容更新old_lockfile文件。
positional arguments:old_lockfile path to previous lockfilenew_lockfile path to modified lockfileoptional arguments:-h, --help show this help message and exit
仅new_lockfile中标记为“已修改”的软件包将被处理。 如果old_lockfile中的节点已被修改,并且尝试更新不兼容的(不同的二进制ID,不同的修订版),它将引发错误。 在old_lockfile中更新后,更新的节点将保留“ modified”标志
此命令对于由相同锁文件锁定的相同依赖关系图中的不同程序包的分布式或并行构建很有用。 重建一个软件包时,它将修改软件包参考,并标记为“已修改”。 将软件包构建信息集成到主锁文件中的方法是此命令。
Example:
使用主锁文件中的锁文件(并在文件夹pkgb_temp中进行修改)集成构建“ pkgb”软件包的信息:
$ conan graph update-lock release/conan.lock pkgb_temp/release/conan.lock
conan graph clean-modified
$ conan graph clean-modified [-h] lockfile
从给定的锁定文件中清除所有“已修改”标志。
positional arguments:lockfile lockfile folderoptional arguments:-h, --help show this help message and exit
当要使用给定的锁定文件来重建依赖关系图的软件包时,希望知道最后一条命令实际上已经重建了该图的哪些软件包,从而完成构建。 此命令将在此类构建之前清除所有先前存在的“已修改”标志,因此在构建之后,仅已构建的那些“已修改”标志。
conan graph build-order
$ conan graph build-order [-h] [-b [BUILD]] [--json JSON] lockfile
给定一个锁文件,根据二进制ID(package_id())定义和—build参数的要求,计算应该编译哪些软件包以及应该以什么顺序构建它们,与conan create | install相同
positional arguments:lockfile lockfile folderoptional arguments:-h, --help show this help message and exit-b [BUILD], --build [BUILD]Optional, specify which packages to build from source.Combining multiple '--build' options on one commandline is allowed. For dependencies, the optional'build_policy' attribute in their conanfile.py takesprecedence over the command line parameter. Possibleparameters: --build Force build for all packages, donot use binary packages. --build=never Disallow buildfor all packages, use binary packages or fail if abinary package is not found. Cannot be combined withother '--build' options. --build=missing Buildpackages from source whose binary package is notfound. --build=outdated Build packages from sourcewhose binary package was not generated from the latestrecipe or is not found. --build=cascade Build packagesfrom source that have at least one dependency beingbuilt from source. --build=[pattern] Build packagesfrom source whose package reference matches thepattern. The pattern uses 'fnmatch' style wildcards.Default behavior: If you omit the '--build' option,the 'build_policy' attribute in conanfile.py will beused if it exists, otherwise the behavior is like '--build=never'.--json JSON generate output file in json format
结果是一个包含元组的列表列表。 每个元组包含2个元素,第一个是图节点的UUID。 它是唯一的,即使在节点具有相同引用的情况下,也可以确保精确寻址一个节点的方式(例如,可能具有相同名称和版本但配置不同的build_requires)
conan graph lock
$ conan graph lock [-h] [-l LOCKFILE] [-b [BUILD]] [-r REMOTE] [-u] [-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 a referenceoptional arguments:-h, --help show this help message and exit-l LOCKFILE, --lockfile LOCKFILEPath to lockfile to be created. If not specified 'conan.lock' willbe created in current folder-b [BUILD], --build [BUILD]Packages to build from source-r REMOTE, --remote REMOTELook in the specified remote server-u, --update Check updates exist from upstream remotes-e ENV_HOST, --env ENV_HOSTEnvironment 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_BUILDEnvironment variables that will be set during the package build(build machine). e.g.: -e CXX=/usr/bin/clang++-e:h ENV_HOST, --env:host ENV_HOSTEnvironment variables that will be set during the package build(host machine). e.g.: -e CXX=/usr/bin/clang++-o OPTIONS_HOST, --options OPTIONS_HOSTDefine options values (host machine), e.g.: -o Pkg:with_qt=true-o:b OPTIONS_BUILD, --options:build OPTIONS_BUILDDefine options values (build machine), e.g.: -o Pkg:with_qt=true-o:h OPTIONS_HOST, --options:host OPTIONS_HOSTDefine options values (host machine), e.g.: -o Pkg: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 the defaults (hostmachine). e.g.: -s compiler=gcc-s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILDSettings to build the package, overwriting the defaults (buildmachine). e.g.: -s compiler=gcc-s:h SETTINGS_HOST, --settings:host SETTINGS_HOSTSettings to build the package, overwriting the defaults (hostmachine). e.g.: -s compiler=gcc
此命令类似于conan install或conan info,但有一些区别:
- 它不需要检索二进制文件,它只会根据
--build参数和规则来计算需要执行的操作 - 即使指定了
--build值,也不会从源代码构建软件包。 它只是计算“试运行”在等效conan install中会发生的情况
