|
| 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"] |
0 commit comments