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

libarchive: add 3.5.1 + bump deps + cache cmake + del fPIC if shared + minor cosmetic changes #4229

Merged
merged 13 commits into from
Jan 13, 2021
13 changes: 10 additions & 3 deletions recipes/libarchive/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
sources:
"3.4.0":
url: "https://github.com/libarchive/libarchive/releases/download/v3.4.0/libarchive-3.4.0.tar.gz"
sha256: "8643d50ed40c759f5412a3af4e353cffbce4fdf3b5cf321cb72cacf06b2d825e"
"3.5.1":
url: "https://github.com/libarchive/libarchive/releases/download/3.5.1/libarchive-3.5.1.tar.gz"
sha256: "9015d109ec00bb9ae1a384b172bf2fc1dff41e2c66e5a9eeddf933af9db37f5a"
"3.4.3":
url: "https://github.com/libarchive/libarchive/releases/download/v3.4.3/libarchive-3.4.3.tar.gz"
sha256: "ee1e749213c108cb60d53147f18c31a73d6717d7e3d2481c157e1b34c881ea39"
"3.4.0":
url: "https://github.com/libarchive/libarchive/releases/download/v3.4.0/libarchive-3.4.0.tar.gz"
sha256: "8643d50ed40c759f5412a3af4e353cffbce4fdf3b5cf321cb72cacf06b2d825e"
patches:
"3.4.0":
- patch_file: "patches/msvc-no-we4061.patch"
base_path: "source_subfolder"
195 changes: 114 additions & 81 deletions recipes/libarchive/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ class LibarchiveConan(ConanFile):
topics = ("conan", "libarchive", "tar", "data-compressor", "file-compression")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://libarchive.org"
license = "BSD"
exports_sources = ["CMakeLists.txt"]
license = "BSD-2-Clause"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_acl": [True, False],
"with_zlib": [True, False],
"with_bzip2": [True, False],
"with_libxml2": [True, False],
"with_expat": [True, False],
Expand All @@ -34,118 +35,153 @@ class LibarchiveConan(ConanFile):
"with_zstd": [True, False]
}
default_options = {
'shared': False,
'fPIC': True,
'with_acl': True,
'with_bzip2': False,
'with_libxml2': False,
'with_expat': False,
'with_iconv': True,
'with_pcreposix': False,
'with_cng': False,
'with_nettle': False,
'with_openssl': False,
'with_libb2': False,
'with_lz4': False,
'with_lzo': False,
'with_lzma': False,
'with_zstd': False
"shared": False,
"fPIC": True,
"with_acl": True,
"with_zlib": True,
"with_bzip2": False,
"with_libxml2": False,
"with_expat": False,
"with_iconv": True,
"with_pcreposix": False,
"with_cng": False,
"with_nettle": False,
"with_openssl": False,
"with_libb2": False,
"with_lz4": False,
"with_lzo": False,
"with_lzma": False,
"with_zstd": False
}

_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
_cmake = None

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
@property
def _source_subfolder(self):
return "source_subfolder"

def validate(self):
if self.version == "3.4.0":
# https://github.com/libarchive/libarchive/pull/1395
if self.settings.compiler == "Visual Studio" and self.settings.compiler.version == "16":
raise ConanInvalidConfiguration("Visual Studio 16 is not supported")
if self.options.with_expat and self.options.with_libxml2:
raise ConanInvalidConfiguration("libxml2 and expat options are exclusive. They cannot be used together as XML engine")
@property
def _build_subfolder(self):
return "build_subfolder"

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

