Skip to content

Commit

Permalink
Cross compilation for Raspberry PI
Browse files Browse the repository at this point in the history
Adding cross compilation script based on https://github.com/rust-embedded/cross.
In order to the generated binary work on Raspbian, OpenSSL is linked statically.

This script required docker and will generate an image named
`rust-aws-ddns/base-armhf-img`.
  • Loading branch information
alessandroasm committed Oct 26, 2020
1 parent f89f579 commit 06ea455
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 66 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
openssl = { version = "0.10", features = ["vendored"], optional = true }

clap = "2.33"
csv = "1.1"
serde = { version = "1", features = ["derive"] }
Expand Down
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.armv7-unknown-linux-gnueabihf]
image = "rust-aws-ddns/base-armhf-img:latest"
3 changes: 3 additions & 0 deletions cross-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
./docker/build-container-armhf.sh
cross build --target armv7-unknown-linux-gnueabihf --features openssl
66 changes: 0 additions & 66 deletions cross-compile.md

This file was deleted.

12 changes: 12 additions & 0 deletions docker/Dockerfile-armhf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.1

# libssl-dev:armhf && \

RUN dpkg --add-architecture armhf && \
apt-get update && \
apt-get install --assume-yes \
openssl:armhf \
libssl-dev:armhf \
&& rm -rf /var/lib/apt/lists/*

ENV PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
3 changes: 3 additions & 0 deletions docker/build-container-armhf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cd "$(dirname "$0")"
docker build -t rust-aws-ddns/base-armhf-img -f Dockerfile-armhf .

0 comments on commit 06ea455

Please sign in to comment.