Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getdns: migrate to Conan v2, bump to v1.7.3 #21389

Merged
merged 24 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
46b3060
getdns: migrate to Conan v2
valgur Jul 20, 2023
3dafbfd
getdns: bump deps
valgur Aug 7, 2023
609a7da
getdns: bump to 1.7.3, finish migration
valgur Nov 26, 2023
32b2b65
getdns: temporarily disable libidn2
valgur Nov 26, 2023
e9130ab
getdns: bump cmake, remove pkg-config
valgur Nov 26, 2023
16a1698
getdns: check that OpenSSL configuration has not failed
valgur Nov 27, 2023
d2c9cf9
getdns: don't need to use cache_variables
valgur Jan 20, 2024
fdd69db
getdns: temporarily print detailed CMake logs
valgur Jan 20, 2024
6efa45c
getdns: add Windows system libs
valgur Jan 20, 2024
0b79b1a
getdns: set CMAKE_TRY_COMPILE_CONFIGURATION
valgur Jan 20, 2024
3550524
getdns: fix Windows build
valgur Jan 20, 2024
3bc0884
getdns: disable libidn2 for now
valgur Jan 23, 2024
4da074a
getdns: fix Windows build
valgur Mar 22, 2024
43b3fc8
Use CMAKE_PROJECT_INCLUDE
uilianries Sep 5, 2024
6ed7302
Avoid capturing network on test package
uilianries Sep 5, 2024
163e933
Remove option for gnutls
uilianries Sep 5, 2024
c4d999b
Remove stub option
uilianries Sep 5, 2024
53c2c75
Enable libidn2 by default
uilianries Sep 5, 2024
577421b
ignore incompatible pointer type
uilianries Sep 5, 2024
15f13a4
Import libidn2 defines
uilianries Sep 5, 2024
6b548ee
Make CMaktoolchain compatible to Conan 1.x
uilianries Sep 6, 2024
8a7ab17
Merge branch 'master' of https://github.com/conan-io/conan-center-ind…
uilianries Sep 6, 2024
2d4af44
Inject libidn2 defines to executables
uilianries Sep 6, 2024
6092f1d
Add todo comment for future refactor
uilianries Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions recipes/getdns/all/CMakeLists.txt

This file was deleted.

29 changes: 29 additions & 0 deletions recipes/getdns/all/conan_deps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.15)
project(cmake_wrapper)

# Wrapper for find_package() that sets variables in the format expected by the project
macro(custom_find_package name)
find_package(${name} REQUIRED CONFIG
# Allow only Conan packages
NO_DEFAULT_PATH
PATHS ${CMAKE_PREFIX_PATH}
)
string(TOUPPER ${name} name_upper)
set(${name_upper}_FOUND TRUE)
set(${name_upper}_INCLUDE_DIR ${${name}_INCLUDE_DIR})
set(${name_upper}_LIBRARIES ${${name}_LIBRARIES})
endmacro()

custom_find_package(OpenSSL)
if(BUILD_LIBEV)
custom_find_package(Libev)
endif()
if(BUILD_LIBEVENT2)
custom_find_package(Libevent2)
endif()
if(BUILD_LIBUV)
custom_find_package(Libuv)
endif()
if(USE_LIBIDN2)
custom_find_package(Libidn2)
endif()
19 changes: 8 additions & 11 deletions recipes/getdns/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
sources:
"1.6.0":
url: "https://getdnsapi.net/dist/getdns-1.6.0.tar.gz"
sha256: "40e5737471a3902ba8304b0fd63aa7c95802f66ebbc6eae53c487c8e8a380f4a"
"1.7.3":
url: "https://getdnsapi.net/dist/getdns-1.7.3.tar.gz"
sha256: "f1404ca250f02e37a118aa00cf0ec2cbe11896e060c6d369c6761baea7d55a2c"
patches:
"1.6.0":
- patch_file: "patches/1.6.0-0001-install-runtimes.patch"
base_path: "source_subfolder"
"1.7.3":
- patch_file: "patches/1.6.0-0002-fix-exports-extension-libraries.patch"
base_path: "source_subfolder"
- patch_file: "patches/1.6.0-0003-let-find-modules-use-pkgconfig.patch"
base_path: "source_subfolder"
- patch_file: "patches/1.6.0-0004-dont-install-symlinked-license.patch"
base_path: "source_subfolder"
- patch_file: "patches/1.7.3-fix-windows-build.patch"
patch_description: "Fix Windows build"
patch_source: "https://github.com/getdnsapi/getdns/pull/538"
patch_type: "portability"
204 changes: 99 additions & 105 deletions recipes/getdns/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,170 +1,164 @@
from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import glob
import os

from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, rm
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.53.0"


