|
| 1 | +using BinaryBuilder |
| 2 | +using Pkg |
| 3 | +using BinaryBuilderBase: sanitize |
| 4 | + |
| 5 | +const llvm_version = v"13.0.1" |
| 6 | + |
| 7 | +function configure_zlib_build(upstream_version::VersionNumber; |
| 8 | + version::VersionNumber=upstream_version, |
| 9 | + kwargs...) |
| 10 | + |
| 11 | + versions_tags = Dict( |
| 12 | + v"1.2.12" => "21767c654d31d2dccdde4330529775c6c5fd5389", |
| 13 | + v"1.3.1" => "51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf", |
| 14 | + ) |
| 15 | + |
| 16 | + name = "Zlib" |
| 17 | + |
| 18 | + sources = [ |
| 19 | + # use Git source because zlib has a track record of deleting release tarballs of old versions |
| 20 | + GitSource("https://github.com/madler/zlib.git", versions_tags[upstream_version]), |
| 21 | + ] |
| 22 | + |
| 23 | + script = raw""" |
| 24 | + cd $WORKSPACE/srcdir/zlib* |
| 25 | + mkdir build && cd build |
| 26 | + if [[ ${bb_full_target} == *-sanitize+memory* ]]; then |
| 27 | + # Install msan runtime (for clang) |
| 28 | + cp -rL ${libdir}/linux/* /opt/x86_64-linux-musl/lib/clang/*/lib/linux/ |
| 29 | + fi |
| 30 | + # We use `-DUNIX=true` to ensure that it is always named `libz` instead of `libzlib` or something absolutely absurd like that. |
| 31 | + cmake -DCMAKE_INSTALL_PREFIX=${prefix} \ |
| 32 | + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ |
| 33 | + -DCMAKE_BUILD_TYPE=Release \ |
| 34 | + -DUNIX=true \ |
| 35 | + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ |
| 36 | + .. |
| 37 | + make install -j${nproc} |
| 38 | + install_license ../README |
| 39 | + """ |
| 40 | + |
| 41 | + platforms = supported_platforms() |
| 42 | + push!(platforms, Platform("x86_64", "linux"; sanitize="memory")) |
| 43 | + |
| 44 | + products = [ |
| 45 | + LibraryProduct("libz", :libz), |
| 46 | + ] |
| 47 | + |
| 48 | + dependencies = [ |
| 49 | + BuildDependency(PackageSpec(; name="LLVMCompilerRT_jll", uuid="4e17d02c-6bf5-513e-be62-445f41c75a11", version=llvm_version); platforms=filter(p -> sanitize(p)=="memory", platforms)), |
| 50 | + ] |
| 51 | + |
| 52 | + return name, version, sources, script, platforms, products, dependencies |
| 53 | +end |
0 commit comments