Skip to content

Commit 2a1447d

Browse files
authored
Merge pull request #1263 from gpajot/dev
fix: working armv6hf docker image for cross-compiling
2 parents 98c5277 + 262fc2e commit 2a1447d

4 files changed

Lines changed: 64 additions & 24 deletions

File tree

contrib/Dockerfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Build the docker image from the root of the project with the following command :
33
# $ docker build -t librespot-cross -f contrib/Dockerfile .
44
#
5-
# The resulting image can be used to build librespot for linux x86_64, armhf(with support for armv6hf), armel, mipsel, aarch64
5+
# The resulting image can be used to build librespot for linux x86_64, armhf, armel, mipsel, aarch64
66
# $ docker run -v /tmp/librespot-build:/build librespot-cross
77
#
88
# The compiled binaries will be located in /tmp/librespot-build
@@ -13,8 +13,6 @@
1313
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
1414
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
1515

16-
# $ docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
17-
1816
FROM debian:stretch
1917

2018
RUN dpkg --add-architecture arm64
@@ -40,10 +38,6 @@ RUN mkdir /.cargo && \
4038
echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' >> /.cargo/config && \
4139
echo '[target.mipsel-unknown-linux-gnu]\nlinker = "mipsel-linux-gnu-gcc"' >> /.cargo/config
4240

43-
RUN mkdir /build && \
44-
mkdir /pi-tools && \
45-
curl -L https://github.com/raspberrypi/tools/archive/648a6eeb1e3c2b40af4eb34d88941ee0edeb3e9a.tar.gz | tar xz --strip-components 1 -C /pi-tools
46-
4741
ENV CARGO_TARGET_DIR /build
4842
ENV CARGO_HOME /build/cache
4943
ENV PKG_CONFIG_ALLOW_CROSS=1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Cross compilation environment for librespot in armv6hf.
2+
# Build the docker image from the root of the project with the following command:
3+
# $ docker build -t librespot-cross-armv6hf -f contrib/cross-compile-armv6hf/Dockerfile .
4+
#
5+
# The resulting image can be used to build librespot for armv6hf:
6+
# $ docker run -v /tmp/librespot-build-armv6hf:/build librespot-cross-armv6hf
7+
#
8+
# The compiled binary will be located in /tmp/librespot-build-armv6hf/arm-unknown-linux-gnueabihf/release/librespot
9+
10+
FROM --platform=linux/amd64 ubuntu:18.04
11+
12+
# Install common packages.
13+
RUN apt-get update
14+
RUN apt-get install -y -qq git curl build-essential libasound2-dev libssl-dev libpulse-dev libdbus-1-dev
15+
16+
# Install armhf packages.
17+
RUN echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main" | tee -a /etc/apt/sources.list
18+
RUN apt-get update
19+
RUN apt-get download libasound2:armhf libasound2-dev:armhf libssl-dev:armhf libssl1.1:armhf
20+
RUN mkdir /sysroot && \
21+
dpkg -x libasound2_*.deb /sysroot/ && \
22+
dpkg -x libssl-dev*.deb /sysroot/ && \
23+
dpkg -x libssl1.1*.deb /sysroot/ && \
24+
dpkg -x libasound2-dev*.deb /sysroot/
25+
26+
# Install rust.
27+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
28+
ENV PATH="/root/.cargo/bin/:${PATH}"
29+
RUN rustup target add arm-unknown-linux-gnueabihf
30+
RUN mkdir /.cargo && \
31+
echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config
32+
33+
# Install Pi tools for armv6.
34+
RUN mkdir /pi && \
35+
git -C /pi clone --depth=1 https://github.com/raspberrypi/tools.git
36+
37+
# Build env variables.
38+
ENV CARGO_TARGET_DIR /build
39+
ENV CARGO_HOME /build/cache
40+
ENV PATH="/pi/tools/arm-bcm2708/arm-linux-gnueabihf/bin:${PATH}"
41+
ENV PKG_CONFIG_ALLOW_CROSS=1
42+
ENV PKG_CONFIG_PATH_arm-unknown-linux-gnueabihf=/usr/lib/arm-linux-gnueabihf/pkgconfig/
43+
ENV C_INCLUDE_PATH=/sysroot/usr/include
44+
ENV OPENSSL_LIB_DIR=/sysroot/usr/lib/arm-linux-gnueabihf
45+
ENV OPENSSL_INCLUDE_DIR=/sysroot/usr/include/arm-linux-gnueabihf
46+
47+
ADD . /src
48+
WORKDIR /src
49+
CMD ["/src/contrib/cross-compile-armv6hf/docker-build.sh"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -eux
3+
4+
PI1_TOOLS_DIR="/pi/tools/arm-bcm2708/arm-linux-gnueabihf"
5+
6+
PI1_LIB_DIRS=(
7+
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/lib"
8+
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/usr/lib"
9+
"/sysroot/usr/lib/arm-linux-gnueabihf"
10+
"/sysroot/lib/arm-linux-gnueabihf"
11+
)
12+
export RUSTFLAGS="-C linker=$PI1_TOOLS_DIR/bin/arm-linux-gnueabihf-gcc ${PI1_LIB_DIRS[*]/#/-L}"
13+
14+
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"

contrib/docker-build-pi-armv6hf.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)