Skip to content

Commit f9de18f

Browse files
committed
Convert stm32-blink to SwiftPM
Replaces bespoke shell scripts with a SwiftPM based build for the stm32-blink example. Adds CI for MachO based examples. Future: enable ELF variants of all MachO STM32 examples.
1 parent 57e8f6a commit f9de18f

32 files changed

+4314
-556
lines changed

.github/actions/install-swift/action.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ runs:
77
- name: Setup Environment
88
shell: bash
99
run: |
10+
mkdir -p "$HOME/.local/share"
11+
1012
export SWIFTLY_TOOLCHAINS_DIR="$HOME/.local/share/swiftly/toolchains"
1113
echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $GITHUB_ENV
1214
echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $HOME/.bashrc
@@ -22,15 +24,15 @@ runs:
2224
echo "PATH=$SWIFTLY_BIN_DIR:$PATH" >> $GITHUB_ENV
2325
echo "PATH=\$SWIFTLY_BIN_DIR:\$PATH" >> $HOME/.bashrc
2426
25-
- name: "Restore: Swift"
27+
- name: Restore Swift
2628
uses: actions/cache/restore@v4
2729
id: cache-swift
2830
with:
2931
path: "~/.local/share/swiftly"
30-
key: swift-${{ hashFiles('**/.swift-version') }}
32+
key: swift-${{ runner.os }}-${{ hashFiles('**/.swift-version', '.github/actions/install-swift/action.yml') }}
3133

3234
- name: Install `apt` Dependencies
33-
if: steps.cache-swift.outputs.cache-hit != 'true'
35+
if: runner.os == 'Linux' && steps.cache-swift.outputs.cache-hit != 'true'
3436
shell: bash
3537
run: |
3638
SUDO=$(if [[ $EUID -ne 0 ]]; then echo sudo; fi)
@@ -40,29 +42,47 @@ runs:
4042
DEBIAN_FRONTEND: noninteractive
4143

4244
- name: Install Swiftly
43-
if: steps.cache-swift.outputs.cache-hit != 'true'
45+
if: runner.os == 'Linux' && steps.cache-swift.outputs.cache-hit != 'true'
4446
shell: bash
4547
run: |
48+
SWIFTLY_VERSION=1.0.1
4649
UNAME=$(uname -m)
47-
curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
48-
tar zxf "swiftly-$UNAME.tar.gz"
50+
SWIFTLY_TGZ=swiftly-$SWIFTLY_VERSION-$UNAME.tar.gz
51+
curl -O "https://download.swift.org/swiftly/linux/$SWIFTLY_TGZ"
52+
tar zxf "$SWIFTLY_TGZ"
4953
./swiftly init \
5054
--skip-install \
5155
--assume-yes \
5256
--quiet-shell-followup \
5357
--no-modify-profile
5458
59+
- name: Install Swiftly
60+
if: runner.os == 'macOS' && steps.cache-swift.outputs.cache-hit != 'true'
61+
shell: bash
62+
run: |
63+
SWIFTLY_VERSION=1.0.1
64+
SWIFTLY_PKG=swiftly-$SWIFTLY_VERSION.pkg
65+
curl -O "https://download.swift.org/swiftly/darwin/$SWIFTLY_PKG"
66+
pkgutil --check-signature $SWIFTLY_PKG
67+
pkgutil --verbose --expand $SWIFTLY_PKG $SWIFTLY_HOME_DIR
68+
tar -C $SWIFTLY_HOME_DIR -xvf $SWIFTLY_HOME_DIR/swiftly-*/Payload
69+
"$SWIFTLY_BIN_DIR/swiftly" init \
70+
--skip-install \
71+
--assume-yes \
72+
--quiet-shell-followup \
73+
--no-modify-profile
74+
5575
- name: Install Swift
5676
if: steps.cache-swift.outputs.cache-hit != 'true'
5777
shell: bash
5878
run: swiftly install --post-install-file ./out.sh
5979

60-
- name: "Save: Swift"
80+
- name: Save Swift
6181
if: steps.cache-swift.outputs.cache-hit != 'true'
6282
uses: actions/cache/save@v4
6383
with:
6484
path: "~/.local/share/swiftly"
65-
key: swift-${{ hashFiles('**/.swift-version') }}
85+
key: swift-${{ runner.os }}-${{ hashFiles('**/.swift-version', '.github/actions/install-swift/action.yml') }}
6686

6787
- name: Print Swift Version
6888
shell: bash

.github/workflows/build-esp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: ESP
33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/build-nuttx.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: NuttX
33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/build-rpi-baremetal.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Raspberry Pi Baremetal
33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/build-rpi-pico-sdk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Raspberry Pi Pico SDK
33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: STM32
1+
name: STM32 ELF
22

33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:
@@ -15,16 +15,12 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
example: [stm32-blink, stm32-lvgl]
18+
example: [stm32-lvgl]
1919

2020
steps:
2121
- name: Checkout repo
2222
uses: actions/checkout@v4
2323

24-
- name: Fixup for running locally in act
25-
if: ${{ env.ACT }}
26-
run: echo /opt/acttoolcache/node/18.20.8/x64/bin >> $GITHUB_PATH
27-
2824
- name: Set up Python
2925
uses: actions/setup-python@v5
3026
with:
@@ -36,21 +32,13 @@ jobs:
3632
- name: Install Swift
3733
uses: ./.github/actions/install-swift
3834

39-
- name: Set environment variables
40-
run: |
41-
echo "STM_BOARD=STM32F746G_DISCOVERY" >> $GITHUB_ENV
42-
4335
- name: Build ${{ matrix.example }}
4436
working-directory: ${{ matrix.example }}
4537
run: |
4638
if [[ -f ./fetch-dependencies.sh ]]; then
4739
./fetch-dependencies.sh
4840
fi
4941
50-
if [[ -f ./build-elf.sh ]]; then
51-
./build-elf.sh
52-
fi
53-
5442
if [[ -f Makefile ]]; then
5543
make
5644
fi
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: STM32 Macho
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
types: [opened, reopened, synchronize, ready_for_review]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: [self-hosted, macos, sequoia, ARM64]
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
example: [stm32-blink] #, stm32-lcd-logo, stm32-neopixel, stm32-uart-echo]
19+
20+
steps:
21+
- name: Checkout repo
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: 3.11
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
31+
32+
- name: Install Swift
33+
uses: ./.github/actions/install-swift
34+
35+
- name: Build ${{ matrix.example }}
36+
working-directory: ${{ matrix.example }}
37+
run: make

.github/workflows/build-zephyr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Zephyr
33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Lint
33
on:
44
push:
55
branches: ["main"]
6-
pull_request:
7-
types: [opened, reopened, synchronize, ready_for_review]
6+
# pull_request:
7+
# types: [opened, reopened, synchronize, ready_for_review]
88
workflow_dispatch:
99

1010
jobs:

.swiftformatignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
./harmony/*
2-
./stm32-lvgl/*
2+
./stm32-blink/Sources/STM32F7X6/*
33
./stm32-lcd-logo/Sources/STM32F7X6/*
4+
./stm32-lvgl/*
45
./stm32-lvgl/Sources/Registers/*
56
./stm32-neopixel/Sources/STM32F7X6/*
67
./stm32-uart-echo/Sources/STM32F7X6/*

0 commit comments

Comments
 (0)