class GetDnsConan(ConanFile):
name = "getdns"
description = "A modern asynchronous DNS API"
topics = "conan", "getdns", "asynchronous", "event"
license = "BSD-3-Clause"
homepage = "https://getdnsapi.net/"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://getdnsapi.net/"
topics = ("dns", "asynchronous", "event")

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
exports_sources = "CMakeLists.txt", "patches/**"
options = {
"shared": [True, False],
"fPIC": [True, False],
"tls": [False, "gnutls"],
"stub_only": ["auto", True, False],
"with_libev": ["auto", True, False],
"with_libev": [True, False],
"with_libevent": [True, False],
"with_libuv": [True, False],
"with_libidn2": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"stub_only": "auto",
"tls": False,
"with_libev": "auto",
"with_libev": True,
"with_libevent": True,
"with_libuv": True,
"with_libidn2": True,
"with_libidn2": True
}
generators = "cmake", "pkg_config", "cmake_find_package"

_cmake = None

@property
def _with_libev(self):
if self.options.with_libev == "auto":
return self.settings.os != "Windows"
else:
return self.options.with_libev

@property
def _stub_only(self):
if self.options.stub_only == "auto":
# FIXME: uncomment the next line when libunbound is available
# return self.settings.os == "Windows"
return True
else:
return self.options.stub_only

@property
def _source_subfolder(self):
return "source_subfolder"

def export_sources(self):
export_conandata_patches(self)
copy(self, "conan_deps.cmake", src=self.recipe_folder, dst=os.path.join(self.export_sources_folder, "src"))

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

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):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("openssl/1.1.1j")
if self._with_libev:
self.requires("openssl/[>=1.1 <4]")
if self.options.with_libev:
self.requires("libev/4.33")
if self.options.with_libevent:
self.requires("libevent/2.1.12")
if self.options.with_libuv:
self.requires("libuv/1.41.0")
self.requires("libuv/1.48.0")
if self.options.with_libidn2:
self.requires("libidn2/2.3.0")
if self.options.tls == "gnutls":
self.requires("nettle/3.6")
# FIXME: missing gnutls recipe
raise ConanInvalidConfiguration("gnutls is not (yet) available on cci")
if not self._stub_only:
# FIXME: missing libunbound recipe
raise ConanInvalidConfiguration("libunbound is not (yet) available on cci")

def build_requirements(self):
self.build_requires("pkgconf/1.7.3")
self.tool_requires("cmake/[>=3.20 <4]")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("getdns-{}".format(self.version), self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["OPENSSL_USE_STATIC_LIBS"] = not self.options["openssl"].shared
self._cmake.definitions["ENABLE_SHARED"] = self.options.shared
self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared
self._cmake.definitions["ENABLE_STUB_ONLY"] = self._stub_only
self._cmake.definitions["BUILD_LIBEV"] = self._with_libev
self._cmake.definitions["BUILD_LIBEVENT2"] = self.options.with_libevent
self._cmake.definitions["BUILD_LIBUV"] = self.options.with_libuv
self._cmake.definitions["USE_LIBIDN2"] = self.options.with_libidn2
self._cmake.definitions["USE_GNUTLS"] = self.options.tls == "gnutls"
self._cmake.definitions["BUILD_TESTING"] = False

self._cmake.configure()
return self._cmake
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
VirtualBuildEnv(self).generate()

tc = CMakeToolchain(self)
tc.variables["CMAKE_PROJECT_getdns_INCLUDE"] = "conan_deps.cmake"
tc.variables["OPENSSL_USE_STATIC_LIBS"] = not self.dependencies["openssl"].options.shared
tc.variables["ENABLE_SHARED"] = self.options.shared
tc.variables["ENABLE_STATIC"] = not self.options.shared
# INFO: Disabling stub-only requires libunbound
tc.variables["ENABLE_STUB_ONLY"] = True
tc.variables["BUILD_LIBEV"] = self.options.with_libev
tc.variables["BUILD_LIBEVENT2"] = self.options.with_libevent
tc.variables["BUILD_LIBUV"] = self.options.with_libuv
tc.variables["USE_LIBIDN2"] = self.options.with_libidn2
# INFO: GnuTLS requires libdane support and is not supported by MSVC
tc.variables["USE_GNUTLS"] = False
# Force use of internal strptime when cross-compiling
tc.variables["FORCE_COMPAT_STRPTIME"] = True
tc.variables["BUILD_TESTING"] = False
# To fix OpenSSL try_compile() checks
# https://github.com/conan-io/conan/issues/12180
tc.variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type)
if self.settings.compiler in ["clang", "apple-clang"]:
# INFO: https://github.com/getdnsapi/getdns/issues/544
# TODO: Change to extra_clfags when CCI only uses Conan 2.x
tc.blocks["cmake_flags_init"].template += '\nstring(APPEND CMAKE_C_FLAGS_INIT " -Wno-incompatible-function-pointer-types")'
if self.options.with_libidn2 and is_msvc(self):
# INFO: getdns_static.lib(convert.c.obj): error LNK2019: unresolved external symbol __imp_idn2_lookup_u8
tc.preprocessor_definitions.update({it: 1 for it in self.dependencies["libidn2"].cpp_info.defines})
tc.generate()

