本文档翻译自:https://docs.conan.io/en/latest/reference/commands/creator/create.html
$ conan create [-h] [-j JSON] [-k] [-kb] [-ne] [-tbf TEST_BUILD_FOLDER][-tf TEST_FOLDER] [--ignore-dirty] [-m [MANIFESTS]][-mi [MANIFESTS_INTERACTIVE]] [-v [VERIFY]] [-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 [reference]
为配方(conanfile.py)构建二进制包。
在配置文件或-s设置,-o选项等中使用指定的配置。如果找到’test_package’文件夹(名称可以使用-tf进行配置),该命令将运行使用者项目以确保该软件包 已正确创建。 查看“ conan test”命令以了解有关“ test_folder”项目的更多信息。
positional arguments:path Path to a folder containing a conanfile.py or to arecipe file e.g., my_folder/conanfile.pyreference user/channel, version@user/channel orpkg/version@user/channel (if name or version declaredin conanfile.py, they should match)optional arguments:-h, --help show this help message and exit-j JSON, --json JSON json file path where the install information will bewritten to-k, -ks, --keep-sourceDo not remove the source folder in the local cache,even if the recipe changed. Use this for testingpurposes only-kb, --keep-build Do not remove the build folder in local cache. Implies--keep-source. Use this for testing purposes only-ne, --not-export Do not export the conanfile.py-tbf TEST_BUILD_FOLDER, --test-build-folder TEST_BUILD_FOLDERWorking directory for the build of the test project.-tf TEST_FOLDER, --test-folder TEST_FOLDERAlternative test folder name. By default it is"test_package". Use "None" to skip the test stage--ignore-dirty When using the "scm" feature with "auto" values,capture the revision and url even if there areuncommitted changes-m [MANIFESTS], --manifests [MANIFESTS]Install dependencies manifests in folder for laterverify. Default folder is .conan_manifests, but can bechanged-mi [MANIFESTS_INTERACTIVE], --manifests-interactive [MANIFESTS_INTERACTIVE]Install dependencies manifests in folder for laterverify, asking user for confirmation. Default folderis .conan_manifests, but can be changed-v [VERIFY], --verify [VERIFY]Verify dependencies manifests against stored ones-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=package name'.-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
**conan create . demo/testing** is equivalent to:
$ conan export . demo/testing$ conan install hello/0.1@demo/testing --build=hello# package is created now, use test to test it$ cd test_package$ conan test . hello/0.1@demo/testing
:::info
Tip
有时您需要跳过/禁用测试阶段,以免在创建软件包时失败,即:当您交叉编译库且目标代码无法在当前主机平台上执行时。 在这种情况下,您可以跳过/禁用测试包阶段:
$ conan create . demo/testing --test-folder=None
:::
柯南创建按以下顺序执行conanfile.py的方法:
config_options()configure()requirements()package_id()build_requirements()build_id()system_requirements()source()imports()build()package()package_info()
如果安装了预构建的二进制文件,则将跳过从5到11的步骤。 请注意,deploy()方法仅在柯南安装中使用。
:::info
Note
使用conan.conf中的general.parallel_download实验配置,可以加快二进制文件的安装速度,以设置并行下载。
:::
