-
Notifications
You must be signed in to change notification settings - Fork 663
fix: windows crosscompilation and added a workflow to test it by crosscompiling on ubuntu and running tests on windows #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+106
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.