-
-
Notifications
You must be signed in to change notification settings - Fork 3
197 lines (176 loc) · 7.54 KB
/
build_linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Linux
on:
pull_request:
branches: [master]
paths:
- "library.properties" # CMake gets lib info from here
- "src/*.h"
- "src/*.cpp"
- "!src/py_bindings.cpp"
- "src/CMakeLists.txt"
- "src/cmake/**"
- "src/utility/CMakeLists.txt"
- "src/utility/mraa/*"
- "src/utility/linux_kernel/*"
- "src/utility/pigpio/*"
- "src/utility/bcm2xxx/*"
- "examples/linux/*"
- ".github/workflows/build_linux.yml"
push:
branches: [master]
paths:
- "library.properties" # CMake gets lib info from here
- "src/*.h"
- "src/*.cpp"
- "!src/py_bindings.cpp"
- "src/CMakeLists.txt"
- "src/cmake/**"
- "src/utility/CMakeLists.txt"
- "src/utility/mraa/*"
- "src/utility/linux_kernel/*"
- "src/utility/pigpio/*"
- "src/utility/bcm2xxx/*"
- "examples/linux/*"
- ".github/workflows/build_linux.yml"
release:
types: [created]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
check_formatting:
uses: ./.github/workflows/cpp_lint.yaml
with:
ignore: 'examples|!examples/linux|src/utility/bcm2xxx/bcm2835.h|src/utility/bcm2xxx/bcm2835.c'
build:
needs: check_formatting
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
driver:
- "bcm2xxx"
- "linux_kernel"
- "mraa"
toolchain:
- compiler: "armhf"
usr_dir: "arm-linux-gnueabihf"
- compiler: "arm64"
usr_dir: "aarch64-linux-gnu"
- compiler: "default" # github runner is hosted on a "amd64"
usr_dir: "local" # using this toolchain to test python wrapper
i2c-bus: [-DUSE_I2C=ON, -DUSE_I2C=OFF]
dr-pin: [-DUSE_SW_DR=ON, -DUSE_SW_DR=OFF]
include:
- driver: "pigpio"
toolchain:
compiler: "default"
usr_dir: "local"
env:
PINNACLE_DRIVER: ${{ matrix.driver }}
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
steps:
- name: provide toolchain (for arm64)
if: ${{ matrix.toolchain.compiler == 'arm64' }}
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: provide toolchain (for armhf)
if: ${{ matrix.toolchain.compiler == 'armhf' }}
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
- uses: actions/checkout@v4
with:
path: ${{ github.event.repository.name }}
- name: provide mraa
if: matrix.driver == 'mraa'
run: |
git clone https://github.com/intel-iot-devkit/mraa.git
cd mraa
mkdir build
cd build
cmake .. -D BUILDSWIGNODE=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ github.event.repository.name }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
sudo make install
- name: provide pigpio
if: matrix.driver == 'pigpio'
run: |
git clone https://github.com/joan2937/pigpio.git
cd pigpio
git fetch --tags
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag
mkdir build
cd build
cmake .. -D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ github.event.repository.name }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
make
sudo make install
- name: create CMake build environment
run: cmake -E make_directory ${{ github.workspace }}/${{ github.event.repository.name }}/build
- name: configure lib
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: |
cmake ../src -D CMAKE_BUILD_TYPE=$BUILD_TYPE \
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
- name: build lib
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: cmake --build .
- name: install lib
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: sudo cmake --install .
- name: package lib
if: endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF')
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: sudo cpack
- name: Save artifact
if: endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF') && startsWith(matrix.toolchain.compiler, 'arm')
uses: actions/upload-artifact@v4
with:
name: pkg_${{ github.event.repository.name }}_${{ matrix.driver }}_${{ matrix.toolchain.compiler }}
path: |
${{ github.workspace }}/${{ github.event.repository.name }}/build/pkgs/*.deb
${{ github.workspace }}/${{ github.event.repository.name }}/build/pkgs/*.rpm
- name: Upload Release assets
if: github.event_name == 'release' && (matrix.toolchain.compiler == 'armhf' || matrix.toolchain.compiler == 'arm64') && (matrix.driver =='bcm2xxx' || matrix.driver =='linux_kernel') && (endsWith(matrix.i2c-bus, 'OFF') && endsWith(matrix.dr-pin, 'OFF'))
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "${{ github.workspace }}/${{ github.event.repository.name }}/build/pkgs/lib*"
- name: clean build environment
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: sudo rm -r ./*
- name: provide ncurses
# This script assumes that any examples using ncurses reside in a 'ncurses' subdirectory
# as is the case w/ RF24Mesh, RF24Gateway, and any new ncurses examples going forward.
run: |
if [[ -d ${{ github.workspace }}/${{ github.event.repository.name }}/examples/linux/ncurses ]]; then
if [[ ${{ matrix.toolchain.compiler }} == 'default' ]]; then
sudo apt-get install libncurses5-dev
else
echo "skipping the ncurses examples for cross-compiled builds"
# avoid cross-compiling linker problems in CI; this works locally but takes a while to build
# curl -L https://invisible-island.net/datafiles/release/ncurses.tar.gz > ncurses.tar.gz
# gunzip ncurses.tar.gz
# tar xf ncurses.tar
# cd ncurses-*
# ./configure --prefix=/usr/${{ matrix.toolchain.usr_dir }} --build=${{ matrix.toolchain.usr_dir }}
# make
# sudo make install
fi
else
echo "ncurses is not needed for these examples"
fi
- name: configure examples
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: |
cmake ../examples/linux \
-D CMAKE_TOOLCHAIN_FILE=../src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake \
${{ matrix.i2c-bus }} ${{ matrix.dr-pin }}
- name: build examples
working-directory: ${{ github.workspace }}/${{ github.event.repository.name }}/build
run: cmake --build .