简体   繁体   English

我如何使用柯南包中的二进制文件?

[英]How do I use binaries from Conan packages?

I'm trying build a project using Emscripten installed form the Conan center.我正在尝试使用从柯南中心安装的 Emscripten 构建一个项目。 I've been able to get it working, but I'm confused as to how I'm supposed to use the binaries for building my project.我已经能够让它工作,但我对应该如何使用二进制文件来构建我的项目感到困惑。

Here's my conanfile:这是我的柯南文件:

[requires]
libxml2/2.10.3
zlib/1.2.13
zstd/1.5.2

[generators]
cmake

And my host profile:我的主机配置文件:

[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=16
build_type=Release

[build_requires]
emsdk/3.1.23

[options]
libxml2:ftp=False
libxml2:shared=False
libxml2:threads=False
[env]

I thought I could use imports, but that didn't seem to work.我以为我可以使用进口,但这似乎不起作用。 Binaries from libxml and zstd got imported, but not anything from emsdk.来自 libxml 和 zstd 的二进制文件被导入,但没有来自 emsdk 的任何东西。

I eventually found a solution using conan info + awk:我最终使用 conan info + awk 找到了解决方案:

source $(conan info  . --package-filter emsdk/3.1.23 --paths --only "package_folder" -pr:h emscripten -pr:b default 2>/dev/null | awk ' $2 != "" {print $2}')/bin/emsdk_env.sh
export PATH=$PATH:$(conan info  . --package-filter nodejs/16.3.0 --paths --only "package_folder" -pr:h emscripten -pr:b default 2>/dev/null |  awk ' $2 != "" {print $2}')/bin

But I feel like there's got to be a simpler way that I've just missed somehow.但我觉得必须有一种我刚刚错过的更简单的方法。

I was able to use them by switching to the python config format.我能够通过切换到 python 配置格式来使用它们。

from conans import ConanFile, CMake


class SFCFEDecompress(ConanFile):
    description = ""
    license = "MIT"
    settings = {"os": ["Emscripten"]}
    exports_sources = ["./*"]
    generators = ["cmake"]

    def _configure_cmake(self):
        cmake = CMake(self)
        cmake.configure(source_folder=".")
        return cmake

    def build(self):
        cmake = self._configure_cmake()
        cmake.build()
        cmake.install()

After this I run install with my profile and then run conan build.在此之后,我使用我的配置文件运行安装,然后运行柯南构建。

Strange that this is a requirement since the txt format is supposed to be sufficient for package consumers, but c'est la vie I guess.奇怪的是,这是一项要求,因为 txt 格式应该足以满足 package 消费者的需求,但我猜这就是生活。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM