Skip to content

Commit 5f04ead

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

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

.github/workflows/pioasm_outputs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CMake
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: Check autogenerated pioasm outputs
22+
run: |
23+
PICO_SDK_PATH=${{github.workspace}}/pico-sdk ./update_pioasm_outputs.sh
24+
if git status --porcelain | grep -q '^ M'; then
25+
echo "::error title=outdated-files::Autogenerated pioasm output files are out of date - update by running update_pioasm_outputs.sh"
26+
exit 1
27+
fi
28+

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)