build.lua 3170 bytes · raw
-- libarchive's CMake project: the library with the dependencies of the options, given to CMake by their files, and the
-- NDK's zlib. What it installs: libarchive.a, or libarchive.so with its links (and libarchive.a beside it, which is not
-- returned).
function build(slice, options, deps)
if options.xml == "libxml2" and tonumber(slice.android.api) < 28 then
error("libarchive takes libxml2 only with iconv, which Android has from API level 28 (this project's is "
.. slice.android.api .. "): choose xml = \"expat\" or a later API level")
end
local defines = {
ENABLE_TEST = false, ENABLE_WERROR = false, ENABLE_COVERAGE = false, ENABLE_INSTALL = true,
ENABLE_TAR = false, ENABLE_UNZIP = false, ENABLE_CPIO = false, ENABLE_CAT = false,
ENABLE_ZLIB = options.zlib, ENABLE_BZip2 = options.bzip2, ENABLE_LZMA = options.lzma, ENABLE_LZ4 = options.lz4,
ENABLE_ZSTD = options.zstd, ENABLE_LIBB2 = false, ENABLE_LZO = false, ENABLE_MD = false, ENABLE_BSDXML = false,
ENABLE_EXPAT = options.xml == "expat", ENABLE_LIBXML2 = options.xml == "libxml2", ENABLE_WIN32_XMLLITE = false,
ENABLE_OPENSSL = options.crypto == "openssl", ENABLE_MBEDTLS = false, ENABLE_NETTLE = false, ENABLE_CNG = false,
ENABLE_PCREPOSIX = false, ENABLE_PCRE2POSIX = false, ENABLE_LIBGCC = false,
ENABLE_ACL = false, ENABLE_XATTR = true, ENABLE_ICONV = true, POSIX_REGEX_LIB = "LIBC",
}
if options.bzip2 then
defines.BZIP2_INCLUDE_DIR = deps.bzip2.include
defines.BZIP2_LIBRARY_RELEASE = deps.bzip2.libraries.bz2
end
if options.lzma then
defines.LIBLZMA_INCLUDE_DIR = deps.lzma.include
defines.LIBLZMA_LIBRARY_RELEASE = deps.lzma.libraries.lzma
end
if options.lz4 then
defines.LZ4_INCLUDE_DIR = deps.lz4.include
defines.LZ4_LIBRARY = deps.lz4.libraries.lz4
end
if options.zstd then
defines.ZSTD_INCLUDE_DIR = deps.zstd.include
defines.ZSTD_LIBRARY = deps.zstd.libraries.zstd
end
if options.xml == "expat" then
defines.EXPAT_INCLUDE_DIR = deps.expat.include
defines.EXPAT_LIBRARY = deps.expat.libraries.expat
elseif options.xml == "libxml2" then
defines.LIBXML2_INCLUDE_DIR = deps.libxml2.include
defines.LIBXML2_LIBRARY = deps.libxml2.libraries.xml2
-- A static libxml2 needs libm, which libarchive's CMake does not link (libarchive.so).
if deps.libxml2.linkage == "static" then defines.CMAKE_C_STANDARD_LIBRARIES = "-lm" end
end
if options.crypto == "openssl" then
defines.OPENSSL_ROOT_DIR = deps.openssl.prefix
defines.OPENSSL_USE_STATIC_LIBS = deps.openssl.linkage == "static"
defines.OPENSSL_INCLUDE_DIR = deps.openssl.include
defines.OPENSSL_CRYPTO_LIBRARY = deps.openssl.libraries.crypto
defines.OPENSSL_SSL_LIBRARY = deps.openssl.libraries.ssl
end
otok.cmake{ defines = defines }
local p = slice.prefix
local lib = otok.glob(slice.linkage == "static" and "lib/libarchive.a" or "lib/libarchive.so", p)[1]
return { libraries = { archive = lib }, headers = p .. "/include" }
end
recipe.toml 3494 bytes · raw
# The otok recipe of libarchive (https://github.com/apotocki/otok): libarchive for Android, from the release archive, with
# libarchive's CMake; the library, static or dynamic. The formats come with the libraries of the options (zlib, the NDK's,
# bzip2, lzma, lz4, zstd, all on by default), XAR with Expat (reading only) or libxml2 (reading and writing; libarchive
# takes it only with iconv, which Android has from API level 28), encryption and the digests with OpenSSL. Without ACLs,
# libb2 (libarchive's own BLAKE2 is used), LZO, Mbed TLS (libarchive needs its 3.x API), Nettle and PCRE.
[recipe]
api = 1
library = "libarchive"
name = "libarchive"
version = "3.8.11"
revision = 1
license = "BSD-2-Clause AND BSD-3-Clause AND (CC0-1.0 OR OpenSSL OR Apache-2.0)"
license-files = ["COPYING"]
homepage = "https://www.libarchive.org"
documentation = "https://github.com/libarchive/libarchive/wiki"
description = "libarchive, a library reading and writing tar, cpio, zip, 7-Zip, RAR, ISO 9660, XAR and other archive and compression formats."
keywords = ["archive", "tar", "zip", "7z", "compression"]
linkage = ["static", "dynamic"]
[source]
url = "https://github.com/libarchive/libarchive/releases/download/v3.8.11/libarchive-3.8.11.tar.xz"
sha256 = "a3dc0872b1b39da34dc18ef1b944f0f11ffd37425d70ae04be679279f1cf43d2"
mirrors = ["https://www.libarchive.org/downloads/libarchive-3.8.11.tar.xz"]
[options.zlib]
type = "bool"
default = true
additive = true
doc = "gzip, deflate in zip, and the formats that need it (ISO 9660 zisofs, XAR, 7-Zip deflate), with the NDK's zlib."
[options.bzip2]
type = "bool"
default = true
additive = true
doc = "bzip2, and bzip2 in zip, 7-Zip and XAR, with bzip2."
[options.lzma]
type = "bool"
default = true
additive = true
doc = "xz, lzma and lzip, and LZMA in zip, 7-Zip and XAR, with liblzma."
[options.lz4]
type = "bool"
default = true
additive = true
doc = "lz4, with lz4."
[options.zstd]
type = "bool"
default = true
additive = true
doc = "zstd, and zstd in zip and 7-Zip, with zstd."
[options.xml]
type = "enum"
values = ["expat", "libxml2", "none"]
default = "expat"
doc = "The XML library of the XAR format: Expat (reading only), libxml2 (reading and writing; API level 28 or later, for iconv), or none (no XAR)."
[options.crypto]
type = "enum"
values = ["openssl", "none"]
default = "openssl"
doc = "OpenSSL for traditional and AES encryption of zip, the digests of XAR, mtree and WARC; none leaves them out."
[platforms]
supported = ["android"]
build-on = ["*/ndk"]
[deps.bzip2]
version = ">= 1.0"
default-recipe = "apotocki/bzip2"
when = { option = "bzip2" }
[deps.lzma]
version = ">= 5.0"
default-recipe = "apotocki/lzma"
when = { option = "lzma" }
[deps.lz4]
version = ">= 1.7"
default-recipe = "apotocki/lz4"
when = { option = "lz4" }
[deps.zstd]
version = ">= 1.4"
default-recipe = "apotocki/zstd"
when = { option = "zstd" }
[deps.expat]
version = ">= 2.0"
default-recipe = "apotocki/expat"
when = { option = "xml", is = "expat" }
[deps.libxml2]
version = ">= 2.9"
default-recipe = "apotocki/libxml2"
when = { option = "xml", is = "libxml2" }
[deps.openssl]
version = ">= 3.0"
default-recipe = "apotocki/openssl"
when = { option = "crypto", is = "openssl" }
[toolchains]
cmake = { version = ">= 3.20", default-recipe = "apotocki/cmake" }
ninja = { version = ">= 1.10", default-recipe = "apotocki/ninja" }
[[product]]
name = "LibArchive"
libraries = ["archive"]
link = { libraries = [{ library = "z", when = { option = "zlib" } }] }