From c13b823682db9790947d121da0c27c838ed4affd Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 7 Jul 2024 12:47:28 +0200 Subject: [PATCH] fix(ci): static compilation --- .woodpecker/build.yml | 17 ++++++++++++----- libarchive3-sys/build.rs | 34 +--------------------------------- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 4cb5370..4d5367b 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -10,12 +10,19 @@ steps: image: 'rust:1.79-alpine3.19' environment: - 'LIBARCHIVE_STATIC=1' - - 'LIBARCHIVE_LIB_DIR=/usr/lib' - - 'LIBARCHIVE_INCLUDE_DIR=/usr/include' - - 'LIBARCHIVE_LDFLAGS=-lssl -lcrypto -L/lib -lz -lbz2 -llzma -lexpat -lzstd -llz4' - - 'LIBARCHIVE_LDFLAGS=-L/usr/lib -lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3' commands: - - apk add --no-cache build-base libarchive-static libarchive-dev + # Dependencies required to statically compile libarchive and libsqlite3 + - > + apk add --no-cache build-base + libarchive-static libarchive-dev + zlib-static + openssl-libs-static + bzip2-static + xz-static + expat-static + zstd-static + lz4-static + acl-static - cargo build --verbose # Binaries, even debug ones, should be statically compiled - '[ "$(readelf -d target/debug/rieterd | grep NEEDED | wc -l)" = 0 ]' diff --git a/libarchive3-sys/build.rs b/libarchive3-sys/build.rs index 43d83e7..b82eb31 100644 --- a/libarchive3-sys/build.rs +++ b/libarchive3-sys/build.rs @@ -1,35 +1,3 @@ -extern crate pkg_config; - -use std::env; - fn main() { - let lib_dir = env::var("LIBARCHIVE_LIB_DIR").ok(); - let include_dir = env::var("LIBARCHIVE_INCLUDE_DIR").ok(); - - if lib_dir.is_some() && include_dir.is_some() { - println!("cargo:rustc-flags=-L native={}", lib_dir.unwrap()); - println!("cargo:include={}", include_dir.unwrap()); - let mode = match env::var_os("LIBARCHIVE_STATIC") { - Some(_) => "static", - None => "dylib", - }; - println!("cargo:rustc-flags=-l {0}=archive", mode); - - if mode == "static" { - if let Ok(ldflags) = env::var("LIBARCHIVE_LDFLAGS") { - for token in ldflags.split_whitespace() { - if token.starts_with("-L") { - println!("cargo:rustc-flags=-L native={}", token.replace("-L", "")); - } else if token.starts_with("-l") { - println!("cargo:rustc-flags=-l static={}", token.replace("-l", "")); - } - } - } - } - } else { - match pkg_config::find_library("libarchive") { - Ok(_) => (), - Err(msg) => panic!("Unable to locate libarchive, err={:?}", msg), - } - } + pkg_config::Config::new().atleast_version("3").probe("libarchive").unwrap(); }