Skip to content

Commit

Permalink
Merge pull request #188 from nRF24/CMake-4-Linux
Browse files Browse the repository at this point in the history
CMake for linux
  • Loading branch information
TMRh20 authored Nov 14, 2021
2 parents b6c6f1c + b3915b2 commit a5e0537
Show file tree
Hide file tree
Showing 86 changed files with 3,417 additions and 644 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Arduino CLI build

on:
pull_request:
types: [opened, reopened]
paths:
- ".github/workflows/build_arduino.yml"
- "examples/**"

push:
paths:
- ".github/workflows/build_arduino.yml"
- "examples/**"

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check code formatting
uses: per1234/artistic-style-action@main
with:
options-file-path: ./examples/examples_formatter.conf
name-patterns: |
- '*.ino'
- '*.cpp'
- '*.hpp'
- '*.h'
target-paths: |
- examples
build:
needs: check_formatting
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
fqbn:
- "arduino:avr:yun"
- "arduino:avr:uno"
- "arduino:avr:diecimila"
- "arduino:avr:nano"
- "arduino:avr:mega"
- "arduino:avr:megaADK"
- "arduino:avr:leonardo"
- "arduino:avr:micro"
- "arduino:avr:esplora"
- "arduino:avr:mini"
- "arduino:avr:ethernet"
- "arduino:avr:fio"
- "arduino:avr:bt"
# - "arduino:avr:LilyPad" # board not found
- "arduino:avr:LilyPadUSB"
- "arduino:avr:pro"
- "arduino:avr:atmegang"
- "arduino:avr:robotControl"
# - "arduino:avr:gemma" # does not support SPI
- "arduino:avr:circuitplay32u4cat"
- "arduino:avr:yunmini"
- "arduino:avr:chiwawa"
- "arduino:avr:one"
- "arduino:avr:unowifi"
- "arduino:mbed:nano33ble"
- "arduino:samd:mkr1000"
- "arduino:samd:mkrzero"
- "arduino:samd:mkrwifi1010"
- "arduino:samd:nano_33_iot"
- "arduino:samd:mkrfox1200"
- "arduino:samd:mkrwan1300"
- "arduino:samd:mkrwan1310"
- "arduino:samd:mkrgsm1400"
- "arduino:samd:mkrnb1500"
- "arduino:samd:mkrvidor4000"
- "arduino:samd:adafruit_circuitplayground_m0"
- "arduino:samd:mzero_pro_bl"
- "arduino:samd:mzero_bl"
- "arduino:samd:tian"
- "arduino:megaavr:uno2018"
# - "arduino:megaavr:nano4809" # board not found

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Compile examples
uses: arduino/compile-sketches@main
with:
sketch-paths: |
- examples/RF24Mesh_Example
- examples/RF24Mesh_Example_Master_Statics
- examples/RF24Mesh_Example_Master_To_Nodes
- examples/RF24Mesh_Example_Node2Node
- examples/RF24Mesh_Example_Node2NodeExtra
- examples/RF24Mesh_SerialConfig
- examples/RF24Mesh_Example_Master
libraries: |
- name: RF24
- source-url: https://github.com/nRF24/RF24Network.git
- source-path: ./
# - name: RF24Network
fqbn: ${{ matrix.fqbn }}
190 changes: 190 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Linux build

on:
pull_request:
types: [opened, reopened]
paths:
- "*.h"
- "*.cpp"
- "CMakeLists.txt"
- "cmake/**"
- "library.properties" # CMake gets lib info from here
- "examples_RPi/**"
- "!examples_RPi/*.py"
- "!**Makefile" # old build system is not tested in this workflow
- "pyRF24Mesh/*"
- ".github/workflows/build_linux.yml"
push:
paths:
- "*.h"
- "*.cpp"
- "CMakeLists.txt"
- "cmake/**"
- "library.properties" # CMake gets lib info from here
- "examples_RPi/**"
- "!examples_RPi/*.py"
- "!**Makefile" # old build system is not tested in this workflow
- "pyRF24Mesh/*"
- ".github/workflows/build_linux.yml"
release:
types: [published, edited]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
using_cmake:
runs-on: ubuntu-latest

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"

steps:
# - 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: checkout RF24
uses: actions/checkout@v2
with:
repository: nRF24/RF24

- name: build & install RF24
run: |
mkdir build
cd build
cmake .. -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D RF24_DRIVER=SPIDEV \
-D CMAKE_INSTALL_PREFIX=/usr/${{ matrix.toolchain.usr_dir }} \
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
sudo make install
- name: checkout RF24Network
uses: actions/checkout@v2
with:
repository: nRF24/RF24Network

- name: build & install RF24Network
run: |
mkdir build
cd build
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
sudo make install
- name: checkout RF24Mesh repo
uses: actions/checkout@v2

- 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_RF24Mesh"
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')
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
run: |
cmake ../examples_RPi \
-D CMAKE_TOOLCHAIN_FILE=../cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
- name: build examples
working-directory: ${{ github.workspace }}/build
# doesn't build the RF24Mesh_Ncurses_Master example because we haven't cross-compiled it in this workflow
run: |
cmake --build .
file ./RF24Mesh_Example
# 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-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 }}/pyRF24Mesh
run: python3 setup.py build

- name: install python wrapper
if: ${{ matrix.toolchain.compiler == 'default' }}
working-directory: ${{ github.workspace }}/pyRF24Mesh
run: sudo python3 setup.py install
Loading

0 comments on commit a5e0537

Please sign in to comment.