Skip to content

Commit 016719c

Browse files
committed
added a new job to build every header individually to prevent include errors
1 parent 3616178 commit 016719c

File tree

1 file changed

+62
-4
lines changed

1 file changed

+62
-4
lines changed

.github/workflows/build.yml

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ env:
1212

1313
jobs:
1414
build:
15-
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
16-
# You can convert this to a matrix build if you need cross-platform coverage.
17-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
1815
runs-on: ubuntu-latest
1916

2017
strategy:
@@ -98,4 +95,65 @@ jobs:
9895
${{github.workspace}}/build/project/klib.memory
9996
${{github.workspace}}/build/project/klib.hex
10097
${{github.workspace}}/build/project/klib.bin
101-
${{github.workspace}}/targets/chip/${{matrix.cpu}}/${{matrix.cpu}}.h
98+
${{github.workspace}}/targets/chip/${{matrix.cpu}}/${{matrix.cpu}}.h
99+
100+
individual-header-build:
101+
name: Build each header in its own main.cpp
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: arm-none-eabi-gcc install
107+
uses: carlosperate/[email protected]
108+
with:
109+
release: '13.2.Rel1'
110+
111+
- name: arm-none-eabi-gcc version
112+
run: arm-none-eabi-gcc --version
113+
114+
- name: getting arm headers
115+
uses: actions/checkout@v4
116+
with:
117+
repository: ARM-software/CMSIS_5
118+
ref: 'develop'
119+
fetch-depth: '1'
120+
path: './CMSIS'
121+
122+
- name: moving arm headers
123+
run: |
124+
cp ${{github.workspace}}/CMSIS/CMSIS/Core/Include/* ${{github.workspace}}/targets/arm/
125+
126+
- name: generating header
127+
run: |
128+
mkdir -p ${{github.workspace}}/targets/chip/lpc1756/docs
129+
wget -q -O ${{github.workspace}}/targets/chip/lpc1756/docs/lpc1756.svd https://raw.githubusercontent.com/itzandroidtab/klib-svd/master/lpc1756.svd
130+
wget -q -O ${{github.workspace}}/svdconv.tbz2 https://github.com/Open-CMSIS-Pack/devtools/releases/download/tools%2Fsvdconv%2F3.3.44/svdconv-3.3.44-linux64-amd64.tbz2
131+
tar -xf ${{github.workspace}}/svdconv.tbz2
132+
chmod +x ${{github.workspace}}/svdconv
133+
134+
${{github.workspace}}/svdconv ${{github.workspace}}/targets/chip/lpc1756/docs/lpc1756.svd --suppress-warnings --generate=header -o ${{github.workspace}}/targets/chip/lpc1756/ || true
135+
sed -i '/#include "system_/d' ${{github.workspace}}/targets/chip/lpc1756/lpc1756.h
136+
137+
- name: Find all header files and build individually
138+
run: |
139+
mkdir -p ${{github.workspace}}/project
140+
HEADER_DIR="${{github.workspace}}/klib/"
141+
BUILD_DIR="${{github.workspace}}/build"
142+
143+
# Find all header files (.hpp and .h)
144+
find "$HEADER_DIR" -type f \( -name "*.hpp" -o -name "*.h" \) | while read header_file; do
145+
# Get a safe name for the build (basename + replace / with _)
146+
header_name=$(basename "$header_file")
147+
safe_name=$(echo "$header_file" | sed 's/[^a-zA-Z0-9]/_/g')
148+
149+
# Create a main.cpp that only includes this header
150+
echo "#include \"${header_file#$HEADER_DIR/}\"" > ${{github.workspace}}/project/main.cpp
151+
echo "int main() { return 0; }" >> ${{github.workspace}}/project/main.cpp
152+
153+
# Optionally: show which header we're building
154+
echo "Building for header: $header_file"
155+
156+
# Configure and build
157+
CC=arm-none-eabi-gcc CXX=arm-none-eabi-g++ cmake -B "$BUILD_DIR/$safe_name" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -S ${{github.workspace}}
158+
cmake --build "$BUILD_DIR/$safe_name" --config ${{env.BUILD_TYPE}}
159+
done

0 commit comments

Comments
 (0)