Skip to content

Commit 0a6698d

Browse files
committed
CMake Improvements
1 parent 6313077 commit 0a6698d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6203
-211
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: wolfboot CMake (.config)
2+
on:
3+
push:
4+
branches: [ 'master', 'main', 'release/**' ]
5+
pull_request:
6+
branches: [ '*' ]
7+
8+
jobs:
9+
wolfboot_dot_config_test:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 15
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: true
17+
18+
- name: Workaround for sources.list
19+
run: |
20+
# Replace sources
21+
22+
set -euxo pipefail
23+
24+
# Peek (what repos are active now)
25+
apt-cache policy
26+
grep -RInE '^(deb|Types|URIs)' /etc/apt || true
27+
28+
# Enable nullglob so *.list/*.sources that don't exist don't break sed
29+
shopt -s nullglob
30+
31+
echo "Replace sources.list (legacy)"
32+
sudo sed -i \
33+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
34+
/etc/apt/sources.list || true
35+
36+
echo "Replace sources.list.d/*.list (legacy)"
37+
for f in /etc/apt/sources.list.d/*.list; do
38+
sudo sed -i \
39+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
40+
"$f"
41+
done
42+
43+
echo "Replace sources.list.d/*.sources (deb822)"
44+
for f in /etc/apt/sources.list.d/*.sources; do
45+
sudo sed -i \
46+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
47+
-e "s|https\?://azure\.archive\.ubuntu\.com|http://mirror.arizona.edu|g" \
48+
"$f"
49+
done
50+
51+
echo "Fix /etc/apt/apt-mirrors.txt (used by URIs: mirror+file:...)"
52+
if grep -qE '^[[:space:]]*https?://azure\.archive\.ubuntu\.com/ubuntu/?' /etc/apt/apt-mirrors.txt; then
53+
# Replace azure with our mirror (idempotent)
54+
sudo sed -i 's|https\?://azure\.archive\.ubuntu\.com/ubuntu/|http://mirror.arizona.edu/ubuntu/|g' /etc/apt/apt-mirrors.txt
55+
fi
56+
57+
# Peek (verify changes)
58+
grep -RIn "azure.archive.ubuntu.com" /etc/apt || true
59+
grep -RInE '^(deb|Types|URIs)' /etc/apt || true
60+
echo "--- apt-mirrors.txt ---"
61+
cat /etc/apt/apt-mirrors.txt || true
62+
63+
64+
- name: Install requirements
65+
run: |
66+
# Run system updates and install toolchain
67+
sudo apt-get update
68+
sudo apt-get install -y gcc-arm-none-eabi gcc-powerpc-linux-gnu cmake
69+
70+
- name: Run dot-config examples
71+
run: |
72+
# Sample .config cmake test
73+
74+
set -euo pipefail
75+
76+
LOG_FILE="run.log"
77+
KEYWORD="Config mode: dot"
78+
echo "Saving output to $LOG_FILE"
79+
80+
echo "Fetch stm32h7 example .config"
81+
cp ./config/examples/stm32h7.config ./.config
82+
ls .config
83+
cat .config
84+
echo ""
85+
86+
echo "Clean"
87+
rm -rf ./build-stm32h7
88+
89+
# Here we should see the .config file values read and displayed:
90+
cmake -S . -B build-stm32h7 \
91+
-DUSE_DOT_CONFIG=ON \
92+
-DWOLFBOOT_TARGET=stm32h7 2>&1 | tee "$LOG_FILE"
93+
94+
# Config dot-config mode
95+
if grep -q -- "$KEYWORD" "$LOG_FILE"; then
96+
echo "Keyword found: $KEYWORD"
97+
else
98+
echo "Keyword not found: $KEYWORD" >&2
99+
exit 1
100+
fi
101+
102+
# Sample build
103+
cmake --build build-stm32h7 --parallel 8
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: WolfBoot CMake Build (macOS)
2+
3+
on:
4+
push:
5+
branches: [ 'master', 'main', 'release/**' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
jobs:
10+
macos-cmake:
11+
name: Build on macOS (CMake + Ninja)
12+
runs-on: macos-14
13+
timeout-minutes: 20
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
target: [stm32l4, stm32h7, stm32c0, stm32g0]
19+
20+
env:
21+
HOMEBREW_NO_AUTO_UPDATE: "1" # avoid updating taps during install
22+
HOMEBREW_NO_ANALYTICS: "1"
23+
HOMEBREW_CURL_RETRIES: "6" # ask curl inside brew to retry
24+
25+
steps:
26+
- name: Checkout (with submodules)
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: true
30+
31+
- name: Cache Homebrew bottles # downloads (so retries don't redownload)
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/Library/Caches/Homebrew
36+
/Users/runner/Library/Caches/Homebrew
37+
key: homebrew-${{ runner.os }}-mac14-cmake-gcc-newlib
38+
restore-keys: |
39+
homebrew-${{ runner.os }}-
40+
41+
- name: Install toolchain and build tools
42+
run: |
43+
# Install with step throttle to hopefully avoid stuck jobs
44+
45+
set -euxo pipefail
46+
47+
throttle_delay=5
48+
brew update
49+
50+
sleep "$throttle_delay"
51+
brew install --force-bottle cmake
52+
53+
sleep "$throttle_delay"
54+
brew install --force-bottle ninja
55+
56+
# Use cask to include headers such as <stdlib.h>
57+
sleep "$throttle_delay"
58+
brew install --cask gcc-arm-embedded
59+
60+
- name: Probe ARM GCC (paths + smoke build)
61+
run: |
62+
set -euxo pipefail
63+
64+
which arm-none-eabi-gcc
65+
arm-none-eabi-gcc --version
66+
67+
echo "=== GCC search dirs ==="
68+
arm-none-eabi-gcc -print-search-dirs
69+
70+
echo "=== GCC verbose include paths (preprocess only) ==="
71+
# This prints the built-in include search order; harmless with empty stdin.
72+
arm-none-eabi-gcc -x c -E -v - < /dev/null || true
73+
74+
echo "=== Compile a freestanding object (no stdlib headers needed) ==="
75+
cat > hello.c <<'EOF'
76+
int main(void) { return 0; }
77+
EOF
78+
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -ffreestanding -nostdlib -c hello.c -o hello.o
79+
ls -l hello.o
80+
81+
- name: Configure (STM32L4)
82+
run: |
83+
echo "Disabled, missing params"
84+
# rm -rf build
85+
# cmake -B build -G Ninja \
86+
# -DWOLFBOOT_CONFIG_MODE=preset \
87+
# -DWOLFBOOT_TARGET=stm32l4 \
88+
# -DBUILD_TEST_APPS=ON \
89+
# -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_arm-none-eabi.cmake
90+
91+
- name: Cmake Configure & Build Preset (${{ matrix.target }})
92+
run: |
93+
rm -rf ./build-${{ matrix.target }}
94+
95+
cmake --preset ${{ matrix.target }}
96+
cmake --build --preset ${{ matrix.target }}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: WolfBoot CMake Presets Build
2+
3+
on:
4+
push:
5+
# TODO: branches: [ 'master', 'main', 'release/**' ]
6+
branches: [ '*' ]
7+
pull_request:
8+
branches: [ "*" ]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
ubuntu-cmake:
15+
name: Build on Ubuntu
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 20
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
target:
26+
- stm32l4
27+
- stm32h7
28+
- stm32g0
29+
include:
30+
# Optional per-target cache variables you might want to pass later.
31+
# Keep empty for now to avoid guessing addresses.
32+
- target: stm32l4
33+
extra_cache: ""
34+
- target: stm32h7
35+
extra_cache: ""
36+
- target: stm32g0
37+
extra_cache: ""
38+
39+
steps:
40+
- name: Checkout (with submodules)
41+
uses: actions/checkout@v4
42+
with:
43+
submodules: true
44+
45+
# Lock down network/runner
46+
# See https://github.com/step-security/harden-runner/releases
47+
# Currently only supported on Ubuntu
48+
49+
# ARM GCC toolchain (adds the bin dir to PATH)
50+
- name: Set up ARM none-eabi GCC 14.x
51+
uses: carlosperate/arm-none-eabi-gcc-action@v1
52+
with:
53+
release: "14.2.Rel1" # <-- use 'release', not 'version'
54+
path-env-var: ARM_NONE_EABI_GCC_PATH
55+
56+
57+
- name: List all environment variables
58+
run: |
59+
# Show environment settings
60+
61+
echo "All environment settings"
62+
env | sort
63+
64+
- name: List Presets
65+
run: |
66+
# Check available presets in CMakePresets.json
67+
68+
cmake -S . -B build-list --list-presets=configure
69+
70+
- name: Configure Preset "${{ matrix.target }}"
71+
run: |
72+
# cmake runs in git bash
73+
74+
cmake --preset "${{ matrix.target }}"
75+
echo "Configured: ${{ matrix.target }}"
76+
77+
- name: Build "${{ matrix.target }}"
78+
run: |
79+
# cmake runs in git bash
80+
# BUILD_DIR="build-${{ matrix.target }}"
81+
cmake --build "build-${{ matrix.target }}" --parallel
82+
83+
# Optional: show interesting artifacts
84+
- name: List build outputs
85+
if: always()
86+
run: |
87+
BUILD_DIR="build-${{ matrix.target }}"
88+
echo "=== Artifacts in $BUILD_DIR ==="
89+
find "$BUILD_DIR" -maxdepth 3 -type f \( -name "*.elf" -o -name "*.bin" -o -name "*.hex" -o -name "bin-assemble" -o -name "keystore" \) -print || true
90+
91+
# Upload binaries if present (non-fatal if none)
92+
- name: Upload firmware/artifacts
93+
if: always()
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: wolfboot-${{ matrix.target }}
97+
path: |
98+
build-${{ matrix.target }}/**/*.elf
99+
build-${{ matrix.target }}/**/*.bin
100+
build-${{ matrix.target }}/**/*.hex
101+
if-no-files-found: warn
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: wolfboot CMake Script
2+
on:
3+
push:
4+
branches: [ 'master', 'main', 'release/**' ]
5+
pull_request:
6+
branches: [ '*' ]
7+
jobs:
8+
wolfboot_build_script_test:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 15
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
submodules: true
16+
17+
- name: Workaround for sources.list
18+
run: |
19+
# Replace sources
20+
21+
set -euxo pipefail
22+
23+
# Peek (what repos are active now)
24+
apt-cache policy
25+
grep -RInE '^(deb|Types|URIs)' /etc/apt || true
26+
27+
# Enable nullglob so *.list/*.sources that don't exist don't break sed
28+
shopt -s nullglob
29+
30+
echo "Replace sources.list (legacy)"
31+
sudo sed -i \
32+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
33+
/etc/apt/sources.list || true
34+
35+
echo "Replace sources.list.d/*.list (legacy)"
36+
for f in /etc/apt/sources.list.d/*.list; do
37+
sudo sed -i \
38+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
39+
"$f"
40+
done
41+
42+
echo "Replace sources.list.d/*.sources (deb822)"
43+
for f in /etc/apt/sources.list.d/*.sources; do
44+
sudo sed -i \
45+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
46+
-e "s|https\?://azure\.archive\.ubuntu\.com|http://mirror.arizona.edu|g" \
47+
"$f"
48+
done
49+
50+
echo "Fix /etc/apt/apt-mirrors.txt (used by URIs: mirror+file:...)"
51+
if grep -qE '^[[:space:]]*https?://azure\.archive\.ubuntu\.com/ubuntu/?' /etc/apt/apt-mirrors.txt; then
52+
# Replace azure with our mirror (idempotent)
53+
sudo sed -i 's|https\?://azure\.archive\.ubuntu\.com/ubuntu/|http://mirror.arizona.edu/ubuntu/|g' /etc/apt/apt-mirrors.txt
54+
fi
55+
56+
# Peek (verify changes)
57+
grep -RIn "azure.archive.ubuntu.com" /etc/apt || true
58+
grep -RInE '^(deb|Types|URIs)' /etc/apt || true
59+
echo "--- apt-mirrors.txt ---"
60+
cat /etc/apt/apt-mirrors.txt || true
61+
62+
63+
- name: Install requirements
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y gcc-arm-none-eabi gcc-powerpc-linux-gnu cmake
67+
68+
- name: Run wolfboot_build script
69+
run: |
70+
rm -rf ./build
71+
72+
./tools/scripts/wolfboot_cmake_full_build.sh --CLEAN "stm32l4"
73+
./tools/scripts/wolfboot_cmake_full_build.sh --target "stm32l4"
74+
75+
./tools/scripts/wolfboot_cmake_full_build.sh --CLEAN "stm32g0"
76+
./tools/scripts/wolfboot_cmake_full_build.sh --target "stm32g0"

0 commit comments

Comments
 (0)