Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions recipes/apr-util/all/CMakeLists.txt

This file was deleted.

10 changes: 3 additions & 7 deletions recipes/apr-util/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
sources:
"1.6.1":
sha256: "b65e40713da57d004123b6319828be7f1273fbc6490e145874ee1177e112c459"
url:
- "https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz"
- "https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz"
sha256: "b65e40713da57d004123b6319828be7f1273fbc6490e145874ee1177e112c459"
patches:
"1.6.1":
- base_path: "source_subfolder"
patch_file: "patches/0001-cmake-build-only-shared-static.patch"
- base_path: "source_subfolder"
patch_file: "patches/0002-apu-config-prefix-env.patch"
- base_path: "source_subfolder"
patch_file: "patches/0003-disable-check-APR_LIBRARIES.patch"
- patch_file: "patches/0001-fix-cmake.patch"
- patch_file: "patches/0002-apu-config-prefix-env.patch"
239 changes: 127 additions & 112 deletions recipes/apr-util/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
from conans import AutoToolsBuildEnvironment, ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import cross_building
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualRunEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc
import os


required_conan_version = ">=1.33.0"
required_conan_version = ">=1.54.0"


class AprUtilConan(ConanFile):
name = "apr-util"
description = "The Apache Portable Runtime (APR) provides a predictable and consistent interface to underlying platform-specific implementations"
description = (
"The Apache Portable Runtime (APR) provides a predictable and "
"consistent interface to underlying platform-specific implementations"
)
license = "Apache-2.0"
topics = ("apr-util", "apache", "platform", "library")
topics = ("apache", "platform", "library")
homepage = "https://apr.apache.org/"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = "CMakeLists.txt", "patches/**"
generators = "cmake", "cmake_find_package"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand Down Expand Up @@ -45,162 +55,167 @@ class AprUtilConan(ConanFile):
"with_ldap": False,
}

_autotools = None
_cmake = None
def export_sources(self):
export_conandata_patches(self)

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.cppstd
del self.settings.compiler.libcxx
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
self.options["apr"].shared = self.options.shared

if not self.options.with_expat:
raise ConanInvalidConfiguration("expat cannot be disabled (at this time) (check back later)")

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

@property
def _build_subfolder(self):
return "build_subfolder"
def layout(self):
if self.settings.os == "Windows":
cmake_layout(self, src_folder="src")
else:
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("apr/1.7.0")
self.requires("apr/1.7.0", transitive_headers=True)
if self.settings.os != "Windows":
#cmake build doesn't allow injection of iconv yet
self.requires("libiconv/1.16")
# https://github.com/conan-io/conan-center-index/pull/16142#issuecomment-1494282164
# transitive_libs needs to be set because some sys-frameworks on the old mac images for c3i
# are pulling it in - discovered in https://github.com/conan-io/conan-center-index/pull/16266
self.requires("libiconv/1.17", transitive_libs=True)
if self.options.with_openssl:
self.requires("openssl/1.1.1k")
self.requires("openssl/1.1.1t")
if self.options.with_mysql:
self.requires("libmysqlclient/8.0.31")
if self.options.with_sqlite3:
self.requires("sqlite3/3.41.1")
if self.options.with_expat:
self.requires("expat/2.5.0")
if self.options.with_postgresql:
self.requires("libpq/14.5")

