Skip to content

Commit

Permalink
Merge pull request #219 from ferrous-systems/split-build
Browse files Browse the repository at this point in the history
Split the build.
  • Loading branch information
jonathanpallant authored Oct 21, 2024
2 parents 4cce827 + b841a33 commit 2efc6dc
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 34 deletions.
92 changes: 75 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ on:
pull_request:

jobs:
build:
build-slides:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v4

Expand All @@ -25,29 +23,16 @@ jobs:
run: |
rustup update stable
- name: Add Rust Targets
run: |
rustup target add thumbv7em-none-eabihf
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/ferrocene/criticalup/releases/download/v1.1.0/criticalup-installer.sh | sh
- name: Find slug name
run: |
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "slug=${slug}" >> "${GITHUB_ENV}"
- name: Build book-and-slides
env:
CRITICALUP_TOKEN: ${{ secrets.CRITICALUP_TOKEN }}
run: |
cd ./training-slides && ./build.sh
- name: Build example code
env:
CRITICALUP_TOKEN: ${{ secrets.CRITICALUP_TOKEN }}
run: |
cd ./example-code && ./build.sh
- name: Assemble Artifacts
run: |
echo "Making ./rust-training-${{ env.slug }}..."
Expand All @@ -62,7 +47,7 @@ jobs:
uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: Artifacts
name: Slides
if-no-files-found: error
path: |
./rust-training-*/
Expand All @@ -73,3 +58,76 @@ jobs:
uses: ncipollo/release-action@v1
with:
artifacts: ./rust-training-${{ env.slug }}.zip

build-examples-ferrocene:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Install Critical Up
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/ferrocene/criticalup/releases/download/v1.1.0/criticalup-installer.sh | sh
- name: Find slug name
run: |
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "slug=${slug}" >> "${GITHUB_ENV}"
- name: Build example code
env:
CRITICALUP_TOKEN: ${{ secrets.CRITICALUP_TOKEN }}
run: |
cd ./example-code && ./build-ferrocene.sh
- name: Assemble Artifacts
run: |
echo "Making ./rust-training-${{ env.slug }}..."
mkdir -p ./rust-training-${{ env.slug }}
cp -r ./example-code ./rust-training-${{ env.slug }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: Ferrocene Examples
if-no-files-found: error
path: |
./rust-training-*/
build-examples:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Add Rust Targets and Tools
run: |
rustup target add thumbv7em-none-eabihf
rustup target add armv7r-none-eabihf
rustup target add aarch64-unknown-none
rustup component add llvm-tools-preview
- name: Find slug name
run: |
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "slug=${slug}" >> "${GITHUB_ENV}"
- name: Build example code
run: |
cd ./example-code && ./build.sh
- name: Assemble Artifacts
run: |
echo "Making ./rust-training-${{ env.slug }}..."
mkdir -p ./rust-training-${{ env.slug }}
cp -r ./example-code ./rust-training-${{ env.slug }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: Examples
if-no-files-found: error
path: |
./rust-training-*/
17 changes: 17 additions & 0 deletions example-code/build-ferrocene.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

# Build qemu Aarch64 Armv8-A example
pushd ./qemu-aarch64v8a
criticalup install
./build.sh "$(criticalup which rustc)"
criticalup run cargo build --release
popd
# And the qemu Aarch32 Armv8-R/Armv7-R example
pushd ./qemu-aarch32v78r
criticalup install
./build.sh "$(criticalup which rustc)"
criticalup run cargo build --release
criticalup run cargo build --target=armv7r-none-eabihf --release
popd
20 changes: 7 additions & 13 deletions example-code/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ set -euo pipefail
pushd ./native/ffi/use-c-in-rust
cargo build --all
cargo test
cargo clean
popd
pushd ./native/stdout
cargo build --all
cargo clean
popd
# And the C based example
pushd native/ffi/use-rust-in-c
Expand All @@ -20,20 +18,16 @@ popd
# And the nRF52 examples
pushd ./nrf52/bsp_demo
cargo build --release
cargo clean
popd
# And the qemu Aarch64 Armv8-A example
# Build qemu Aarch64 Armv8-A example
pushd ./qemu-aarch64v8a
criticalup install
./build.sh
criticalup run cargo build --release
criticalup run cargo clean
cargo build
popd
# And the qemu Aarch32 Armv8-R/Armv7-R example
# Build qemu Aarch32 Armv8-R/Armv7-R example
pushd ./qemu-aarch32v78r
criticalup install
./build.sh
criticalup run cargo build --release
criticalup run cargo build --target=armv7r-none-eabihf --release
criticalup run cargo clean
# Can't use the shell script or the default target becuase armv8r isn't available
# outside Ferrocene
# ./build.sh
cargo build --target=armv7r-none-eabihf
popd
9 changes: 7 additions & 2 deletions example-code/qemu-aarch32v78r/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -euo pipefail

TARGET_DIR=target/production
RUSTC=$(criticalup which rustc)
SYSROOT=$(criticalup run rustc --print sysroot)
RUSTC="${1:-rustc}"
SYSROOT=$("${RUSTC}" --print sysroot)
OBJDUMP=$(ls "${SYSROOT}"/lib/rustlib/*/bin/llvm-objdump)
RUSTC_FLAGS="--target armv8r-none-eabihf -Ctarget-cpu=cortex-r52 -Copt-level=s"

Expand All @@ -18,6 +18,11 @@ NO_HEAP_OUTPUT_ASM=${TARGET_DIR}/no_heap.asm
rm -rf ${TARGET_DIR}
mkdir -p ${TARGET_DIR}

# ############################################################################
echo "Printing version"
# ############################################################################
"${RUSTC}" --version

# ############################################################################
echo "Running rustc for critical-section"
# ############################################################################
Expand Down
9 changes: 7 additions & 2 deletions example-code/qemu-aarch64v8a/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -euo pipefail

TARGET_DIR=target/production
RUSTC=$(criticalup which rustc)
SYSROOT=$(criticalup run rustc --print sysroot)
RUSTC="${1:-rustc}"
SYSROOT=$("${RUSTC}" --print sysroot)
OBJDUMP=$(ls "${SYSROOT}"/lib/rustlib/*/bin/llvm-objdump)
RUSTC_FLAGS="--target aarch64-unknown-none -Copt-level=s"

Expand All @@ -18,6 +18,11 @@ NO_HEAP_OUTPUT_ASM=${TARGET_DIR}/no_heap.asm
rm -rf ${TARGET_DIR}
mkdir -p ${TARGET_DIR}

# ############################################################################
echo "Printing version"
# ############################################################################
"${RUSTC}" --version

# ############################################################################
echo "Running rustc for critical-section"
# ############################################################################
Expand Down

0 comments on commit 2efc6dc

Please sign in to comment.