docker-build-pi-armv6hf.sh 1.5 KB

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