From 78fe040aa6f5f6a3b09ff919167cbef22bc43e3a Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 09:54:34 +0200 Subject: [PATCH 01/14] (#23610) aaf: use expat version range --- recipes/aaf/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/aaf/all/conanfile.py b/recipes/aaf/all/conanfile.py index ee7906ff05936..471ea8132e2ce 100644 --- a/recipes/aaf/all/conanfile.py +++ b/recipes/aaf/all/conanfile.py @@ -35,7 +35,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("expat/2.5.0") + self.requires("expat/[>=2.6.2 <3]") self.requires("libjpeg/9e") if self.settings.os in ("FreeBSD", "Linux"): self.requires("util-linux-libuuid/2.39") From 5deb787af418b4397837296eeb0db8a1e86e0e62 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 10:28:57 +0200 Subject: [PATCH 02/14] (#23608) exiv2: use expat version range --- recipes/exiv2/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/exiv2/all/conanfile.py b/recipes/exiv2/all/conanfile.py index e0f3dda5c9ab6..749096cccd372 100644 --- a/recipes/exiv2/all/conanfile.py +++ b/recipes/exiv2/all/conanfile.py @@ -76,7 +76,7 @@ def requirements(self): self.requires("libpng/[>=1.6 <2]") self.requires("zlib/[>=1.2.11 <2]") if self.options.with_xmp == "bundled": - self.requires("expat/2.5.0") + self.requires("expat/[>=2.6.2 <3]") if self.options.with_curl: self.requires("libcurl/[>=7.78.0 <9]") if self.options.get_safe("with_brotli"): From 11d737760e81793999df766889424882fa9c6aa3 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 10:41:16 +0200 Subject: [PATCH 03/14] (#23609) jsbsim: use expat version range --- recipes/jsbsim/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/jsbsim/all/conanfile.py b/recipes/jsbsim/all/conanfile.py index 3d180281b5649..048e4a19a18e0 100644 --- a/recipes/jsbsim/all/conanfile.py +++ b/recipes/jsbsim/all/conanfile.py @@ -48,7 +48,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("expat/2.5.0") + self.requires("expat/[>=2.6.2 <3]") def validate(self): if self.settings.compiler.get_safe("cppstd"): From 6ed4bf63c5b2b9dd7a4199c04ab8cfa9be38802f Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 10:54:48 +0200 Subject: [PATCH 04/14] (#23611) apr-util: use expat version range --- recipes/apr-util/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/apr-util/all/conanfile.py b/recipes/apr-util/all/conanfile.py index ed635923b1c3a..92e0be4b1f040 100644 --- a/recipes/apr-util/all/conanfile.py +++ b/recipes/apr-util/all/conanfile.py @@ -90,7 +90,7 @@ def requirements(self): if self.options.with_sqlite3: self.requires("sqlite3/3.45.0") if self.options.with_expat: - self.requires("expat/2.5.0") + self.requires("expat/[>=2.6.2 <3]") if self.options.with_postgresql: self.requires("libpq/15.4") From dbc68b71b6a84ee66db2c134e7a22913e6d51736 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 11:11:10 +0200 Subject: [PATCH 05/14] (#23613) libmetalink: use version range for expat & libxml2 --- recipes/libmetalink/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libmetalink/all/conanfile.py b/recipes/libmetalink/all/conanfile.py index 10c23cc875879..57b9b280bec17 100644 --- a/recipes/libmetalink/all/conanfile.py +++ b/recipes/libmetalink/all/conanfile.py @@ -53,9 +53,9 @@ def layout(self): def requirements(self): if self.options.xml_backend == "expat": - self.requires("expat/2.5.0") + self.requires("expat/[>=2.6.2 <3]") elif self.options.xml_backend == "libxml2": - self.requires("libxml2/2.12.3") + self.requires("libxml2/[>=2.12.5 <3]") def validate(self): if is_msvc(self): From 85854290b51c1bb754e672bd2884e08814206750 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 11:24:51 +0200 Subject: [PATCH 06/14] (#23617) xlsxio: use version range for expat --- recipes/xlsxio/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/xlsxio/all/conanfile.py b/recipes/xlsxio/all/conanfile.py index 7724a07d64464..ed6652c07a361 100644 --- a/recipes/xlsxio/all/conanfile.py +++ b/recipes/xlsxio/all/conanfile.py @@ -62,7 +62,7 @@ def requirements(self): self.requires("minizip-ng/4.0.1") else: self.requires("minizip/1.2.13") - self.requires("expat/2.5.0") + self.requires("expat/[>=2.6.2 <3]") def validate(self): if Version(self.version) >= "0.2.34": From 14a1c86d8d0603294cd0f70c40bc8c3c944210c9 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 16:54:27 +0200 Subject: [PATCH 07/14] (#23623) libarchive: use version range for libxml2 --- recipes/libarchive/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libarchive/all/conanfile.py b/recipes/libarchive/all/conanfile.py index f83e7f6e3413d..c68aabe657d31 100644 --- a/recipes/libarchive/all/conanfile.py +++ b/recipes/libarchive/all/conanfile.py @@ -87,7 +87,7 @@ def requirements(self): if self.options.with_bzip2: self.requires("bzip2/1.0.8") if self.options.with_libxml2: - self.requires("libxml2/2.12.5") + self.requires("libxml2/[>=2.12.5 <3]") if self.options.with_expat: self.requires("expat/[>=2.6.2 <3]") if self.options.with_iconv: From ab622e0f22627c2d765cba0b90e520e3fbd16f14 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 17:13:20 +0200 Subject: [PATCH 08/14] (#23627) hwloc: use version range for libxml2 --- recipes/hwloc/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/hwloc/all/conanfile.py b/recipes/hwloc/all/conanfile.py index 231701d41f587..ff20e76545dae 100644 --- a/recipes/hwloc/all/conanfile.py +++ b/recipes/hwloc/all/conanfile.py @@ -32,7 +32,7 @@ def configure(self): def requirements(self): if self.options.with_libxml2: - self.requires("libxml2/2.12.3") + self.requires("libxml2/[>=2.12.5 <3]") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From 2f5627cff08fab4f3ddbeee2d5ecae7224d7796c Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 18 Apr 2024 17:26:21 +0200 Subject: [PATCH 09/14] (#23628) norm: use version range for libxml2 --- recipes/norm/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/norm/all/conanfile.py b/recipes/norm/all/conanfile.py index 06df6975769c2..3d4877a41e642 100644 --- a/recipes/norm/all/conanfile.py +++ b/recipes/norm/all/conanfile.py @@ -39,7 +39,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("libxml2/2.12.3") # dependency of protolib actually + self.requires("libxml2/[>=2.12.5 <3]") # dependency of protolib actually def source(self): get(self, **self.conan_data["sources"][self.version]) From cc08e2ff73aa6720f1c7a1825873cf0d355d7297 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Thu, 18 Apr 2024 17:43:17 +0200 Subject: [PATCH 10/14] (#23636) xkbcommon: fix conflict with wayland since https://github.com/conan-io/conan-center-index/commit/3264e15a2117e10f4d286d033876d4bc800e47ff#diff-5c99ca1cb44d19a32c9f1373d8effc9125f8e1b094489ef02ee1cf755feb82f7R53 --- recipes/xkbcommon/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/xkbcommon/all/conanfile.py b/recipes/xkbcommon/all/conanfile.py index 6c59c78b63932..cc9c77df8e95f 100644 --- a/recipes/xkbcommon/all/conanfile.py +++ b/recipes/xkbcommon/all/conanfile.py @@ -66,7 +66,7 @@ def requirements(self): if self.options.with_x11: self.requires("xorg/system") if self.options.get_safe("xkbregistry"): - self.requires("libxml2/2.12.3") + self.requires("libxml2/[>=2.12.5 <3]") if self.options.get_safe("with_wayland"): self.requires("wayland/1.22.0") From 156d3592a823c0d3d297d8c365eee01f27532a49 Mon Sep 17 00:00:00 2001 From: yhsng <153517809+yhsng@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:24:26 +0200 Subject: [PATCH 11/14] (#23491) minizip-ng: add missing system dependencies --- recipes/minizip-ng/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/minizip-ng/all/conanfile.py b/recipes/minizip-ng/all/conanfile.py index 7d26ebb7bc61f..6185768b2d0c8 100644 --- a/recipes/minizip-ng/all/conanfile.py +++ b/recipes/minizip-ng/all/conanfile.py @@ -197,6 +197,8 @@ def package_info(self): self.cpp_info.components["minizip"].requires.append("openssl::openssl") elif is_apple_os(self): self.cpp_info.components["minizip"].frameworks.extend(["CoreFoundation", "Security"]) + elif self.settings.os == "Windows": + self.cpp_info.components["minizip"].system_libs.append("crypt32") if self.settings.os != "Windows" and self.options.with_iconv: self.cpp_info.components["minizip"].requires.append("libiconv::libiconv") From 2c8bcee56b6ffaafacef63ba72d8d0f9a9bc9b3c Mon Sep 17 00:00:00 2001 From: Vladimir Shaleev Date: Fri, 19 Apr 2024 03:07:28 +0300 Subject: [PATCH 12/14] (#23206) ipaddress: add recipe * ipaddress: add recipe * Improved readability and template compliance from package_templates in conanfile.py * Compiling a test package using C++11 * Target compile features cxx_std_11 --- recipes/ipaddress/all/conandata.yml | 4 + recipes/ipaddress/all/conanfile.py | 89 +++++++++++++++++++ .../ipaddress/all/test_package/CMakeLists.txt | 8 ++ .../ipaddress/all/test_package/conanfile.py | 26 ++++++ .../all/test_package/test_package.cpp | 11 +++ recipes/ipaddress/config.yml | 3 + 6 files changed, 141 insertions(+) create mode 100644 recipes/ipaddress/all/conandata.yml create mode 100644 recipes/ipaddress/all/conanfile.py create mode 100644 recipes/ipaddress/all/test_package/CMakeLists.txt create mode 100644 recipes/ipaddress/all/test_package/conanfile.py create mode 100644 recipes/ipaddress/all/test_package/test_package.cpp create mode 100644 recipes/ipaddress/config.yml diff --git a/recipes/ipaddress/all/conandata.yml b/recipes/ipaddress/all/conandata.yml new file mode 100644 index 0000000000000..05cfe6de06df9 --- /dev/null +++ b/recipes/ipaddress/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.1": + url: "https://github.com/VladimirShaleev/ipaddress/archive/v1.0.1.tar.gz" + sha256: "49c16294f06fe95ffc66cae828dc08d116efb4a1ede3dddd21dcc182a2eceb03" diff --git a/recipes/ipaddress/all/conanfile.py b/recipes/ipaddress/all/conanfile.py new file mode 100644 index 0000000000000..1bdda098db7d5 --- /dev/null +++ b/recipes/ipaddress/all/conanfile.py @@ -0,0 +1,89 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + + +required_conan_version = ">=1.52.0" + + +class IpAddressConan(ConanFile): + name = "ipaddress" + description = "A library for working and manipulating IPv4/IPv6 addresses and networks" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/VladimirShaleev/ipaddress" + topics = ("ipv4", "ipv6", "ipaddress", "ip", "network", "header-only") + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + options = { + "exceptions": [True, False], + "overload_std": [True, False], + "ipv6_scope": [True, False], + "ipv6_scope_max_length": ["ANY"], + } + default_options = { + "exceptions": True, + "overload_std": True, + "ipv6_scope": True, + "ipv6_scope_max_length": 16, + } + + @property + def _min_cppstd(self): + return 11 + + @property + def _compilers_minimum_version(self): + return { + "apple-clang": "13.0", + "clang": "6.0", + "gcc": "7.5", + "msvc": "192", + "Visual Studio": "16", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} doesn't support {self.settings.compiler} < {minimum_version}" + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy( + self, + "*.hpp", + os.path.join(self.source_folder, "include"), + os.path.join(self.package_folder, "include") + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + if not self.options.exceptions: + self.cpp_info.defines.append("IPADDRESS_NO_EXCEPTIONS") + if not self.options.overload_std: + self.cpp_info.defines.append("IPADDRESS_NO_OVERLOAD_STD") + if not self.options.ipv6_scope: + self.cpp_info.defines.append("IPADDRESS_NO_IPV6_SCOPE") + else: + self.cpp_info.defines.append(f"IPADDRESS_IPV6_SCOPE_MAX_LENGTH={int(self.options.ipv6_scope_max_length)}") diff --git a/recipes/ipaddress/all/test_package/CMakeLists.txt b/recipes/ipaddress/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f9368cb4ca108 --- /dev/null +++ b/recipes/ipaddress/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(ipaddress CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ipaddress::ipaddress) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ipaddress/all/test_package/conanfile.py b/recipes/ipaddress/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a91c9439218e --- /dev/null +++ b/recipes/ipaddress/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ipaddress/all/test_package/test_package.cpp b/recipes/ipaddress/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..1e0a4a4597eaf --- /dev/null +++ b/recipes/ipaddress/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "ipaddress/ipaddress.hpp" + + +int main(void) { + auto ip = ipaddress::ipv6_address::parse("fec0::1ff:fe23:4567:890a%eth2"); + std::cout << "Parsing ipv6: " << ip << std::endl; + + return EXIT_SUCCESS; +} diff --git a/recipes/ipaddress/config.yml b/recipes/ipaddress/config.yml new file mode 100644 index 0000000000000..715e55357a17b --- /dev/null +++ b/recipes/ipaddress/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.1": + folder: all From ddd25f95598ed991993a71f9ad138fb2d1c902da Mon Sep 17 00:00:00 2001 From: Carlos Zoido Date: Fri, 19 Apr 2024 02:17:12 +0200 Subject: [PATCH 13/14] (#23644) Remove `os.version` from package ID and also removing `no_copy_source = True` in openjdk recipe * remove os.version from package ID * remove no_copy_source * fix recipe --- recipes/openjdk/all/conanfile.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/recipes/openjdk/all/conanfile.py b/recipes/openjdk/all/conanfile.py index 9da58ed44e05f..33d8977b70cc4 100644 --- a/recipes/openjdk/all/conanfile.py +++ b/recipes/openjdk/all/conanfile.py @@ -16,12 +16,14 @@ class OpenJDK(ConanFile): license = "GPL-2.0-only WITH Classpath-exception-2.0", "GPL-2.0-only WITH OpenJDK-assembly-exception-1.0" topics = ("java", "jdk", "openjdk") settings = "os", "arch", "compiler", "build_type" - no_copy_source = True def package_id(self): del self.info.settings.compiler del self.info.settings.build_type + def configure(self): + self.settings.rm_safe("os.version") + def validate(self): if Version(self.version) < "19.0.2" and self.settings.arch != "x86_64": raise ConanInvalidConfiguration("Unsupported Architecture. This package currently only supports x86_64.") @@ -33,35 +35,35 @@ def build(self): if self.settings.os in ["Macos", "Linux"]: key = f"{self.settings.os}_{self.settings.arch}" get(self, **self.conan_data["sources"][self.version][str(key)], - destination=self.source_folder, strip_root=True) + destination=self.build_folder, strip_root=True) def package(self): if self.settings.os == "Macos": - source_folder = os.path.join(self.source_folder, f"jdk-{self.version}.jdk", "Contents", "Home") + build_folder = os.path.join(self.build_folder, f"jdk-{self.version}.jdk", "Contents", "Home") else: - source_folder = self.source_folder - symlinks.remove_broken_symlinks(self, source_folder) + build_folder = self.build_folder + symlinks.remove_broken_symlinks(self, build_folder) copy(self, pattern="*", - src=os.path.join(source_folder, "bin"), + src=os.path.join(build_folder, "bin"), dst=os.path.join(self.package_folder, "bin"), excludes=("msvcp140.dll", "vcruntime140.dll", "vcruntime140_1.dll")) copy(self, pattern="*", - src=os.path.join(source_folder, "include"), + src=os.path.join(build_folder, "include"), dst=os.path.join(self.package_folder, "include")) copy(self, pattern="*", - src=os.path.join(source_folder, "lib"), + src=os.path.join(build_folder, "lib"), dst=os.path.join(self.package_folder, "lib")) copy(self, pattern="*", - src=os.path.join(source_folder, "jmods"), + src=os.path.join(build_folder, "jmods"), dst=os.path.join(self.package_folder, "lib", "jmods")) copy(self, pattern="*", - src=os.path.join(source_folder, "legal"), + src=os.path.join(build_folder, "legal"), dst=os.path.join(self.package_folder, "licenses")) # conf folder is required for security settings, to avoid # java.lang.SecurityException: Can't read cryptographic policy directory: unlimited # https://github.com/conan-io/conan-center-index/pull/4491#issuecomment-774555069 copy(self, pattern="*", - src=os.path.join(source_folder, "conf"), + src=os.path.join(build_folder, "conf"), dst=os.path.join(self.package_folder, "conf")) def package_info(self): From b547df8527ded145ca7afcd04b9ce2243bf8d98b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 19 Apr 2024 03:32:08 +0300 Subject: [PATCH 14/14] (#18641) libidn: migrate to Conan v2, add shared MSVC build support * libidn: migrate to Conan v2 * libidn: fix MSVC build * libidn: --disable-csharp * libidn: fix shared lib not being found in v1 * libidn: fix MSVC build, add shared MSVC build support * libidn: tc.extra_cflags.append("-FS") --- recipes/libidn/all/conandata.yml | 1 - recipes/libidn/all/conanfile.py | 180 ++++++++++-------- .../libidn/all/test_package/CMakeLists.txt | 7 +- recipes/libidn/all/test_package/conanfile.py | 24 ++- .../libidn/all/test_v1_package/CMakeLists.txt | 8 + .../libidn/all/test_v1_package/conanfile.py | 19 ++ 6 files changed, 150 insertions(+), 89 deletions(-) create mode 100644 recipes/libidn/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/libidn/all/test_v1_package/conanfile.py diff --git a/recipes/libidn/all/conandata.yml b/recipes/libidn/all/conandata.yml index 8be8baf6f09f3..fcb454914799b 100644 --- a/recipes/libidn/all/conandata.yml +++ b/recipes/libidn/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "1.36": - patch_file: "patches/0001-unconditional-system-stdint-h.patch" - base_path: "source_subfolder" diff --git a/recipes/libidn/all/conanfile.py b/recipes/libidn/all/conanfile.py index 49221670d5e8e..2512e8efab52b 100644 --- a/recipes/libidn/all/conanfile.py +++ b/recipes/libidn/all/conanfile.py @@ -1,13 +1,14 @@ -from conan import ConanFile -from conan.errors import ConanInvalidConfiguration -from conan.tools.files import get, rmdir -from conan.tools.scm import Version -from conans import AutoToolsBuildEnvironment, tools -import contextlib -import functools import os -required_conan_version = ">=1.33.0" +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv, Environment +from conan.tools.files import get, rmdir, export_conandata_patches, apply_conandata_patches, copy, replace_in_file, rm, save +from conan.tools.gnu import AutotoolsToolchain, Autotools, AutotoolsDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import unix_path, is_msvc + +required_conan_version = ">=1.53.0" class LibIdnConan(ConanFile): @@ -17,6 +18,8 @@ class LibIdnConan(ConanFile): topics = ("libidn", "encode", "decode", "internationalized", "domain", "name") license = "GPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" + + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -29,17 +32,12 @@ class LibIdnConan(ConanFile): "threads": True, } - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _settings_build(self): return getattr(self, "settings_build", self.settings) def export_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -47,91 +45,120 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): self.requires("libiconv/1.17") - def validate(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Shared libraries are not supported on Windows due to libtool limitation") - def build_requirements(self): - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") - if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.5") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") def source(self): - get(self, **self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - @contextlib.contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self): - env = { - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), - } - with tools.environment_append(env): - yield - else: - yield + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") - @functools.lru_cache(1) - def _configure_autotools(self): - autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - autotools.libs = [] + tc = AutotoolsToolchain(self) if not self.options.shared: - autotools.defines.append("LIBIDN_STATIC") - if self.settings.compiler == "Visual Studio": - if Version(self.settings.compiler.version) >= "12": - autotools.flags.append("-FS") - autotools.link_flags.extend("-L{}".format(p.replace("\\", "/")) for p in self.deps_cpp_info.lib_paths) + tc.extra_defines.append("LIBIDN_STATIC") yes_no = lambda v: "yes" if v else "no" - conf_args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), + tc.configure_args += [ "--enable-threads={}".format(yes_no(self.options.threads)), - "--with-libiconv-prefix={}".format(tools.unix_path(self.deps_cpp_info["libiconv"].rootpath)), + "--with-libiconv-prefix={}".format(unix_path(self, self.dependencies["libiconv"].package_folder)), + "--disable-csharp", "--disable-nls", "--disable-rpath", ] - autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return autotools - - def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self.settings.compiler == "Visual Studio": + if is_msvc(self): + tc.extra_cflags.append("-FS") + tc.extra_cxxflags.append("-FS") + tc.generate() + + if is_msvc(self): + env = Environment() + dep_info = self.dependencies["libiconv"].cpp_info.aggregated_components() + env.append("CPPFLAGS", [f"-I{unix_path(self, p)}" for p in dep_info.includedirs] + [f"-D{d}" for d in dep_info.defines]) + env.append("_LINK_", [lib if lib.endswith(".lib") else f"{lib}.lib" for lib in (dep_info.libs + dep_info.system_libs)]) + env.append("LDFLAGS", [f"-L{unix_path(self, p)}" for p in dep_info.libdirs] + dep_info.sharedlinkflags + dep_info.exelinkflags) + env.append("CFLAGS", dep_info.cflags) + env.vars(self).save_script("conanautotoolsdeps_cl_workaround") + else: + deps = AutotoolsDeps(self) + deps.generate() + + if is_msvc(self): + env = Environment() + automake_conf = self.dependencies.build["automake"].conf_info + compile_wrapper = unix_path(self, automake_conf.get("user.automake:compile-wrapper", check_type=str)) + ar_wrapper = unix_path(self, automake_conf.get("user.automake:lib-wrapper", check_type=str)) + # Workaround for iconv.lib not being found due to linker flag order + libiconv_libdir = unix_path(self, self.dependencies["libiconv"].cpp_info.aggregated_components().libdir) + env.define("CC", f"{compile_wrapper} cl -nologo -L{libiconv_libdir}") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f'{ar_wrapper} lib') + env.vars(self).save_script("conanbuild_msvc") + + def _patch_sources(self): + apply_conandata_patches(self) + # Disable examples and tests + for subdir in ["examples", "tests", "fuzz", "gltests", os.path.join("lib", "gltests"), "doc"]: + save(self, os.path.join(self.source_folder, subdir, "Makefile.in"), "all:\ninstall:\n") + + if is_msvc(self): if self.settings.arch in ("x86_64", "armv8", "armv8.3"): ssize = "signed long long int" else: ssize = "signed long int" - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "stringprep.h"), - "ssize_t", ssize) - with self._build_context(): - autotools = self._configure_autotools() - autotools.make(args=["V=1"]) + replace_in_file(self, os.path.join(self.source_folder, "lib", "stringprep.h"), "ssize_t", ssize) - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() + if self.settings.os == "Windows": + # Otherwise tries to create a symlink from GNUmakefile to itself, which fails on Windows + replace_in_file(self, os.path.join(self.source_folder, "configure"), + '"$GNUmakefile") CONFIG_LINKS="$CONFIG_LINKS $GNUmakefile:$GNUmakefile" ;;', "") + replace_in_file(self, os.path.join(self.source_folder, "configure"), + 'ac_config_links="$ac_config_links $GNUmakefile:$GNUmakefile"', "") + def build(self): + self._patch_sources() + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rmdir(self, os.path.join(self.package_folder, "share")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) + + if is_msvc(self) and self.options.shared: + os.rename(os.path.join(self.package_folder, "lib", "idn.dll.lib"), + os.path.join(self.package_folder, "lib", "idn-12.lib")) def package_info(self): - self.cpp_info.libs = ["idn"] - self.cpp_info.names["pkg_config"] = "libidn" + if is_msvc(self) and self.options.shared: + self.cpp_info.libs = ["idn-12"] + else: + self.cpp_info.libs = ["idn"] + self.cpp_info.set_property("pkg_config_name", "libidn") if self.settings.os in ["Linux", "FreeBSD"]: if self.options.threads: self.cpp_info.system_libs = ["pthread"] @@ -139,7 +166,6 @@ def package_info(self): if not self.options.shared: self.cpp_info.defines = ["LIBIDN_STATIC"] + # TODO: to remove in conan v2 bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) - diff --git a/recipes/libidn/all/test_package/CMakeLists.txt b/recipes/libidn/all/test_package/CMakeLists.txt index 7b9b613cbb24a..3482998466c6b 100644 --- a/recipes/libidn/all/test_package/CMakeLists.txt +++ b/recipes/libidn/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.15) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libidn REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libidn::libidn) diff --git a/recipes/libidn/all/test_package/conanfile.py b/recipes/libidn/all/test_package/conanfile.py index 07c965844de9b..441cef7471a37 100644 --- a/recipes/libidn/all/test_package/conanfile.py +++ b/recipes/libidn/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str, run=True) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,8 +22,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - self.run("idn --help", run_environment=True) + if can_run(self): + self.run("idn --help", env="conanrun") - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libidn/all/test_v1_package/CMakeLists.txt b/recipes/libidn/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/libidn/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libidn/all/test_v1_package/conanfile.py b/recipes/libidn/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..3eaa9f0102538 --- /dev/null +++ b/recipes/libidn/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run("idn --help", run_environment=True) + + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True)