Skip to content

Commit 02e4db1

Browse files
chore: added workflow to test cross compilation
1 parent 6d36272 commit 02e4db1

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Cross compilation
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
shared_libs: ['ON','OFF']
17+
18+
steps:
19+
- name: install dependencies
20+
run: |
21+
sudo apt update
22+
sudo apt install -y --no-install-recommends cmake ninja-build gcc-mingw-w64-x86-64
23+
24+
- uses: actions/checkout@v4
25+
26+
- name: Set reusable strings
27+
id: strings
28+
shell: bash
29+
run: |
30+
echo "build-output-dir=$GITHUB_WORKSPACE/build" >> "$GITHUB_OUTPUT"
31+
32+
- name: Configure CMake
33+
run: >
34+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
35+
-G Ninja
36+
-D CMAKE_SYSTEM_NAME=Windows
37+
-D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc
38+
-D CMAKE_BUILD_TYPE=Release
39+
-D BUILD_SHARED_LIBS=${{ matrix.shared_libs }}
40+
-D BUILD_TESTING=ON
41+
-S $GITHUB_WORKSPACE
42+
43+
- name: Build & Install
44+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }}
45+
46+
- name: add DLL to test folder
47+
if: matrix.shared_libs == 'ON'
48+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
49+
run: |
50+
cp *apriltag.dll test/
51+
52+
- name: Upload build artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: cross-compilation-build-sharedlib-${{ matrix.shared_libs }}
56+
path: ${{ steps.strings.outputs.build-output-dir }}
57+
58+
test:
59+
needs: build
60+
runs-on: windows-latest
61+
62+
strategy:
63+
matrix:
64+
shared_libs: ['ON','OFF']
65+
66+
steps:
67+
- uses: actions/checkout@v4
68+
- name: Set reusable strings
69+
id: strings
70+
shell: bash
71+
run: |
72+
echo "build-output-dir=$GITHUB_WORKSPACE/build" >> "$GITHUB_OUTPUT"
73+
74+
- name: Download build artifact
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: cross-compilation-build-sharedlib-${{ matrix.shared_libs }}
78+
path: ${{ steps.strings.outputs.build-output-dir }}
79+
80+
- name: Change test pathes
81+
run: |
82+
(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
83+
84+
- name: Test
85+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
86+
run: |
87+
ctest --no-tests=error --output-on-failure --verbose

0 commit comments

Comments
 (0)