forked from nRF24/RF24
-
Notifications
You must be signed in to change notification settings - Fork 0
372 lines (326 loc) · 12.6 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: Linux build
on:
pull_request_target:
pull_request:
types: [opened, reopened]
paths:
- "*.h"
- "*.cpp"
- "CMakeLists.txt"
- "cmake/**"
- "library.properties" # CMake & 'configure' gets lib info from here
- "configure"
- "Makefile"
- "utility/CMakeLists.txt"
# - "utility/LittleWire/*"" # this is not tested (anymore)
- "utility/wiringPi/*"
- "utility/MRAAA/*"
- "utility/SPIDEV/*"
- "utility/pigpio"
- "examples_linux/*"
- "!examples_linux/*.py"
- "!examples_linux/*.md"
- "pyRF24/setup.py"
- "pyRF24/pyRF24.cpp"
- ".github/workflows/build_linux.yml"
push:
paths:
- "*.h"
- "*.cpp"
- "CMakeLists.txt"
- "cmake/**"
- "library.properties" # CMake & 'configure' gets lib info from here
- "configure"
- "Makefile"
- "utility/CMakeLists.txt"
# - "utility/LittleWire/*"" # this is not tested (anymore)
- "utility/wiringPi/*"
- "utility/MRAAA/*"
- "utility/SPIDEV/*"
- "utility/pigpio"
- "examples_linux/*"
- "!examples_linux/*.py"
- "!examples_linux/*.md"
- "pyRF24/setup.py"
- "pyRF24/pyRF24.cpp"
- ".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:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install cpp-linter
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--ignore='examples|examples_pico|utility/RPi/bcm2835.h|utility/RPi/bcm2835.c'
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1
####################### using Makefile #############################
build:
needs: check_formatting
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config-options:
- "--soc=BCM2835 --driver=RPi"
- "--soc=BCM2836 --driver=RPi"
- "--driver=SPIDEV"
- "--driver=MRAA"
- "--driver=pigpio"
# - "--soc=BCM2835 --driver=wiringPi"
env:
CFLAGS: "-I /usr/local/include"
steps:
- uses: actions/checkout@v2
- name: provide toolchain
run: |
sudo apt-get update
sudo apt-get install binutils-arm-linux-gnueabi gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
arm-linux-gnueabihf-gcc -v
arm-linux-gnueabihf-g++ -v
- name: provide WiringPi
if: ${{ matrix.config-options == '--soc=BCM2835 --driver=wiringPi' }}
env:
CC: /usr/bin/arm-linux-gnueabihf-gcc
CFLAGS: "-I /usr/local/include -L /usr/local/lib -marm -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -lcrypt -lrt"
run: |
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
- name: provide pigpio
if: ${{ matrix.config-options == '--driver=pigpio' || endsWith(matrix.config-options, '--driver=RPi') }}
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/arm-linux-gnueabihf \
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/toolchains/armhf.cmake
make
sudo make install
- name: provide MRAA
if: ${{ matrix.config-options == '--driver=MRAA' }}
env:
CC: /usr/bin/arm-linux-gnueabihf-gcc
CXX: /usr/bin/arm-linux-gnueabihf-g++
run: |
git clone https://github.com/intel-iot-devkit/mraa.git
cd mraa
mkdir build
cd build
cmake .. -D BUILDSWIGNODE=OFF -D BUILDARCH=arm
sudo make install
sudo bash -c 'echo "/usr/local/lib/arm-linux-gnueabihf" >> /etc/ld.so.conf'
sudo ldconfig
- name: library configure
run: ./configure ${{ matrix.config-options }}
- name: library make
run: make
- name: library make install
run: sudo make install
- name: make linux examples
# compiling examples for wiringPi is broken see issue #669
# executables linked to wiringPi additionally need to be linked to crypt and shm_open
# interruptConfigure.cpp example is incompatible with MRAA & wiringPi drivers
if: ${{ matrix.config-options != '--soc=BCM2835 --driver=wiringPi' && matrix.config-options != '--driver=MRAA' }}
run: |
cd examples_linux
make
file ./gettingstarted
####################### using CMake ################################
using_cmake:
needs: check_formatting
runs-on: ubuntu-latest
env:
RF24_DRIVER: ${{ matrix.driver }}
strategy:
fail-fast: false
matrix:
toolchain:
- compiler: "armhf"
usr_dir: "arm-linux-gnueabihf"
- compiler: "arm64"
usr_dir: "aarch64-linux-gnu"
# - compiler: "x86_64"
# usr_dir: "x86_64-linux-gnux32"
# - compiler: "i686"
# usr_dir: "i686-linux-gnu"
- compiler: "default" # github runner is hosted on a "amd64"
usr_dir: "local" # using this toolchain to test python wrapper
driver:
- "RPi"
- "SPIDEV"
- "MRAA"
- "pigpio"
exclude:
# MRAA is not compatible with i686 arch
- driver: "MRAA"
toolchain:
compiler: "i686"
usr_dir: "i686-linux-gnu"
- driver: "pigpio"
toolchain:
compiler: "default"
usr_dir: "local"
include:
# need to cross-compile wiringPi dependencies (libcrypt)
# only test default compiler with wiringPi
- driver: "wiringPi"
toolchain:
compiler: "default" # github runner is hosted on a "amd64"
usr_dir: "local"
steps:
- name: Checkout RF24 repo
uses: actions/checkout@v2
# - name: provide toolchain (for x86_64)
# if: ${{ matrix.toolchain.compiler == 'x86_64' }}
# run: |
# sudo apt-get update
# sudo apt-get install gcc-x86-64-linux-gnux32 g++-x86-64-linux-gnux32
# - name: provide toolchain (for i686)
# if: ${{ matrix.toolchain.compiler == 'i686' }}
# run: |
# sudo apt-get update
# sudo apt-get install gcc-i686-linux-gnu g++-i686-linux-gnu
- 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
- 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 }}/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
sudo make install
- name: provide WiringPi
if: ${{ matrix.driver == 'wiringPi' && matrix.toolchain.compiler == 'default' }}
run: |
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
# - name: provide WiringPi (with toolchain compilers)
# if: ${{ matrix.driver == 'wiringPi' && matrix.toolchain.compiler != 'default' }}
# env:
# CC: /usr/bin/${{ matrix.toolchain.usr_dir }}-gcc
# CFLAGS: "-I/usr/${{ matrix.toolchain.usr_dir }}"
# run: |
# git clone https://github.com/WiringPi/WiringPi
# cd WiringPi
# ./build
- 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 }}/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
make
sudo make install
- name: create CMake build environment
run: cmake -E make_directory ${{ github.workspace }}/build
- name: configure lib
working-directory: ${{ github.workspace }}/build
run: |
cmake .. -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 }}/build
run: cmake --build .
- name: install lib
working-directory: ${{ github.workspace }}/build
run: sudo cmake --install .
- name: package lib
working-directory: ${{ github.workspace }}/build
run: sudo cpack
- name: Save artifact
uses: actions/upload-artifact@v2
with:
name: "pkg_RF24"
path: |
${{ github.workspace }}/build/pkgs/*.deb
${{ github.workspace }}/build/pkgs/*.rpm
- name: Upload Release assets
if: github.event_name == 'release' && (matrix.toolchain.compiler == 'armhf' || matrix.toolchain.compiler == 'arm64') && (matrix.driver =='RPi' || matrix.driver =='SPIDEV')
uses: csexton/release-asset-action@master
with:
pattern: "${{ github.workspace }}/build/pkgs/librf24*"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: clean build environment
working-directory: ${{ github.workspace }}/build
run: sudo rm -r ./*
- name: configure examples
working-directory: ${{ github.workspace }}/build
# interruptConfigure isn't compatible with RF24 lib's support of MRAA as a driver
# interruptConfigure uses `attachInterrupt()` instead of wiringPi's `waitFor/interrupt()`
# executables linked to wiringPi additionally need to be linked to crypt and shm_open
run: |
cmake ../examples_linux \
-D CMAKE_TOOLCHAIN_FILE=../cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
- name: build examples
working-directory: ${{ github.workspace }}/build
run: |
cmake --build .
file ./gettingstarted
# cross-compiling a python C extension is better done with pypa/cibuildwheel action
- name: Set up Python 3.7
if: ${{ matrix.toolchain.compiler == 'default' }}
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: provide python wrapper prerequisites
if: ${{ matrix.toolchain.compiler == 'default' }}
# python3-rpi.gpio is only required for physical hardware (namely the IRQ example)
run: |
sudo apt-get install python3-dev libboost-python-dev python3-pip
python3 -m pip install --upgrade pip setuptools
- name: create alias symlink to libboost_python3*.so
if: ${{ matrix.toolchain.compiler == 'default' }}
run: sudo ln -s $(ls /usr/lib/$(ls /usr/lib/gcc | tail -1)/libboost_python3*.so | tail -1) /usr/lib/$(ls /usr/lib/gcc | tail -1)/libboost_python3.so
- name: build python wrapper
if: ${{ matrix.toolchain.compiler == 'default' }}
working-directory: ${{ github.workspace }}/pyRF24
run: python3 setup.py build
- name: install python wrapper
if: ${{ matrix.toolchain.compiler == 'default' }}
working-directory: ${{ github.workspace }}/pyRF24
run: sudo python3 setup.py install