From 621e2ad44784d3e3f509d1ef15c568695354c048 Mon Sep 17 00:00:00 2001 From: memsharded Date: Mon, 2 Dec 2024 15:46:38 +0100 Subject: [PATCH] conan config install-pkg with profile, settings --- reference/commands/config.rst | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/reference/commands/config.rst b/reference/commands/config.rst index 81ac029ad8b4..81f0ac8546ff 100644 --- a/reference/commands/config.rst +++ b/reference/commands/config.rst @@ -161,6 +161,54 @@ or it can download from a Conan remote directly specifying the repository URL: $ conan config install-pkg myconf/version --url= +Conan configuration packages can also be parameterized depending on profiles, settings and options. +For example, if some organization would like to manage their configuration slightly differently for Windows and other platforms they could do: + +.. code-block:: python + + import os + from conan import ConanFile + from conan.tools.files import copy + + class Conf(ConanFile): + name = "myconf" + version = "0.1" + settings = "os" + package_type = "configuration" + def package(self): + f = "win" if self.settings.os == "Windows" else "nix" + copy(self, "*.conf", src=os.path.join(self.build_folder, f), dst=self.package_folder) + + +And if they had a layout with different ``global.conf`` for the different platforms, like: + +.. code-block:: text + + conanfile.py + win/global.conf + nix/global.conf + + +They, they could create and upload their configuration package as: + +.. code-block:: bash + + $ conan export-pkg . -s os=Windows + $ conan export-pkg . -s os=Linux + $ conan upload "*" -r=remote -c + + +Then, developers could do: + +.. code-block:: bash + + $ conan config install-pkg "myconf/[*]" -s os=Linux + # or even implicitly, if they default build profile defines os=Linux + $ conan config install-pkg "myconf/[*]" + + +And they will get the correct configuration for their platform. + conan config list -----------------