mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Add Dockerfile for cross compilation
This commit is contained in:
parent
7b77d5b87d
commit
f5a4feeb90
6 changed files with 68 additions and 1 deletions
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target
|
|
@ -88,5 +88,5 @@ section = "sound"
|
||||||
priority = "optional"
|
priority = "optional"
|
||||||
assets = [
|
assets = [
|
||||||
["target/release/librespot", "usr/bin/", "755"],
|
["target/release/librespot", "usr/bin/", "755"],
|
||||||
["assets/librespot.service", "lib/systemd/system/", "644"]
|
["contrib/librespot.service", "lib/systemd/system/", "644"]
|
||||||
]
|
]
|
||||||
|
|
22
README.md
22
README.md
|
@ -60,6 +60,28 @@ The following backends are currently available :
|
||||||
- PortAudio
|
- PortAudio
|
||||||
- PulseAudio
|
- PulseAudio
|
||||||
|
|
||||||
|
## Cross-compiling
|
||||||
|
A cross compilation environment is provided as a docker image.
|
||||||
|
Build the image from the root of the project with the following command :
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker build -t librespot-cross -f contrib/Dockerfile .
|
||||||
|
```
|
||||||
|
|
||||||
|
The resulting image can be used to build librespot for linux x86_64, armhf and armel.
|
||||||
|
The compiled binaries will be located in /tmp/librespot-build
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -v /tmp/librespot-build:/build librespot-cross
|
||||||
|
```
|
||||||
|
|
||||||
|
If only one architecture is desired, cargo can be invoked directly with the appropriate options :
|
||||||
|
```shell
|
||||||
|
docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
When developing *librespot*, it is preferable to use Rust nightly, and build it using the following :
|
When developing *librespot*, it is preferable to use Rust nightly, and build it using the following :
|
||||||
```shell
|
```shell
|
||||||
|
|
38
contrib/Dockerfile
Normal file
38
contrib/Dockerfile
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Cross compilation environment for librespot
|
||||||
|
# Build the docker image from the root of the project with the following command :
|
||||||
|
# $ docker build -t librespot-cross -f contrib/Dockerfile .
|
||||||
|
#
|
||||||
|
# The resulting image can be used to build librespot for linux x86_64, armhf and armel.
|
||||||
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross
|
||||||
|
#
|
||||||
|
# The compiled binaries will be located in /tmp/librespot-build
|
||||||
|
#
|
||||||
|
# If only one architecture is desired, cargo can be invoked directly with the appropriate options :
|
||||||
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
#
|
||||||
|
|
||||||
|
FROM debian:stretch
|
||||||
|
|
||||||
|
RUN dpkg --add-architecture armhf
|
||||||
|
RUN dpkg --add-architecture armel
|
||||||
|
RUN apt-get update
|
||||||
|
|
||||||
|
RUN apt-get install -y curl build-essential crossbuild-essential-armhf crossbuild-essential-armel
|
||||||
|
RUN apt-get install -y libasound2-dev libasound2-dev:armhf libasound2-dev:armel
|
||||||
|
|
||||||
|
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||||
|
ENV PATH="/root/.cargo/bin/:${PATH}"
|
||||||
|
RUN rustup target add arm-unknown-linux-gnueabi
|
||||||
|
RUN rustup target add arm-unknown-linux-gnueabihf
|
||||||
|
|
||||||
|
RUN echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' > ~/.cargo/config
|
||||||
|
RUN echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' > ~/.cargo/config
|
||||||
|
|
||||||
|
RUN mkdir /build
|
||||||
|
ENV CARGO_TARGET_DIR /build
|
||||||
|
|
||||||
|
ADD . /src
|
||||||
|
WORKDIR /src
|
||||||
|
CMD ["/src/contrib/docker-build.sh"]
|
6
contrib/docker-build.sh
Executable file
6
contrib/docker-build.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
cargo build --release --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "with-syntex alsa-backend"
|
||||||
|
cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "with-syntex alsa-backend"
|
Loading…
Reference in a new issue