-
Notifications
You must be signed in to change notification settings - Fork 4
143 lines (119 loc) · 4.89 KB
/
build_cross-compile.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
name: Cross-Compile & package
on:
pull_request:
types: [opened, synchronize, reopened]
push:
release:
types: [published, edited]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
test_lib_and_examples:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
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"
include:
- os: "windows-latest"
toolchain:
compiler: "default"
usr_dir: "Program Files(x86)"
steps:
- name: checkout RF24Log lib
uses: actions/checkout@v2
- name: Install Visual Studio Tools (for Windows)
if: ${{ matrix.os == 'windows-latest' }}
uses: seanmiddleditch/gha-setup-vsdevenv@master
- name: install rpmbuild
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install rpm
- 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: Create Build Environment
run: cmake -E make_directory ${{ github.workspace }}/build
- name: Configure CMake
if: ${{ matrix.toolchain.compiler == 'default' && matrix.os != 'windows-latest' }}
working-directory: ${{ github.workspace }}/build
run: cmake ../src -D CMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Configure CMake (for Windows)
if: ${{ matrix.os == 'windows-latest' }}
working-directory: ${{ github.workspace }}/build
run: cmake ../src -G "NMake Makefiles"
- name: Configure CMake (with toolchain compilers)
if: ${{ matrix.toolchain.compiler != 'default' && matrix.os != 'windows-latest'}}
working-directory: ${{ github.workspace }}/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 }}/build
run: cmake --build .
- name: package lib
if: ${{ matrix.os == 'ubuntu-latest' }}
working-directory: ${{ github.workspace }}/build
run: sudo cpack
- name: Save artifact
if: ${{ matrix.os == 'ubuntu-latest'}}
uses: actions/upload-artifact@v2
with:
name: "pkg_RF24Log"
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: Install lib for Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
working-directory: ${{ github.workspace }}/build
# this step requires sudo (on Linux) or administator privledges (on Windows)
run: sudo cmake --install .
- name: Install lib for Windows
if: ${{ matrix.os == 'windows-latest' }}
working-directory: ${{ github.workspace }}/build
# this step requires sudo (on Linux) or administator privledges (on Windows)
run: cmake --install .
- name: Compile the examples for Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
mkdir build_examples
cd build_examples
cmake ../examples -D CMAKE_BUILD_TYPE=$BUILD_TYPE \
-D CMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/src/cmake/toolchains/${{ matrix.toolchain.compiler }}.cmake
cmake --build .
file ./GettingStarted