def requirements(self):
self.requires("zlib/1.2.11")
if self.options.with_zlib:
self.requires("zlib/1.2.11")
if self.options.with_bzip2:
self.requires("bzip2/1.0.8")
if self.options.with_openssl:
self.requires("openssl/1.1.1d")
if self.options.with_lz4:
self.requires("lz4/1.9.2")
if self.options.with_zstd:
self.requires("zstd/1.4.3")
if self.options.with_lzma:
self.requires("xz_utils/5.2.4")
if self.options.with_libxml2:
self.requires("libxml2/2.9.9")
self.requires("libxml2/2.9.10")
if self.options.with_expat:
self.requires("expat/2.2.7")
self.requires("expat/2.2.10")
if self.options.with_iconv:
self.requires("libiconv/1.15")
self.requires("libiconv/1.16")
if self.options.with_pcreposix:
self.requires("pcre/8.41")
# TODO: deps not covered yet: cng, nettle, libb2
self.requires("pcre/8.44")
if self.options.with_cng:
# TODO: add cng when available in CCI
raise ConanInvalidConfiguration("cng recipe not yet available in CCI.")
if self.options.with_nettle:
self.requires("nettle/3.6")
if self.options.with_openssl:
self.requires("openssl/1.1.1i")
if self.options.with_libb2:
self.requires("libb2/20190723")
if self.options.with_lz4:
self.requires("lz4/1.9.3")
if self.options.with_lzo:
self.requires("lzo/2.10")
if self.options.with_lzma:
self.requires("xz_utils/5.2.5")
if self.options.with_zstd:
self.requires("zstd/1.4.8")

def validate(self):
if self.options.with_expat and self.options.with_libxml2:
raise ConanInvalidConfiguration("libxml2 and expat options are exclusive. They cannot be used together as XML engine")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
if self._cmake:
return self._cmake
self._cmake = CMake(self)
# turn off deps to avoid picking up them accidentally
cmake.definitions["ENABLE_NETTLE"] = self.options.with_nettle
cmake.definitions["ENABLE_OPENSSL"] = self.options.with_openssl
cmake.definitions["ENABLE_LIBB2"] = self.options.with_libb2
cmake.definitions["ENABLE_LZ4"] = self.options.with_lz4
cmake.definitions["ENABLE_LZO"] = self.options.with_lzo
cmake.definitions["ENABLE_LZMA"] = self.options.with_lzma
cmake.definitions["ENABLE_ZSTD"] = self.options.with_zstd
cmake.definitions["ENABLE_ZLIB"] = True
cmake.definitions["ENABLE_BZip2"] = self.options.with_bzip2
self._cmake.definitions["ENABLE_NETTLE"] = self.options.with_nettle
self._cmake.definitions["ENABLE_OPENSSL"] = self.options.with_openssl
self._cmake.definitions["ENABLE_LIBB2"] = self.options.with_libb2
self._cmake.definitions["ENABLE_LZ4"] = self.options.with_lz4
self._cmake.definitions["ENABLE_LZO"] = self.options.with_lzo
self._cmake.definitions["ENABLE_LZMA"] = self.options.with_lzma
self._cmake.definitions["ENABLE_ZSTD"] = self.options.with_zstd
self._cmake.definitions["ENABLE_ZLIB"] = self.options.with_zlib
self._cmake.definitions["ENABLE_BZip2"] = self.options.with_bzip2
# requires LibXml2 cmake name
cmake.definitions["ENABLE_LIBXML2"] = self.options.with_libxml2
cmake.definitions["ENABLE_ICONV"] = self.options.with_iconv
cmake.definitions["ENABLE_EXPAT"] = self.options.with_expat
cmake.definitions["ENABLE_PCREPOSIX"] = self.options.with_pcreposix
cmake.definitions["ENABLE_LibGCC"] = False
cmake.definitions["ENABLE_CNG"] = self.options.with_cng
self._cmake.definitions["ENABLE_LIBXML2"] = self.options.with_libxml2
self._cmake.definitions["ENABLE_ICONV"] = self.options.with_iconv
self._cmake.definitions["ENABLE_EXPAT"] = self.options.with_expat
self._cmake.definitions["ENABLE_PCREPOSIX"] = self.options.with_pcreposix
if self.options.with_pcreposix:
self._cmake.definitions["POSIX_REGEX_LIB"] = "LIBPCREPOSIX"
self._cmake.definitions["ENABLE_LibGCC"] = False
self._cmake.definitions["ENABLE_CNG"] = self.options.with_cng
# turn off features
cmake.definitions["ENABLE_ACL"] = self.options.with_acl
self._cmake.definitions["ENABLE_ACL"] = self.options.with_acl
# turn off components
cmake.definitions["ENABLE_TAR"] = False
cmake.definitions["ENABLE_CPIO"] = False
cmake.definitions["ENABLE_CAT"] = False
cmake.definitions["ENABLE_TEST"] = False
self._cmake.definitions["ENABLE_TAR"] = False
self._cmake.definitions["ENABLE_CPIO"] = False
self._cmake.definitions["ENABLE_CAT"] = False
self._cmake.definitions["ENABLE_TEST"] = False
# too strict check
cmake.definitions["ENABLE_WERROR"] = False
self._cmake.definitions["ENABLE_WERROR"] = False

