Skip to content

Commit

Permalink
Split the build.
Browse files Browse the repository at this point in the history
Now the examples has a job, and building the examples in Ferrocene has a job.
  • Loading branch information
jonathanpallant committed Oct 18, 2024
1 parent 2b81db5 commit e68ef98
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 28 deletions.
95 changes: 81 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

jobs:
build:
build-slides:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -21,29 +21,16 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/ferrous-systems/mdslides/releases/download/v0.4.0/mdslides-installer.sh | sh
- 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 @@ -69,3 +56,83 @@ jobs:
uses: ncipollo/release-action@v1
with:
artifacts: ./rust-training-${{ env.slug }}.zip

build-examples-ferrocene:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
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-ferrocene-examples-${{ env.slug }}..."
mkdir -p ./rust-training-ferrocene-examples-${{ env.slug }}
cp -r ./example-code ./rust-training-ferrocene-examples-${{ env.slug }}
echo "Compressing ./rust-training-ferrocene-examples-${{ env.slug }}.zip..."
zip -r ./rust-training-ferrocene-examples-${{ env.slug }}.zip ./rust-training-ferrocene-examples-${{ env.slug }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: Artifacts
if-no-files-found: error
path: |
./rust-training-ferrocene-examples-*/
build-examples:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v4

- name: Add Rust Targets
run: |
rustup target add thumbv7em-none-eabihf
rustup target add armv7r-none-eabihf
rustup target add aarch64-unknown-none
- 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-examples-${{ env.slug }}..."
mkdir -p ./rust-training-examples-${{ env.slug }}
cp -r ./example-code ./rust-training-examples-${{ env.slug }}
echo "Compressing ./rust-training-examples-${{ env.slug }}.zip..."
zip -r ./rust-training-examples-${{ env.slug }}.zip ./rust-training-examples-${{ env.slug }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: Artifacts
if-no-files-found: error
path: |
./rust-training-examples-*/
19 changes: 19 additions & 0 deletions example-code/build-ferrocene.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/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
criticalup run cargo clean
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
criticalup run cargo clean
popd
19 changes: 9 additions & 10 deletions example-code/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ 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 --target=armv7r-none-eabihf
cargo clean
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
cargo clean
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 e68ef98

Please sign in to comment.