Skip to content

Commit 9d9c311

Browse files
authored
Merge pull request #184 from ashthespy/armv6hf
Add a armv6hf crossbuild target
2 parents 8f8eb8c + 24cd9aa commit 9d9c311

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

contrib/Dockerfile

Lines changed: 6 additions & 3 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 and armel.
5+
# The resulting image can be used to build librespot for linux x86_64, armhf(with support for armv6hf), 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
@@ -11,7 +11,7 @@
1111
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features "alsa-backend"
1212
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
1313
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "alsa-backend"
14-
#
14+
# $ docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
1515

1616
FROM debian:stretch
1717

@@ -37,7 +37,10 @@ RUN mkdir /.cargo && \
3737
echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' >> /.cargo/config && \
3838
echo '[target.mipsel-unknown-linux-gnu]\nlinker = "mipsel-linux-gnu-gcc"' >> /.cargo/config
3939

40-
RUN mkdir /build
40+
RUN mkdir /build && \
41+
mkdir /pi-tools && \
42+
curl -L https://github.com/raspberrypi/tools/archive/648a6eeb1e3c2b40af4eb34d88941ee0edeb3e9a.tar.gz | tar xz --strip-components 1 -C /pi-tools
43+
4144
ENV CARGO_TARGET_DIR /build
4245
ENV CARGO_HOME /build/cache
4346

contrib/docker-build-pi-armv6hf.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
# Snipped and tucked from https://github.com/plietar/librespot/pull/202/commits/21549641d39399cbaec0bc92b36c9951d1b87b90
4+
# and further inputs from https://github.com/kingosticks/librespot/commit/c55dd20bd6c7e44dd75ff33185cf50b2d3bd79c3
5+
6+
set -eux
7+
# Get alsa lib and headers
8+
ALSA_VER="1.0.25-4"
9+
DEPS=( \
10+
"http://mirrordirector.raspbian.org/raspbian/pool/main/a/alsa-lib/libasound2_${ALSA_VER}_armhf.deb" \
11+
"http://mirrordirector.raspbian.org/raspbian/pool/main/a/alsa-lib/libasound2-dev_${ALSA_VER}_armhf.deb" \
12+
)
13+
14+
# Collect Paths
15+
SYSROOT="/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot"
16+
GCC="/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"
17+
GCC_SYSROOT="$GCC/gcc-sysroot"
18+
19+
20+
export PATH=/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/:$PATH
21+
22+
# Link the compiler
23+
export TARGET_CC="$GCC/arm-linux-gnueabihf-gcc"
24+
25+
# Create wrapper around gcc to point to rpi sysroot
26+
echo -e '#!/bin/bash' "\n$TARGET_CC --sysroot $SYSROOT \"\$@\"" > $GCC_SYSROOT
27+
chmod +x $GCC_SYSROOT
28+
29+
# Add extra target dependencies to our rpi sysroot
30+
for path in "${DEPS[@]}"; do
31+
curl -OL $path
32+
dpkg -x $(basename $path) $SYSROOT
33+
done
34+
35+
# i don't why this is neccessary
36+
# ln -s ld-linux.so.3 $SYSROOT/lib/ld-linux-armhf.so.3
37+
38+
# point cargo to use gcc wrapper as linker
39+
echo -e '[target.arm-unknown-linux-gnueabihf]\nlinker = "gcc-sysroot"' > /.cargo/config
40+
41+
# Build
42+
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"

0 commit comments

Comments
 (0)