deps = CMakeDeps(self)
deps.set_property("libev", "cmake_file_name", "Libev")
deps.set_property("libev", "cmake_target_name", "Libev::Libev")
deps.set_property("libevent", "cmake_file_name", "Libevent2")
deps.set_property("libevent::core", "cmake_target_name", "Libevent2::Libevent_core")
deps.set_property("libidn2", "cmake_file_name", "Libidn2")
deps.set_property("libidn2", "cmake_target_name", "Libidn2::Libidn2")
deps.set_property("libuv", "cmake_file_name", "Libuv")
deps.set_property("libuv", "cmake_target_name", "Libuv::Libuv")
deps.generate()

def _patch_sources(self):
apply_conandata_patches(self)
rm(self, "Find*.cmake", os.path.join(self.source_folder, "cmake", "modules"))

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
# Use FindOpenSSL.cmake to let check_function_exists succeed
# Remove other cmake modules as they use FindPkgConfig
for fn in glob.glob("Find*cmake"):
if "OpenSSL" not in fn:
os.unlink(fn)
cmake = self._configure_cmake()
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_id(self):
self.info.options.stub_only = self._stub_only
self.info.options.with_libev = self._with_libev
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
libsuffix = ""
if self.settings.compiler == "Visual Studio" and not self.options.shared:
if is_msvc(self) and not self.options.shared:
libsuffix = "_static"

self.cpp_info.components["libgetdns"].libs = ["getdns" + libsuffix]
self.cpp_info.components["libgetdns"].includedirs.append(os.path.join("include", "getdns"))
self.cpp_info.components["libgetdns"].names["pkg_config"]= "getdns"
self.cpp_info.components["libgetdns"].set_property("pkg_config_name", "getdns")
self.cpp_info.components["libgetdns"].requires = ["openssl::openssl"]
if self.options.with_libidn2:
self.cpp_info.components["libgetdns"].requires.append("libidn2::libidn2")
if self.options.with_libidn2:
self.cpp_info.components["libgetdns"].requires.append("libidn2::libidn2")
if self.options.tls == "gnutls":
self.cpp_info.components["libgetdns"].requires.extend(["nettle::nettle", "gnutls::gnutls"])
if self.settings.os == "Windows":
self.cpp_info.components["libgetdns"].system_libs.extend(["ws2_32", "crypt32", "gdi32", "iphlpapi", "psapi", "userenv"])

if self.options.with_libevent:
self.cpp_info.components["dns_ex_event"].libs = ["getdns_ex_event" + libsuffix]
self.cpp_info.components["dns_ex_event"].requires= ["libgetdns", "libevent::libevent"]
self.cpp_info.components["dns_ex_event"].names["pkg_config"]= "getdns_ext_event"
self.cpp_info.components["dns_ext_event"].libs = ["getdns_ext_event" + libsuffix]
self.cpp_info.components["dns_ext_event"].requires = ["libgetdns", "libevent::libevent"]
self.cpp_info.components["dns_ext_event"].set_property("pkg_config_name", "getdns_ext_event")

if self._with_libev:
self.cpp_info.components["dns_ex_ev"].libs = ["getdns_ex_ev" + libsuffix]
self.cpp_info.components["dns_ex_ev"].requires = ["libgetdns", "libev::libev"]
self.cpp_info.components["dns_ex_ev"].names["pkg_config"]= "getdns_ext_ev"
if self.options.with_libev:
self.cpp_info.components["dns_ext_ev"].libs = ["getdns_ext_ev" + libsuffix]
self.cpp_info.components["dns_ext_ev"].requires = ["libgetdns", "libev::libev"]
self.cpp_info.components["dns_ext_ev"].set_property("pkg_config_name", "getdns_ext_ev")

if self.options.with_libuv:
self.cpp_info.components["dns_ex_uv"].libs = ["getdns_ex_uv" + libsuffix]
self.cpp_info.components["dns_ex_uv"].requires = ["libgetdns", "libuv::libuv"]
self.cpp_info.components["dns_ex_uv"].names["pkg_config"]= "getdns_ext_uv"
self.cpp_info.components["dns_ext_uv"].libs = ["getdns_ext_uv" + libsuffix]
self.cpp_info.components["dns_ext_uv"].requires = ["libgetdns", "libuv::libuv"]
self.cpp_info.components["dns_ext_uv"].set_property("pkg_config_name", "getdns_ext_uv")

# TODO: Remove after dropping support for Conan 1.x in ConanCenterIndex
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)
33 changes: 0 additions & 33 deletions recipes/getdns/all/patches/1.6.0-0001-install-runtimes.patch

This file was deleted.

Loading
Loading