对柯南架构的困惑

Confusion about the architecture of Conan

我正在努力掌握柯南的工作原理,并学习柯南的文档。
所以到目前为止我得到的是,从客户端,客户端编写了一个 conanfile.txt 文件,其中包含一个 [requirements] 部分,其中指定了项目的所有要求。
当客户端运行时 conan install - Conan 从 ~/.conan/profiles/default 中读取客户端的设置(或者也可以通过 Conan CLI 指定另一个配置文件)并从中下载相关的二进制包与配置文件(如 OS、体系结构等)相对应的远程(假定它已不存在于本地缓存中)。

我的困惑是从制作方开始的。这是我目前得到的:为了创建一个包,你需要写一个 conanfile.py,它被称为 recipe。这个食谱描述了二进制包的构建。

docs表示conan create相当于:

$ conan export . demo/testing
$ conan install hello/0.1@demo/testing --build=hello
# package is created now, use test to test it
$ conan test test_package hello/0.1@demo/testing

有几点不明白:

  1. 客户端为什么要下载菜谱?配方不是只有创建包才需要吗?
  2. 为什么客户的配置文件包含 compiler 位?例如,我可以理解 osarch,因为 X86-Windows 客户端机器无法处理 Linux 包或 ARM 包,但为什么编译器是客户端指定配置的一部分吗?
  3. 食谱包含一行settings = "os", "compiler", "build_type", "arch"文档说:

The settings field defines the configuration of the different binary packages. In this example, we defined that any change to the OS, compiler, architecture or build type will generate a different binary package. Please note that Conan generates different binary packages for different introduced configuration (in this case settings) for the same recipe.

在哪里明确说明了在包创建过程中要构建哪些配置?

  1. conan install既用于包创建又用于包消费?

这里有一些答案:

  1. Why does the client download the recipe? Isn't the recipe needed only for the package creation?

是的,客户端下载配方,因为如果所需的包 ID 没有可用的二进制文件,则该配方将用于构建源代码。 conan-center.

中并非所有配置都可用

此外,conan install 命令中的 build options 会影响其行为。下载食谱比只下载包更方便。

此行为不会改变,因为它是柯南 1.0 的一部分,并且会破坏许多使用柯南缓存中食谱的用户。

  1. Why does a client's profile contain a compiler bit? I can understand the os and arch for example, since a X86-Windows client machine can't handle a Linux package or a ARM package, but why does a compiler is part of the configuration specified by the client?

不同的编译器提供不同的二进制文件。在 Windows 上,您可以使用 mingw 或 MSVC 中的 gcc。在 Linux 上,您可以使用 clang 或 gcc,它们大部分时间都是兼容的,但会生成不同的二进制文件,包括优化级别。此外,还有与每个编译器相关的其他重要标志,例如 libcxx(libstdc++、libc++、libstdc++11)或 MSVC 运行时(MT、MD)。部分编译器版本只支持C++11(GCC 4.9),所以在构建工程时一定要确定编译器的兼容性。基本上,它会影响 ABI compatibility.

where is it specified exactly which configurations to build in the package creation process?

包生成已记录,请阅读:

  1. conan install is used both for package creation and both for package consuming?

如果你想开发一个新的简单配方,在你的机器上构建并使用,所以 conan create 就是这样。您将使用 conan create for 90% of cases when creating a new recipe. You can read Development flow with Conan Create 部分了解更多信息。

另一方面,conan install主要用于包消费,但也可用于包创建。什么时候?

  • Development flow
  • 当你想安装一个包,但你也想从源代码构建它时。

背后的原因是因为 conan install 先出现,它被用于两个提议,但我们需要更直接的包创建,所以引入了 conan create。但是,由于向后兼容规则,我们无法删除功能,conan install 仍然可以用作包创建者。