Skip to content

Commit 84bf772

Browse files
authored
Merge pull request #598 from gojimmypi/pr-cmake-improvements
CMake Improvements
2 parents 95b91b8 + f202980 commit 84bf772

Some content is hidden

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

55 files changed

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

0 commit comments

Comments
 (0)