Skip to content

Commit

Permalink
Cross-compile for armhf (#5)
Browse files Browse the repository at this point in the history
* Utility script

* Add GitHub action

* Temporarily run on pull requests, too

* Specify output file to use

* Store built application
  • Loading branch information
mthmulders authored Jan 12, 2021
1 parent 6ea6a2b commit 3e6d287
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build-raspberry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build for Raspberry Pi

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Download ARM Toolchain
run: |
pushd /tmp
wget "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz?revision=d0b90559-3960-4e4b-9297-7ddbc3e52783&la=en&hash=985078B758BC782BC338DB947347107FBCF8EF6B" \
-O gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz
tar xf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz
- name: Install Standard Rust library for Raspberry Pi 2/3/4
run: |
rustup target add armv7-unknown-linux-gnueabihf
- name: Perform build
run: |
./cross-compile-armv7.sh
env:
ARMHF_TOOLCHAIN_PATH: "/tmp/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/"

- name: Upload application
uses: actions/upload-artifact@v2
if: github.ref == 'refs/heads/main'
with:
name: dsmr-rs
path: target/armv7-unknown-linux-gnueabihf/release/dsmr-rs
5 changes: 5 additions & 0 deletions cross-compile-armv7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -euo pipefail

PATH=$ARMHF_TOOLCHAIN_PATH/bin:$PATH \
cargo build --target armv7-unknown-linux-gnueabihf --release --features ""

0 comments on commit 3e6d287

Please sign in to comment.