Skip to content

Commit 7bf380a

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

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/pioasm_outputs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check pioasm output files
2+
on: [push, pull_request]
3+
4+
jobs:
5+
check-pioasm-outputs:
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
12+
uses: actions/checkout@v4
13+
14+
- name: Checkout pico-sdk/develop
15+
uses: actions/checkout@v4
16+
with:
17+
repository: raspberrypi/pico-sdk
18+
ref: develop
19+
path: pico-sdk
20+
21+
- name: Rebuild pioasm outputs
22+
run: PICO_SDK_PATH=${{github.workspace}}/pico-sdk ./update_pioasm_outputs.sh
23+
24+
- name: Check pioasm outputs for changes
25+
run: |
26+
if git status --porcelain | grep -q '^ M'; then
27+
echo "::error title=outdated-files::Autogenerated pioasm output files are out of date - update by running update_pioasm_outputs.sh"
28+
exit 1
29+
fi
30+

update_pioasm_outputs.sh

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

0 commit comments

Comments
 (0)