def validate(self):
if not self.options.with_expat:
raise ConanInvalidConfiguration("expat cannot be disabled (at this time) (check back later)")
if self.options.shared != self.dependencies["apr"].options.shared:
raise ConanInvalidConfiguration("apr-util must be built with same shared option as apr")
if self.options.with_nss:
# self.requires("nss/x.y.z")
raise ConanInvalidConfiguration("CCI has no nss recipe (yet)")
if self.options.with_commoncrypto:
# self.requires("commoncrypto/x.y.z")
raise ConanInvalidConfiguration("CCI has no commoncrypto recipe (yet)")
if self.options.dbm == "gdbm":
# self.requires("gdbm/x.y.z")
raise ConanInvalidConfiguration("CCI has no gdbm recipe (yet)")
elif self.options.dbm == "ndbm":
# self.requires("ndbm/x.y.z")
raise ConanInvalidConfiguration("CCI has no ndbm recipe (yet)")
elif self.options.dbm == "db":
# self.requires("libdb/x.y.z")
raise ConanInvalidConfiguration("CCI has no libdb recipe (yet)")
if self.options.with_lber:
# self.requires("lber/x.y.z")
raise ConanInvalidConfiguration("CCI has no lber recipe (yet)")
if self.options.with_ldap:
# self.requires("ldap/x.y.z")
raise ConanInvalidConfiguration("CCI has no ldap recipe (yet)")
if self.options.with_mysql:
self.requires("libmysqlclient/8.0.25")
if self.options.with_sqlite3:
self.requires("sqlite3/3.35.5")
if self.options.with_expat:
self.requires("expat/2.4.1")
if self.options.with_postgresql:
self.requires("libpq/13.2")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def validate(self):
if self.options.shared != self.options["apr"].shared:
raise ConanInvalidConfiguration("apr-util must be built with same shared option as apr")

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["APR_INCLUDE_DIR"] = ";".join(self.deps_cpp_info["apr"].include_paths)
self._cmake.definitions["INSTALL_PDB"] = False
self._cmake.definitions["APU_HAVE_CRYPTO"] = self._with_crypto
self._cmake.definitions["APR_HAS_LDAP"] = self.options.with_ldap
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
get(self, **self.conan_data["sources"][self.version], strip_root=True)

@property
def _with_crypto(self):
return self.options.with_openssl or self.options.with_nss or self.options.with_commoncrypto

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self)
self._autotools.libs = []
self._autotools.include_paths = []
if self._with_crypto:
if self.settings.os == "Linux":
self._autotools.libs.append("dl")
conf_args = [
"--with-apr={}".format(tools.unix_path(self.deps_cpp_info["apr"].rootpath)),
"--with-crypto" if self._with_crypto else "--without-crypto",
"--with-iconv={}".format(tools.unix_path(self.deps_cpp_info["libiconv"].rootpath)),
"--with-openssl={}".format(tools.unix_path(self.deps_cpp_info["openssl"].rootpath)) if self.options.with_openssl else "--without-openssl",
"--with-expat={}".format(tools.unix_path(self.deps_cpp_info["expat"].rootpath)) if self.options.with_expat else "--without-expat",
"--with-mysql={}".format(tools.unix_path(self.deps_cpp_info["libmysqlclient"].rootpath)) if self.options.with_mysql else "--without-mysql",
"--with-pgsql={}".format(tools.unix_path(self.deps_cpp_info["libpq"].rootpath)) if self.options.with_postgresql else "--without-pgsql",
"--with-sqlite3={}".format(tools.unix_path(self.deps_cpp_info["sqlite3"].rootpath)) if self.options.with_sqlite3 else "--without-sqlite3",
"--with-ldap={}".format(tools.unix_path(self.deps_cpp_info["ldap"].rootpath)) if self.options.with_ldap else "--without-ldap",
"--with-berkeley-db={}".format(tools.unix_path(self.deps_cpp_info["libdb"].rootpath)) if self.options.dbm == "db" else "--without-berkeley-db",
"--with-gdbm={}".format(tools.unix_path(self.deps_cpp_info["gdbm"].rootpath)) if self.options.dbm == "gdbm" else "--without-gdbm",
"--with-ndbm={}".format(tools.unix_path(self.deps_cpp_info["ndbm"].rootpath)) if self.options.dbm == "ndbm" else "--without-ndbm",
]
if self.options.dbm:
conf_args.append("--with-dbm={}".format(self.options.dbm))
self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder)
return self._autotools

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
def generate(self):
if self.settings.os == "Windows":
tc = CMakeToolchain(self)
tc.variables["INSTALL_PDB"] = False
tc.variables["APU_HAVE_CRYPTO"] = self._with_crypto
tc.variables["APR_HAS_LDAP"] = self.options.with_ldap
tc.generate()
deps = CMakeDeps(self)
deps.generate()
else:
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")

