配置文件插件¶
profile.py
扩展插件是一个 Python 脚本,它接收一个配置文件并允许检查和修改它。
此插件位于 extensions/plugins/profile.py
缓存文件夹中。
此 profile.py
包含一个默认实现,它会执行以下操作:
如果未定义,将尝试为
msvc
和clang
编译器(在 Windows 中)定义compiler.runtime_type
,并将其定义为与settings.build_type
匹配。这允许用户在配置文件中将其保留为未定义,并且只需使用-s build_type=Debug
即可在命令行中方便地切换。如果定义了
compiler.cppstd
值,将检查它以验证当前编译器版本是否支持它。例如,如果开发人员尝试使用-s compiler=gcc -s compiler.version=5 -s compiler.cppstd=20
,将会报错。尽管
profile.py
插件对处理compiler.cstd
检查有一些规定,但它们尚未实现,因此该插件对定义错误将保持宽松。请确保您的编译器版本确实支持compiler.cstd
。
用户可以自定义此 profile.py
并通过 conan config install
分发它,在这种情况下,应删除前几行。
# This file was generated by Conan. Remove this comment if you edit this file or Conan
# will destroy your changes.
并且 profile.py
应该包含一个具有以下签名的函数:
def profile_plugin(profile):
settings = profile.settings
print(settings)
当配置文件被计算时,它将显示类似如下内容:
OrderedDict([('arch', 'x86_64'), ('build_type', 'Release'), ('compiler', 'msvc'), ('compiler.cppstd', '14'), ('compiler.runtime', 'dynamic'), ('compiler.runtime_type', 'Release'), ('compiler.version', '192'), ('os', 'Windows')])
另请参阅
请参阅有关 Conan 配置文件 的文档。