conan profile¶
管理配置文件
conan profile detect¶
$ conan profile detect -h
usage: conan profile detect [-h] [-v [V]] [-cc CORE_CONF] [--name NAME] [-f]
[-e]
Generate a profile using auto-detected values.
options:
-h, --help show this help message and exit
-v [V] Level of detail of the output. Valid options from less
verbose to more verbose: -vquiet, -verror, -vwarning,
-vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
-vvv or -vtrace
-cc CORE_CONF, --core-conf CORE_CONF
Define core configuration, overwriting global.conf
values. E.g.: -cc core:non_interactive=True
--name NAME Profile name, 'default' if not specified
-f, --force Overwrite if exists
-e, --exist-ok If the profile already exist, do not detect a new one
警告
conan profile detect
的输出**不稳定**。它可能会在未来的 Conan 版本中随时更改,以适应最新的工具、最新版本或环境中的其他更改。有关更多信息,请参阅Conan 稳定性部分。
您可以使用以下命令为您的配置创建一个新的自动检测配置文件
$ conan profile detect
Found apple-clang 14.0
apple-clang>=13, using the major as version
Detected profile:
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=14
os=Macos
WARN: This profile is a guess of your environment, please check it.
WARN: Defaulted to cppstd='gnu17' for apple-clang.
WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions.
WARN: Use your own profile files for stability.
Saving detected profile to /Users/barbarians/.conan2/profiles/default
请注意,如果配置文件已存在,则必须使用--force
覆盖它。否则它将失败
$ conan profile detect
ERROR: Profile '/Users/carlosz/.conan2/profiles/default' already exists
$ conan profile detect --force
Found apple-clang 14.0
...
Saving detected profile to /Users/carlosz/.conan2/profiles/default
注意
最佳实践不建议在生产环境中使用conan profile detect
。为了保证可重复性,建议定义您自己的配置文件,将它们存储在 git 仓库或服务器上的 zip 文件中,并使用conan config install
将其分发给您的团队和 CI 机器,以及其他配置,如自定义设置、自定义远程定义等。
conan profile list¶
$ conan profile list -h
usage: conan profile list [-h] [-f FORMAT] [-v [V]] [-cc CORE_CONF]
List all profiles in the cache.
options:
-h, --help show this help message and exit
-f FORMAT, --format FORMAT
Select the output format: json
-v [V] Level of detail of the output. Valid options from less
verbose to more verbose: -vquiet, -verror, -vwarning,
-vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
-vvv or -vtrace
-cc CORE_CONF, --core-conf CORE_CONF
Define core configuration, overwriting global.conf
values. E.g.: -cc core:non_interactive=True
$ conan profile list
Profiles found in the cache:
default
ios_base
ios_simulator
clang_15
conan profile path¶
$ conan
Consumer commands
cache Perform file operations in the local cache (of recipes and/or packages).
config Manage the Conan configuration in the Conan home.
graph Compute a dependency graph, without installing or building the binaries.
inspect Inspect a conanfile.py to return its public fields.
install Install the requirements specified in a recipe (conanfile.py or conanfile.txt).
list List existing recipes, revisions, or packages in the cache (by default) or the
remotes.
lock Create or manage lockfiles.
pkglist Several operations over package lists
profile Manage profiles.
remote Manage the remote list and the users authenticated on them.
remove Remove recipes or packages from local cache or a remote.
search Search for package recipes in all the remotes (by default), or a remote.
version Give information about the Conan client version.
Creator commands
build Install dependencies and call the build() method.
create Create a package.
download Download (without installing) a single conan package from a remote server.
editable Allow working with a package that resides in user folder.
export Export a recipe to the Conan package cache.
export-pkg Create a package directly from pre-compiled binaries.
new Create a new example recipe and source files from a template.
source Call the source() method.
test Test a package from a test_package folder.
upload Upload packages to a remote.
Type "conan <command> -h" for help
用于获取您[CONAN_HOME]
文件夹中的配置文件位置
$ conan profile path default
/Users/barbarians/.conan2/profiles/default
conan profile show¶
$ conan profile show -h
usage: conan profile show [-h] [-f FORMAT] [-v [V]] [-cc CORE_CONF]
[-pr PROFILE] [-pr:b PROFILE_BUILD]
[-pr:h PROFILE_HOST] [-pr:a PROFILE_ALL]
[-o OPTIONS] [-o:b OPTIONS_BUILD]
[-o:h OPTIONS_HOST] [-o:a OPTIONS_ALL] [-s SETTINGS]
[-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST]
[-s:a SETTINGS_ALL] [-c CONF] [-c:b CONF_BUILD]
[-c:h CONF_HOST] [-c:a CONF_ALL]
Show aggregated profiles from the passed arguments.
options:
-h, --help show this help message and exit
-f FORMAT, --format FORMAT
Select the output format: json
-v [V] Level of detail of the output. Valid options from less
verbose to more verbose: -vquiet, -verror, -vwarning,
-vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
-vvv or -vtrace
-cc CORE_CONF, --core-conf CORE_CONF
Define core configuration, overwriting global.conf
values. E.g.: -cc core:non_interactive=True
-pr PROFILE, --profile PROFILE
Apply the specified profile. By default, or if
specifying -pr:h (--profile:host), it applies to the
host context. Use -pr:b (--profile:build) to specify
the build context, or -pr:a (--profile:all) to specify
both contexts at once
-pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
-pr:h PROFILE_HOST, --profile:host PROFILE_HOST
-pr:a PROFILE_ALL, --profile:all PROFILE_ALL
-o OPTIONS, --options OPTIONS
Apply the specified options. By default, or if
specifying -o:h (--options:host), it applies to the
host context. Use -o:b (--options:build) to specify
the build context, or -o:a (--options:all) to specify
both contexts at once. Example:
-o="pkg/*:with_qt=True"
-o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
-o:h OPTIONS_HOST, --options:host OPTIONS_HOST
-o:a OPTIONS_ALL, --options:all OPTIONS_ALL
-s SETTINGS, --settings SETTINGS
Apply the specified settings. By default, or if
specifying -s:h (--settings:host), it applies to the
host context. Use -s:b (--settings:build) to specify
the build context, or -s:a (--settings:all) to specify
both contexts at once. Example: -s="compiler=gcc"
-s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
-s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
-s:a SETTINGS_ALL, --settings:all SETTINGS_ALL
-c CONF, --conf CONF Apply the specified conf. By default, or if specifying
-c:h (--conf:host), it applies to the host context.
Use -c:b (--conf:build) to specify the build context,
or -c:a (--conf:all) to specify both contexts at once.
Example:
-c="tools.cmake.cmaketoolchain:generator=Xcode"
-c:b CONF_BUILD, --conf:build CONF_BUILD
-c:h CONF_HOST, --conf:host CONF_HOST
-c:a CONF_ALL, --conf:all CONF_ALL
使用conan profile show从命令行参数计算生成的构建和主机配置文件。例如,使用默认配置文件或使用pr:b
或pr:h
参数结合其他任何配置文件,组合不同的选项和设置
$ conan profile show -s:h build_type=Debug -o:h shared=False
Host profile:
[settings]
arch=x86_64
build_type=Debug
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=14
os=Macos
[options]
shared=False
[conf]
Build profile:
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=14
os=Macos
[conf]
它还有助于显示配置文件中 Jinja2 模板的评估结果。例如,像这样的配置文件
[settings]
os = {{ {"Darwin": "Macos"}.get(platform.system(), platform.system()) }}
检查已评估的配置文件
$ conan profile show -pr:h=myprofile
Host profile:
[settings]
os=Macos
[conf]
...
该命令还可以输出包含结果的 json 文件
$ conan profile show --format=json
{
"host": {
"settings": {
"arch": "armv8",
"build_type": "Release",
"compiler": "apple-clang",
"compiler.cppstd": "gnu17",
"compiler.libcxx": "libc++",
"compiler.version": "15",
"os": "Macos"
},
"package_settings": {},
"options": {},
"tool_requires": {},
"conf": {},
"build_env": ""
},
"build": {
"settings": {
"arch": "armv8",
"build_type": "Release",
"compiler": "apple-clang",
"compiler.cppstd": "gnu17",
"compiler.libcxx": "libc++",
"compiler.version": "15",
"os": "Macos"
},
"package_settings": {},
"options": {},
"tool_requires": {},
"conf": {},
"build_env": ""
}
}
另请参阅
阅读有关配置文件的更多信息