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

  1. $ conan graph [-h] {update-lock,build-order,clean-modified,lock} ...

生成和操作锁定文件。

  1. positional arguments:
  2. {update-lock,build-order,clean-modified,lock}
  3. sub-command help
  4. update-lock merge two lockfiles
  5. build-order Returns build-order
  6. clean-modified Clean modified
  7. lock create a lockfile
  8. optional arguments:
  9. -h, --help show this help message and exit

conan graph update-lock

  1. $ conan graph update-lock [-h] old_lockfile new_lockfile

使用new_lockfiles的内容更新old_lockfile文件。

  1. positional arguments:
  2. old_lockfile path to previous lockfile
  3. new_lockfile path to modified lockfile
  4. optional arguments:
  5. -h, --help show this help message and exit

仅new_lockfile中标记为“已修改”的软件包将被处理。 如果old_lockfile中的节点已被修改,并且尝试更新不兼容的(不同的二进制ID,不同的修订版),它将引发错误。 在old_lockfile中更新后,更新的节点将保留“ modified”标志
此命令对于由相同锁文件锁定的相同依赖关系图中的不同程序包的分布式或并行构建很有用。 重建一个软件包时,它将修改软件包参考,并标记为“已修改”。 将软件包构建信息集成到主锁文件中的方法是此命令。

Example:
使用主锁文件中的锁文件(并在文件夹pkgb_temp中进行修改)集成构建“ pkgb”软件包的信息:

  1. $ conan graph update-lock release/conan.lock pkgb_temp/release/conan.lock

conan graph clean-modified

  1. $ conan graph clean-modified [-h] lockfile

从给定的锁定文件中清除所有“已修改”标志。

  1. positional arguments:
  2. lockfile lockfile folder
  3. optional arguments:
  4. -h, --help show this help message and exit

当要使用给定的锁定文件来重建依赖关系图的软件包时,希望知道最后一条命令实际上已经重建了该图的哪些软件包,从而完成构建。 此命令将在此类构建之前清除所有先前存在的“已修改”标志,因此在构建之后,仅已构建的那些“已修改”标志。

conan graph build-order

  1. $ conan graph build-order [-h] [-b [BUILD]] [--json JSON] lockfile

给定一个锁文件,根据二进制ID(package_id())定义和—build参数的要求,计算应该编译哪些软件包以及应该以什么顺序构建它们,与conan create | install相同

  1. positional arguments:
  2. lockfile lockfile folder
  3. optional arguments:
  4. -h, --help show this help message and exit
  5. -b [BUILD], --build [BUILD]
  6. Optional, specify which packages to build from source.
  7. Combining multiple '--build' options on one command
  8. line is allowed. For dependencies, the optional
  9. 'build_policy' attribute in their conanfile.py takes
  10. precedence over the command line parameter. Possible
  11. parameters: --build Force build for all packages, do
  12. not use binary packages. --build=never Disallow build
  13. for all packages, use binary packages or fail if a
  14. binary package is not found. Cannot be combined with
  15. other '--build' options. --build=missing Build
  16. packages from source whose binary package is not
  17. found. --build=outdated Build packages from source
  18. whose binary package was not generated from the latest
  19. recipe or is not found. --build=cascade Build packages
  20. from source that have at least one dependency being
  21. built from source. --build=[pattern] Build packages
  22. from source whose package reference matches the
  23. pattern. The pattern uses 'fnmatch' style wildcards.
  24. Default behavior: If you omit the '--build' option,
  25. the 'build_policy' attribute in conanfile.py will be
  26. used if it exists, otherwise the behavior is like '--
  27. build=never'.
  28. --json JSON generate output file in json format

结果是一个包含元组的列表列表。 每个元组包含2个元素,第一个是图节点的UUID。 它是唯一的,即使在节点具有相同引用的情况下,也可以确保精确寻址一个节点的方式(例如,可能具有相同名称和版本但配置不同的build_requires)

conan graph lock

  1. $ conan graph lock [-h] [-l LOCKFILE] [-b [BUILD]] [-r REMOTE] [-u] [-e ENV_HOST]
  2. [-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST]
  3. [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST] [-pr PROFILE_HOST]
  4. [-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST] [-s SETTINGS_HOST]
  5. [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST]
  6. 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 reference
  5. optional arguments:
  6. -h, --help show this help message and exit
  7. -l LOCKFILE, --lockfile LOCKFILE
  8. Path to lockfile to be created. If not specified 'conan.lock' will
  9. be created in current folder
  10. -b [BUILD], --build [BUILD]
  11. Packages to build from source
  12. -r REMOTE, --remote REMOTE
  13. Look in the specified remote server
  14. -u, --update Check updates exist from upstream remotes
  15. -e ENV_HOST, --env ENV_HOST
  16. Environment variables that will be set during the package build
  17. (host machine). e.g.: -e CXX=/usr/bin/clang++
  18. -e:b ENV_BUILD, --env:build ENV_BUILD
  19. Environment variables that will be set during the package build
  20. (build machine). e.g.: -e CXX=/usr/bin/clang++
  21. -e:h ENV_HOST, --env:host ENV_HOST
  22. Environment variables that will be set during the package build
  23. (host machine). e.g.: -e CXX=/usr/bin/clang++
  24. -o OPTIONS_HOST, --options OPTIONS_HOST
  25. Define options values (host machine), e.g.: -o Pkg:with_qt=true
  26. -o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
  27. Define options values (build machine), e.g.: -o Pkg:with_qt=true
  28. -o:h OPTIONS_HOST, --options:host OPTIONS_HOST
  29. Define options values (host machine), e.g.: -o Pkg:with_qt=true
  30. -pr PROFILE_HOST, --profile PROFILE_HOST
  31. Apply the specified profile to the host machine
  32. -pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
  33. Apply the specified profile to the build machine
  34. -pr:h PROFILE_HOST, --profile:host PROFILE_HOST
  35. Apply the specified profile to the host machine
  36. -s SETTINGS_HOST, --settings SETTINGS_HOST
  37. Settings to build the package, overwriting the defaults (host
  38. machine). e.g.: -s compiler=gcc
  39. -s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
  40. Settings to build the package, overwriting the defaults (build
  41. machine). e.g.: -s compiler=gcc
  42. -s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
  43. Settings to build the package, overwriting the defaults (host
  44. machine). e.g.: -s compiler=gcc

此命令类似于conan installconan info,但有一些区别:

  • 它不需要检索二进制文件,它只会根据--build参数和规则来计算需要执行的操作
  • 即使指定了--build值,也不会从源代码构建软件包。 它只是计算“试运行”在等效 conan install 中会发生的情况