tc = AutotoolsToolchain(self)
yes_no = lambda v: "yes" if v else "no"
rootpath_no = lambda v, req: self.dependencies[req].package_folder if v else "no"
tc.configure_args.extend([
f"--with-apr={rootpath_no(True, 'apr')}",
f"--with-crypto={yes_no(self._with_crypto)}",
f"--with-iconv={rootpath_no(True, 'libiconv')}",
f"--with-openssl={rootpath_no(self.options.with_openssl, 'openssl')}",
f"--with-expat={rootpath_no(self.options.with_expat, 'expat')}",
f"--with-mysql={rootpath_no(self.options.with_mysql, 'libmysqlclient')}",
f"--with-pgsql={rootpath_no(self.options.with_postgresql, 'libpq')}",
f"--with-sqlite3={rootpath_no(self.options.with_sqlite3, 'sqlite3')}",
f"--with-ldap={rootpath_no(self.options.with_ldap, 'ldap')}",
f"--with-berkeley-db={rootpath_no(self.options.dbm == 'db', 'libdb')}",
f"--with-gdbm={rootpath_no(self.options.dbm == 'gdbm', 'gdbm')}",
f"--with-ndbm={rootpath_no(self.options.dbm == 'ndbm', 'ndbm')}",
])
if self.options.dbm:
tc.configure_args.append(f"--with-dbm={self.options.dbm}")
if self._with_crypto and self.settings.os in ["Linux", "FreeBSD"]:
tc.extra_ldflags.append("-ldl")
env = tc.environment()
env.define_path("APR_ROOT", self.dependencies["apr"].package_folder)
env.define_path("_APR_BUILDDIR", os.path.join(self.dependencies["apr"].package_folder, "res", "build-1"))
tc.generate(env)

deps = AutotoolsDeps(self)
deps.generate()

def build(self):
self._patch_sources()
apply_conandata_patches(self)
if self.settings.os == "Windows":
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.configure()
cmake.build()
else:
autotools = self._configure_autotools()
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
if self.settings.os == "Windows":
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()
else:
autotools = self._configure_autotools()
autotools = Autotools(self)
autotools.install()

tools.remove_files_by_mask(os.path.join(self.package_folder, "lib", "apr-util-1"), "*.la")
os.unlink(os.path.join(self.package_folder, "lib", "libaprutil-1.la"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True)
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.names["pkg_config"] = "apr-util-1"
self.cpp_info.libs = ["libaprutil-1" if self.settings.os == "Windows" and self.options.shared else "aprutil-1"]
self.cpp_info.set_property("pkg_config_name", "apr-util-1")
if self.settings.os == "Windows":
self.cpp_info.libs = ["apr_dbd_odbc-1"]
if self._with_crypto:
self.cpp_info.libs.append("apr_crypto_openssl-1")
if self.options.with_ldap:
self.cpp_info.libs.append("apr_ldap-1")
prefix = "lib" if self.options.shared else ""
self.cpp_info.libs.append(f"{prefix}aprutil-1")
else:
self.cpp_info.libs = ["aprutil-1"]
self.cpp_info.libdirs.append(os.path.join("lib", "apr-util-1"))
if not self.options.shared:
self.cpp_info.defines = ["APU_DECLARE_STATIC"]
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["dl", "pthread", "rt"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs = ["crypt", "dl", "pthread", "rt"]
elif self.settings.os == "Windows":
self.cpp_info.system_libs = ["mswsock", "rpcrt4", "ws2_32"]
self.cpp_info.system_libs = ["mswsock", "odbc32", "rpcrt4", "ws2_32"]

binpath = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH env var : {}".format(binpath))
self.env_info.PATH.append(binpath)
self.runenv_info.define_path("APR_UTIL_ROOT", self.package_folder)

apr_util_root = tools.unix_path(self.package_folder)
self.output.info("Settings APR_UTIL_ROOT environment var: {}".format(apr_util_root))
self.env_info.APR_UTIL_ROOT = apr_util_root
deps = [dep for dep in reversed(self.dependencies.host.topological_sort.values())]
libdirs = [p for dep in deps for p in dep.cpp_info.aggregated_components().includedirs]
aprutil_ldflags = " ".join([f"-L{p}" for p in libdirs])
self.runenv_info.define("APRUTIL_LDFLAGS", aprutil_ldflags)

if self.settings.compiler != "Visual Studio":
self.env_info.APRUTIL_LDFLAGS = " ".join(tools.unix_path("-L{}".format(l)) for l in self.deps_cpp_info.lib_paths)
# TODO: to remove in conan v2
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.env_info.APR_UTIL_ROOT = self.package_folder
if not is_msvc(self):
self.env_info.APRUTIL_LDFLAGS = aprutil_ldflags
Loading