-
Notifications
You must be signed in to change notification settings - Fork 650
102 lines (85 loc) · 3.08 KB
/
cross-compilation.yml
File metadata and controls
102 lines (85 loc) · 3.08 KB
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
name: Cross compilation
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
# Use mingw to cross compile apriltag and its tests on linux
build:
runs-on: ubuntu-latest
strategy:
matrix:
shared_libs: ['ON','OFF']
steps:
# Install required packages to build for windows
- name: install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends cmake ninja-build gcc-mingw-w64-x86-64
# Get the sources
- uses: actions/checkout@v4
# Save the "build/" folder path
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=$GITHUB_WORKSPACE/build" >> "$GITHUB_OUTPUT"
# Configure cmake
# CMAKE_SYSTEM_NAME=Windows is needed else it will produce libapriltag.so instead of .dll
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-G Ninja
-D CMAKE_SYSTEM_NAME=Windows
-D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc
-D CMAKE_BUILD_TYPE=Release
-D BUILD_SHARED_LIBS=${{ matrix.shared_libs }}
-D BUILD_TESTING=ON
-S $GITHUB_WORKSPACE
# Build apriltag
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }}
# In case of shared lib, copy the .dll file in the test directory
- name: add DLL to test folder
if: matrix.shared_libs == 'ON'
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
cp *apriltag.dll test/
# Upload the "build/" directory as artifact
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: cross-compilation-build-sharedlib-${{ matrix.shared_libs }}
path: ${{ steps.strings.outputs.build-output-dir }}
# On windows, retrieve the cross compiled build and run the tests
test:
needs: build
runs-on: windows-latest
strategy:
matrix:
shared_libs: ['ON','OFF']
steps:
- uses: actions/checkout@v4
# Save the "build/" folder path
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=$GITHUB_WORKSPACE/build" >> "$GITHUB_OUTPUT"
# Download the "build/" directory
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: cross-compilation-build-sharedlib-${{ matrix.shared_libs }}
path: ${{ steps.strings.outputs.build-output-dir }}
# Change the tests pathes so they match the windows ones instead of the linux ones
- name: Change test pathes
run: |
(Get-Content ${{ steps.strings.outputs.build-output-dir }}/test/CTestTestfile.cmake) -replace '/home/runner/work/apriltag/apriltag', $PWD.Path.Replace('\', '/') | Set-Content ${{ steps.strings.outputs.build-output-dir }}/test/CTestTestfile.cmake
# Run the tests
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
ctest --no-tests=error --output-on-failure --verbose