Skip to content

Commit 76491dd

Browse files
committed
Add script (and CI check) to check / update the autogenerated pioasm outputs
1 parent 4c3a3dc commit 76491dd

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CMake
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
# Prevent running twice for PRs from same repo
7+
if: github.repository_owner == 'raspberrypi' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
8+
runs-on: [self-hosted, Linux, X64]
9+
10+
steps:
11+
- name: Checkout pico-examples
12+
uses: actions/checkout@v4
13+
with:
14+
path: pico-examples
15+
16+
- name: Checkout pico-sdk/develop
17+
uses: actions/checkout@v4
18+
with:
19+
repository: raspberrypi/pico-sdk
20+
ref: develop
21+
path: pico-sdk
22+
23+
- name: Check autogenerated pioasm outputs
24+
working-directory: ${{github.workspace}}/pico-examples
25+
run: |
26+
PICO_SDK_PATH=${{github.workspace}}/pico-sdk ./update_pioasm_outputs.sh
27+
if git status --porcelain | grep -q '^ M'; then
28+
echo "::error title=outdated-files::Autogenerated pioasm output files are out of date - update by running update_pioasm_outputs.sh"
29+
exit 1
30+
fi
31+

update_pioasm_outputs.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Helper-script to update the pioasm-generated files in pico-examples repo
3+
PIOASM_COMMENT_STRING="This file is autogenerated by pioasm"
4+
if [ -z $PICO_SDK_PATH ]; then
5+
echo "PICO_SDK_PATH envvar not set"
6+
exit 1
7+
fi
8+
if [ ! -d $PICO_SDK_PATH ]; then
9+
echo "PICO_SDK_PATH envvar ($PICO_SDK_PATH) is invalid"
10+
exit 1
11+
fi
12+
# convert to absolute path
13+
PICO_SDK_PATH=$(realpath $PICO_SDK_PATH)
14+
BUILD_DIR=$(mktemp -d -p .)
15+
cleanup() {
16+
if [[ -d "$BUILD_DIR" ]]; then
17+
rm -rf "$BUILD_DIR"
18+
fi
19+
}
20+
trap cleanup EXIT
21+
PIOASM_OUTPUT_DIRS=()
22+
while read -r DIRNAME; do
23+
PIOASM_OUTPUT_DIRS+=("$DIRNAME")
24+
done <<< "$(git grep -l "$PIOASM_COMMENT_STRING" | cut -d/ -f1-2 | sort | uniq)"
25+
while read -r FILENAME; do
26+
rm "$FILENAME"
27+
done <<< "$(git grep -l "$PIOASM_COMMENT_STRING")"
28+
cmake -S . -B "$BUILD_DIR" -DPICO_SDK_PATH=$PICO_SDK_PATH -DPICO_NO_PICOTOOL=1
29+
for DIRNAME in "${PIOASM_OUTPUT_DIRS[@]}"; do
30+
make -j4 -C "$BUILD_DIR/$DIRNAME"
31+
done
32+
cleanup

0 commit comments

Comments
 (0)