中国建设招聘信息网站,出入郑州最新通知今天,深圳住房和城乡建设厅官网,api网站模板最近使用conan来执行本地或交叉编译时#xff0c;我发现我需要知道当前profile定义的编译器的类型和版本以及平台#xff0c;希望用profile中定义的os,arch,compier生成安装路径名如windows-msvc-x86_64#xff0c;该怎么实现呢#xff1f;
conan profile show
基本的思路…最近使用conan来执行本地或交叉编译时我发现我需要知道当前profile定义的编译器的类型和版本以及平台希望用profile中定义的os,arch,compier生成安装路径名如windows-msvc-x86_64该怎么实现呢
conan profile show
基本的思路就是用 conan profile show命令获取profile中的配置参数,参见 https://docs.conan.io/2/reference/commands/profile.html 执行 conan profile show --formatjson可以以json 格式输出当前profilehost及build)中定义所有的参数 如下
{host: {settings: {arch: x86_64,build_type: Release,compiler: gcc,compiler.cppstd: gnu11,compiler.libcxx: libstdc11,compiler.version: 5.2,os: Windows},package_settings: {},options: {boost/*:without_stacktrace: True},tool_requires: {},conf: {},build_env: },build: {settings: {arch: x86_64,build_type: Release,compiler: gcc,compiler.cppstd: gnu11,compiler.libcxx: libstdc11,compiler.version: 5.2,os: Windows},package_settings: {},options: {boost/*:without_stacktrace: True},tool_requires: {},conf: {},build_env: }
}有了这个json,就可以用python的json工具来读取其中的内容了
示例一
如下命令读取host profile的编译类型字段(host.settings.compiler)
conan profile show --formatjson | python -c import sys, json; print(json.load(sys.stdin)[host][settings][compiler])输出 gcc 示例二
如下读取compiler,arch,os字段拼写生成完整的类machine描述
conan profile show --formatjson | python -c import sys, json; jjson.load(sys.stdin)[host][settings];mj[os]-j[compiler]-j[arch]; print(m.lower())输出 windows-gcc-x86_64 参考资料
《profile》 《Parse JSON using Python?》