mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Merge pull request #1263 from gpajot/dev
fix: working armv6hf docker image for cross-compiling
This commit is contained in:
commit
2a1447daa0
4 changed files with 64 additions and 24 deletions
|
@ -2,7 +2,7 @@
|
||||||
# Build the docker image from the root of the project with the following command :
|
# Build the docker image from the root of the project with the following command :
|
||||||
# $ docker build -t librespot-cross -f contrib/Dockerfile .
|
# $ docker build -t librespot-cross -f contrib/Dockerfile .
|
||||||
#
|
#
|
||||||
# The resulting image can be used to build librespot for linux x86_64, armhf(with support for armv6hf), armel, mipsel, aarch64
|
# The resulting image can be used to build librespot for linux x86_64, armhf, armel, mipsel, aarch64
|
||||||
# $ docker run -v /tmp/librespot-build:/build librespot-cross
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross
|
||||||
#
|
#
|
||||||
# The compiled binaries will be located in /tmp/librespot-build
|
# The compiled binaries will be located in /tmp/librespot-build
|
||||||
|
@ -13,8 +13,6 @@
|
||||||
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
|
||||||
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
|
||||||
|
|
||||||
# $ docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
|
|
||||||
|
|
||||||
FROM debian:stretch
|
FROM debian:stretch
|
||||||
|
|
||||||
RUN dpkg --add-architecture arm64
|
RUN dpkg --add-architecture arm64
|
||||||
|
@ -40,10 +38,6 @@ RUN mkdir /.cargo && \
|
||||||
echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' >> /.cargo/config && \
|
echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' >> /.cargo/config && \
|
||||||
echo '[target.mipsel-unknown-linux-gnu]\nlinker = "mipsel-linux-gnu-gcc"' >> /.cargo/config
|
echo '[target.mipsel-unknown-linux-gnu]\nlinker = "mipsel-linux-gnu-gcc"' >> /.cargo/config
|
||||||
|
|
||||||
RUN mkdir /build && \
|
|
||||||
mkdir /pi-tools && \
|
|
||||||
curl -L https://github.com/raspberrypi/tools/archive/648a6eeb1e3c2b40af4eb34d88941ee0edeb3e9a.tar.gz | tar xz --strip-components 1 -C /pi-tools
|
|
||||||
|
|
||||||
ENV CARGO_TARGET_DIR /build
|
ENV CARGO_TARGET_DIR /build
|
||||||
ENV CARGO_HOME /build/cache
|
ENV CARGO_HOME /build/cache
|
||||||
ENV PKG_CONFIG_ALLOW_CROSS=1
|
ENV PKG_CONFIG_ALLOW_CROSS=1
|
||||||
|
|
49
contrib/cross-compile-armv6hf/Dockerfile
Normal file
49
contrib/cross-compile-armv6hf/Dockerfile
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# Cross compilation environment for librespot in armv6hf.
|
||||||
|
# Build the docker image from the root of the project with the following command:
|
||||||
|
# $ docker build -t librespot-cross-armv6hf -f contrib/cross-compile-armv6hf/Dockerfile .
|
||||||
|
#
|
||||||
|
# The resulting image can be used to build librespot for armv6hf:
|
||||||
|
# $ docker run -v /tmp/librespot-build-armv6hf:/build librespot-cross-armv6hf
|
||||||
|
#
|
||||||
|
# The compiled binary will be located in /tmp/librespot-build-armv6hf/arm-unknown-linux-gnueabihf/release/librespot
|
||||||
|
|
||||||
|
FROM --platform=linux/amd64 ubuntu:18.04
|
||||||
|
|
||||||
|
# Install common packages.
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y -qq git curl build-essential libasound2-dev libssl-dev libpulse-dev libdbus-1-dev
|
||||||
|
|
||||||
|
# Install armhf packages.
|
||||||
|
RUN echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main" | tee -a /etc/apt/sources.list
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get download libasound2:armhf libasound2-dev:armhf libssl-dev:armhf libssl1.1:armhf
|
||||||
|
RUN mkdir /sysroot && \
|
||||||
|
dpkg -x libasound2_*.deb /sysroot/ && \
|
||||||
|
dpkg -x libssl-dev*.deb /sysroot/ && \
|
||||||
|
dpkg -x libssl1.1*.deb /sysroot/ && \
|
||||||
|
dpkg -x libasound2-dev*.deb /sysroot/
|
||||||
|
|
||||||
|
# Install rust.
|
||||||
|
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||||
|
ENV PATH="/root/.cargo/bin/:${PATH}"
|
||||||
|
RUN rustup target add arm-unknown-linux-gnueabihf
|
||||||
|
RUN mkdir /.cargo && \
|
||||||
|
echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config
|
||||||
|
|
||||||
|
# Install Pi tools for armv6.
|
||||||
|
RUN mkdir /pi && \
|
||||||
|
git -C /pi clone --depth=1 https://github.com/raspberrypi/tools.git
|
||||||
|
|
||||||
|
# Build env variables.
|
||||||
|
ENV CARGO_TARGET_DIR /build
|
||||||
|
ENV CARGO_HOME /build/cache
|
||||||
|
ENV PATH="/pi/tools/arm-bcm2708/arm-linux-gnueabihf/bin:${PATH}"
|
||||||
|
ENV PKG_CONFIG_ALLOW_CROSS=1
|
||||||
|
ENV PKG_CONFIG_PATH_arm-unknown-linux-gnueabihf=/usr/lib/arm-linux-gnueabihf/pkgconfig/
|
||||||
|
ENV C_INCLUDE_PATH=/sysroot/usr/include
|
||||||
|
ENV OPENSSL_LIB_DIR=/sysroot/usr/lib/arm-linux-gnueabihf
|
||||||
|
ENV OPENSSL_INCLUDE_DIR=/sysroot/usr/include/arm-linux-gnueabihf
|
||||||
|
|
||||||
|
ADD . /src
|
||||||
|
WORKDIR /src
|
||||||
|
CMD ["/src/contrib/cross-compile-armv6hf/docker-build.sh"]
|
14
contrib/cross-compile-armv6hf/docker-build.sh
Executable file
14
contrib/cross-compile-armv6hf/docker-build.sh
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
PI1_TOOLS_DIR="/pi/tools/arm-bcm2708/arm-linux-gnueabihf"
|
||||||
|
|
||||||
|
PI1_LIB_DIRS=(
|
||||||
|
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/lib"
|
||||||
|
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/usr/lib"
|
||||||
|
"/sysroot/usr/lib/arm-linux-gnueabihf"
|
||||||
|
"/sysroot/lib/arm-linux-gnueabihf"
|
||||||
|
)
|
||||||
|
export RUSTFLAGS="-C linker=$PI1_TOOLS_DIR/bin/arm-linux-gnueabihf-gcc ${PI1_LIB_DIRS[*]/#/-L}"
|
||||||
|
|
||||||
|
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
|
|
@ -1,17 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# largerly inspired by https://github.com/Spotifyd/spotifyd/blob/993336f7/.github/workflows/cd.yml#L109
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
# See https://github.com/raspberrypi/tools/commit/5caa7046
|
|
||||||
# Since this commit is not (yet) contained in what is downloaded in Dockerfile, we use the target of the symlink directly
|
|
||||||
PI1_TOOLS_DIR="/pi-tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf"
|
|
||||||
|
|
||||||
PI1_LIB_DIRS=(
|
|
||||||
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/lib"
|
|
||||||
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/usr/lib"
|
|
||||||
)
|
|
||||||
export RUSTFLAGS="-C linker=$PI1_TOOLS_DIR/bin/arm-linux-gnueabihf-gcc ${PI1_LIB_DIRS[@]/#/-L}"
|
|
||||||
|
|
||||||
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
|
|
Loading…
Reference in a new issue