cmake.configure(build_folder=self._build_subfolder)
return cmake
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

cmakelists_path = os.path.join(self._source_subfolder, "CMakeLists.txt")

# it can possibly override CMAKE_MODULE_PATH provided by generator
tools.replace_in_file(cmakelists_path,
"SET(CMAKE_MODULE_PATH",
"LIST(APPEND CMAKE_MODULE_PATH")
# Using Visual Studio, openssl caused some link problems because by using cmake variableds
# generated by cmake's FindOpenSSL, will let it forget these libraries
# workaround due to case sensitivity and limitations in cmake_find_package
# see https://github.com/conan-io/conan/issues/7691
if self.options.with_bzip2:
tools.replace_in_file(cmakelists_path, "BZIP2_FOUND", "BZip2_FOUND")
tools.replace_in_file(cmakelists_path, "BZIP2_INCLUDE_DIR", "BZip2_INCLUDE_DIR")
tools.replace_in_file(cmakelists_path, "BZIP2_LIBRARIES", "BZip2_LIBRARIES")
if self.options.with_libxml2:
tools.replace_in_file(cmakelists_path, "LIBXML2_FOUND", "LibXml2_FOUND")
tools.replace_in_file(cmakelists_path, "LIBXML2_INCLUDE_DIR", "LibXml2_INCLUDE_DIR")
tools.replace_in_file(cmakelists_path, "LIBXML2_LIBRARIES", "LibXml2_LIBRARIES")
if self.options.with_openssl:
tools.replace_in_file(cmakelists_path,
"${OPENSSL_CRYPTO_LIBRARY}",
"${OPENSSL_CRYPTO_LIBRARY} ${CONAN_LIBS_OPENSSL}")
tools.replace_in_file(cmakelists_path,
"${OPENSSL_LIBRARIES}",
"${OPENSSL_LIBRARIES} ${CONAN_LIBS_OPENSSL}")
"IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES \"Darwin\")",
"IF(ENABLE_OPENSSL)")
tools.replace_in_file(cmakelists_path, "OPENSSL_FOUND", "OpenSSL_FOUND")
tools.replace_in_file(cmakelists_path, "OPENSSL_INCLUDE_DIR", "OpenSSL_INCLUDE_DIR")
tools.replace_in_file(cmakelists_path, "OPENSSL_LIBRARIES", "OpenSSL_LIBRARIES")
tools.replace_in_file(cmakelists_path, "OPENSSL_CRYPTO_LIBRARY", "OpenSSL_LIBRARIES")
if self.options.with_lzma:
tools.replace_in_file(cmakelists_path, "LIBLZMA_FOUND", "LibLZMA_FOUND")
tools.replace_in_file(cmakelists_path, "LIBLZMA_INCLUDE_DIR", "LibLZMA_INCLUDE_DIR")
tools.replace_in_file(cmakelists_path, "LIBLZMA_LIBRARIES", "LibLZMA_LIBRARIES")
# add possible names for lz4 library
if not self.options.shared:
tools.replace_in_file(cmakelists_path,
Expand Down Expand Up @@ -181,11 +217,8 @@ def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
# drop pc and cmake file
tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake'))
tools.rmdir(os.path.join(self.package_folder, 'cmake'))
tools.rmdir(os.path.join(self.package_folder, 'share'))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
Expand Down
10 changes: 10 additions & 0 deletions recipes/libarchive/all/patches/msvc-no-we4061.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -157,7 +157,6 @@ IF (MSVC)
# This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
# Enable level 4 C4061: The enumerate has no associated handler in a switch
# statement.
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4061")
# Enable level 4 C4254: A larger bit field was assigned to a smaller bit
# field.
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4254")
4 changes: 3 additions & 1 deletion recipes/libarchive/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
versions:
"3.4.0":
"3.5.1":
folder: all
"3.4.3":
folder: all
"3.4.0":
folder: all