本文档翻译自:https://docs.conan.io/en/latest/reference/commands/development/package.html
$ conan package [-h] [-bf BUILD_FOLDER] [-if INSTALL_FOLDER][-pf PACKAGE_FOLDER] [-sf SOURCE_FOLDER]path
调用您本地的conanfile.py的 “package()” 方法。
此命令在用户空间中起作用,它将把工件从–build-folder和–source-folder文件夹复制到–package-folder文件夹。 它不会在本地缓存中创建新程序包,如果要执行此操作,请在”conan build”命令后使用 “conan create” 或 “conan export-pkg”。
positional arguments:path Path to a folder containing a conanfile.py or to arecipe file e.g., my_folder/conanfile.pyoptional arguments:-h, --help show this help message and exit-bf BUILD_FOLDER, --build-folder BUILD_FOLDERDirectory for the build process. Defaulted to thecurrent directory. A relative path to the currentdirectory can also be specified-if INSTALL_FOLDER, --install-folder INSTALL_FOLDERDirectory containing the conaninfo.txt andconanbuildinfo.txt files (from previous 'conaninstall'). Defaulted to --build-folder-pf PACKAGE_FOLDER, --package-folder PACKAGE_FOLDERfolder to install the package. Defaulted to the'{build_folder}/package' folder. A relative path canbe specified (relative to the current directory). Alsoan absolute path is allowed.-sf SOURCE_FOLDER, --source-folder SOURCE_FOLDERDirectory containing the sources. Defaulted to theconanfile's directory. A relative path to the currentdirectory can also be specified
package() 方法可能使用来自指定配置文件的设置,选项和环境变量,以及来自conanfile要求中已声明的deps_XXX_info对象的依赖项信息。
运行conan install时,所有这些信息分别自动保存在conaninfo.txt和conanbuildinfo.txt文件中。 这些文件必须位于指定的—build-folder中。
$ conan install . --build-folder=build
Examples
本示例说明 package() 如何在可编辑并内置于用户文件夹而不是本地缓存中的包中工作。
$ conan new hello/0.1 -s$ conan install . --install-folder=build_x86 -s arch=x86$ conan build . --build-folder=build_x86$ conan package . --build-folder=build_x86 --package-folder=package_x86$ ls package/x86> conaninfo.txt conanmanifest.txt include/ lib/
:::info
Note
本地创建的软件包仅供用户使用,不能被其他软件包直接使用,也不能上载到远程存储库。 为了使这些软件包对系统可用,必须将它们放入conan本地缓存中,这可以使用conan export-pkg命令来完成,而不是使用conan package命令:
:::
:::info
$ conan new hello/0.1 -s$ conan install . --install-folder=build_x86 -s arch=x86$ conan build . --build-folder=build_x86$ conan export-pkg . hello/0.1@user/stable --build-folder=build_x86 -s arch=x86
:::
