diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87e82bf..10b4ae4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,33 @@ jobs: path: releases/ + Linux_static_x86: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Packages + run: sudo apt-get update && sudo apt-get install build-essential yasm -y + + - name: Build x86 static-libav version + run: | + cargo build --release --features=staticlibav + strip target/release/bliss-analyser + mkdir releases + cp target/release/bliss-analyser releases/bliss-analyser + cp UserGuide.md releases/README.md + cp LICENSE releases/ + cp configs/linux.ini releases/config.ini + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: bliss-analyser-linux-x86 + path: releases/ + + Ubuntu_2204_libav_x86: runs-on: ubuntu-22.04 @@ -107,6 +134,25 @@ jobs: path: releases/ + Linux_static_arm: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build ARM static-libav on Debian + run: | + docker build -t bliss-analyser-cross - < docker/Dockerfile_Bullseye_static + docker run --rm -v $PWD/target:/build -v $PWD:/src bliss-analyser-cross + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: bliss-analyser-linux-arm + path: releases/ + + Debian_libav_arm: runs-on: ubuntu-22.04 @@ -181,6 +227,54 @@ jobs: path: releases/ + macOS_staticlibav: + runs-on: macos-13 + + steps: + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Checkout + uses: actions/checkout@v2 + + - name: Install deps + run: | + brew install pkg-config ffmpeg + + - name: Install Rust support for ARM64 & prepare environment + run: | + rustup target add aarch64-apple-darwin + mkdir releases + + - name: Build + run: | + cargo build --release --features update-aubio-bindings,staticlibav + strip target/release/bliss-analyser + cp target/release/bliss-analyser releases/bliss-analyser-x86_64 + cargo build --target=aarch64-apple-darwin --release --features update-aubio-bindings,staticlibav + strip target/aarch64-apple-darwin/release/bliss-analyser + cp target/aarch64-apple-darwin/release/bliss-analyser releases/bliss-analyser-arm64 + + - name: Build fat binary + run: | + lipo -create \ + -arch x86_64 releases/bliss-analyser-x86_64 \ + -arch arm64 releases/bliss-analyser-arm64 \ + -output releases/bliss-analyser + + - name: Remove ununsed binaries + run: + rm releases/bliss-analyser-x86_64 releases/bliss-analyser-arm64 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: bliss-analyser-mac-ffmpeg + path: releases/ + + Windows: runs-on: windows-2019 diff --git a/Cargo.lock b/Cargo.lock index 2d4217a..78d9197 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -100,6 +100,28 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "bindgen" +version = "0.64.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 1.0.99", + "which 4.4.2", +] + [[package]] name = "bindgen" version = "0.70.1" @@ -163,7 +185,7 @@ dependencies = [ "rusqlite", "substring", "ureq", - "which", + "which 7.0.2", ] [[package]] @@ -203,6 +225,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a5b978c743f6450be98229b052d996ed1cc0507274e9c68a7effeb51e8a13ec" dependencies = [ + "bindgen 0.64.0", "cc", ] @@ -455,7 +478,7 @@ version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bc3234d0a4b2f7d083699d0860c6c9dd83713908771b60f94a96f8704adfe45" dependencies = [ - "bindgen", + "bindgen 0.70.1", "cc", "libc", "num_cpus", @@ -567,6 +590,15 @@ dependencies = [ "time 0.2.27", ] +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys", +] + [[package]] name = "humantime" version = "2.1.0" @@ -651,6 +683,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.170" @@ -882,6 +920,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.1.0" @@ -1637,6 +1681,18 @@ dependencies = [ "webpki", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "which" version = "7.0.2" diff --git a/Cargo.toml b/Cargo.toml index aef9c5e..adfd13f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ hhmmss = "0.1.0" [features] libav = ["bliss-audio/ffmpeg"] update-aubio-bindings = ["bliss-audio/update-aubio-bindings"] +staticlibav = ["bliss-audio/ffmpeg","bliss-audio/build-ffmpeg,bliss-audio/ffmpeg-static"] [dependencies.bliss-audio] default-features = false diff --git a/docker/Dockerfile_Bullseye_static b/docker/Dockerfile_Bullseye_static new file mode 100644 index 0000000..c2d954c --- /dev/null +++ b/docker/Dockerfile_Bullseye_static @@ -0,0 +1,36 @@ +# Cross compilation environment for bliss-mixer + +FROM debian:bullseye + +RUN dpkg --add-architecture arm64 && \ + dpkg --add-architecture armhf +RUN apt-get update + +RUN apt-get install -y curl git pkg-config yasm +RUN apt-get install -y build-essential clang +RUN apt-get install -y crossbuild-essential-armhf crossbuild-essential-arm64 + +RUN apt-get install -y libavutil-dev:arm64 libavcodec-dev:arm64 libavformat-dev:arm64 \ + libavfilter-dev:arm64 libavdevice-dev:arm64 libswresample-dev:arm64 libfftw3-dev:arm64 + +RUN apt-get install -y libavutil-dev:armhf libavcodec-dev:armhf libavformat-dev:armhf \ + libavfilter-dev:armhf libavdevice-dev:armhf libswresample-dev:armhf libfftw3-dev:armhf + +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +ENV PATH="/root/.cargo/bin/:${PATH}" +RUN rustup target add aarch64-unknown-linux-gnu && \ + rustup target add arm-unknown-linux-gnueabihf + +RUN mkdir /.cargo && \ + echo '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' > /.cargo/config && \ + echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config + +RUN mkdir /build +ENV CARGO_TARGET_DIR /build +ENV CARGO_HOME /build/cache + +RUN mkdir /src + +WORKDIR /src +CMD ["/src/docker/docker-build-arm-staticlibav.sh"] + diff --git a/docker/docker-build-arm-staticlibav.sh b/docker/docker-build-arm-staticlibav.sh new file mode 100755 index 0000000..f96c779 --- /dev/null +++ b/docker/docker-build-arm-staticlibav.sh @@ -0,0 +1,29 @@ +#!/bin/bash +## #!/usr/bin/env bash +set -eux + +uname -a +DESTDIR=/src/releases + +mkdir -p $DESTDIR/bin +rm -rf $DESTDIR/bin/* + +function build { + echo Building for $1 to $3... + + if [[ ! -f /build/$1/release/bliss-analyser ]]; then + export RUST_BACKTRACE=full + export PKG_CONFIG=${1//unknown-/}-pkg-config + BINDGEN_EXTRA_CLANG_ARGS="--sysroot /usr/${1//unknown-/}" cargo build --release --features=staticlibav --target $1 + fi + + $2 /build/$1/release/bliss-analyser && cp /build/$1/release/bliss-analyser $DESTDIR/$3 +} + +build arm-unknown-linux-gnueabihf arm-linux-gnueabihf-strip bin/bliss-analyser-armhf +build aarch64-unknown-linux-gnu aarch64-linux-gnu-strip bin/bliss-analyser-aarch64 + +cp UserGuide.md $DESTDIR/README.md +cp LICENSE $DESTDIR/ +cp configs/linux.ini $DESTDIR/config.ini +cp scripts/bliss-analyser-arm $DESTDIR/bliss-analyser