Skip to content

Commit 2adb187

Browse files
authored
Cross compile for Linux arm64, unify build matrix, and use WPILib directory layout (#13)
Clean up README as well
1 parent 29c6a36 commit 2adb187

File tree

3 files changed

+18
-112
lines changed

3 files changed

+18
-112
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ on:
1010

1111
env:
1212
BUILD_TYPE: Release
13-
# Keep in sync with
14-
# https://github.com/PhotonVision/photonvision/blob/main/.github/workflows/build.yml
15-
IMAGE_VERSION: v2026.0.3
1613

1714
jobs:
1815
build-host:
@@ -22,12 +19,17 @@ jobs:
2219
include:
2320
- os: ubuntu-22.04
2421
arch-name: linuxx86-64
22+
- os: ubuntu-22.04-arm
23+
arch-name: linuxarm64
24+
- os: windows-latest
25+
arch-name: windowsx86-64
26+
extra-flags: -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl
2527

2628
runs-on: ${{ matrix.os }}
2729
name: "mrcal-jni - Build - ${{ matrix.arch-name }}"
2830

2931
steps:
30-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v5
3133
with:
3234
submodules: 'true'
3335
fetch-depth: 0
@@ -37,110 +39,21 @@ jobs:
3739
- run: git describe --tags
3840

3941
- name: Install Java 17
40-
uses: actions/setup-java@v3
42+
uses: actions/setup-java@v5
4143
with:
4244
java-version: 17
4345
distribution: temurin
4446

45-
- name: Setup cmake
46-
uses: jwlawson/actions-setup-cmake@v1.13
47-
4847
- name: Install deps
48+
if: runner.os == 'Linux'
4949
run: |
50-
sudo bash -c "echo 'deb [trusted=yes] http://mrcal.secretsauce.net/packages/jammy/public/ jammy main' >> /etc/apt/sources.list"
5150
sudo apt update
52-
sudo apt-get install -y cmake gcc g++ liblist-moreutils-perl
51+
sudo apt-get install -y cmake ninja-build gcc g++ liblist-moreutils-perl
5352
5453
- name: Configure CMake
5554
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
5655
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
57-
run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=${{ matrix.arch-name }}
58-
59-
- name: Build shared mrcal_jni
60-
# Build your program with the given configuration
61-
run: cmake --build ${{github.workspace}}/cmake_build --config ${{env.BUILD_TYPE}} ${{ (startsWith(matrix.arch-name, 'windowx86-64') && '--config Release') || '' }} -j --target mrcal_jni
62-
63-
- name: Gradle build
64-
# Build your program with the given configuration
65-
run: ./gradlew build
66-
67-
- run: ./gradlew publish
68-
name: Publish
69-
env:
70-
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
71-
if: github.event_name == 'push'
72-
73-
- uses: actions/upload-artifact@v4
74-
with:
75-
name: libmrcal-jar-${{ matrix.arch-name }}
76-
path: |
77-
${{ github.workspace }}/build/libs/*.jar
78-
79-
build-raspi:
80-
runs-on: ubuntu-latest
81-
steps:
82-
- uses: actions/checkout@v3
83-
with:
84-
submodules: 'true'
85-
fetch-depth: 0
86-
- name: Fetch tags
87-
run: git fetch --tags --force
88-
- run: git describe --tags
89-
- uses: pguyot/arm-runner-action@v2
90-
with:
91-
base_image: https://github.com/PhotonVision/photon-image-modifier/releases/download/$IMAGE_VERSION/photonvision_raspi.img.xz
92-
cpu: cortex-a7
93-
image_additional_mb: 5000
94-
bind_mount_repository: true
95-
# Mark kernel packages as held to avoid automatic updates (which don't work in a chroot)
96-
commands: |
97-
sudo bash -c "echo 'deb [trusted=yes] http://mrcal.secretsauce.net/packages/jammy/public/ jammy main' >> /etc/apt/sources.list"
98-
sudo apt-get update
99-
sudo apt-mark hold 'linux-image-*'
100-
sudo apt-get install --no-install-recommends cmake default-jdk default-jre git gcc g++ liblist-moreutils-perl ninja-build -y
101-
cmake -B cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=linuxarm64 -G Ninja
102-
cmake --build cmake_build --config ${{env.BUILD_TYPE}} -j --target mrcal_jni
103-
104-
- run: |
105-
./gradlew build ${{ (startsWith(github.event_name, 'push') && 'publish') || '' }} -PArchOverride=linuxarm64
106-
env:
107-
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
108-
109-
- uses: actions/upload-artifact@v4
110-
name: Upload jar
111-
with:
112-
name: libmrcal-jar-pi
113-
path: ${{ github.workspace }}/build/libs/*.jar
114-
115-
build-windows:
116-
runs-on: windows-latest
117-
118-
name: "mrcal-jni - Build - Windows"
119-
120-
env:
121-
BUILD_TYPE: "Release"
122-
123-
steps:
124-
- uses: actions/checkout@v3
125-
with:
126-
submodules: 'true'
127-
fetch-depth: 0
128-
129-
- name: Fetch tags
130-
run: git fetch --tags --force
131-
- run: git describe --tags
132-
133-
- name: Install Java 17
134-
uses: actions/setup-java@v3
135-
with:
136-
java-version: 17
137-
distribution: temurin
138-
139-
- name: Setup cmake
140-
uses: jwlawson/actions-setup-cmake@v1.13
141-
142-
- name: Configure CMake
143-
run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=windowsx86-64 -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -G Ninja
56+
run: cmake -B ${{github.workspace}}/cmake_build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=${{ matrix.arch-name }} ${{ matrix.extra-flags }}
14457

14558
- name: Build shared mrcal_jni
14659
# Build your program with the given configuration
@@ -156,18 +69,18 @@ jobs:
15669
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
15770
if: github.event_name == 'push'
15871

159-
- uses: actions/upload-artifact@v4
72+
- uses: actions/upload-artifact@v5
16073
with:
161-
name: libmrcal-jar-windowsx64
74+
name: libmrcal-jar-${{ matrix.arch-name }}
16275
path: ${{ github.workspace }}/build/libs/*.jar
16376

16477
release:
165-
needs: [build-host, build-raspi, build-windows]
78+
needs: build-host
16679
runs-on: ubuntu-22.04
16780
steps:
16881
# Download literally every single artifact. This also downloads client and docs,
16982
# but the filtering below won't pick these up (I hope)
170-
- uses: actions/download-artifact@v4
83+
- uses: actions/download-artifact@v5
17184

17285
- run: find
17386

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ See: http://mrcal.secretsauce.net/install.html
55
- Install cmake
66

77
```
8-
sudo apt install cmake gcc g++ libmrcal-dev mrbuild libsuitesparse-dev
8+
sudo apt install cmake gcc g++ libmrcal-dev
99
cmake -B build . # You may need to add JAVA_HOME=/path/to/java
1010
cmake --build build
1111
```
1212

13-
For windows: `cmake -B build -S . -T ClangCl -A x64 -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="vcpkg/scripts/buildsystems/vcpkg.cmake"`
14-
15-
and cvpkg install suitesparse:x64-windows
13+
For windows: `cmake -B build -S . -T ClangCl -A x64 -G "Visual Studio 17 2022"

build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,16 @@ test {
5757
useJUnitPlatform()
5858
}
5959

60-
ext.nativeName = wpilibTools.platformMapper.currentPlatform.platformName;
60+
ext.nativeName = wpilibTools.platformMapper.currentPlatform.platformName.replace('win', 'windows/').replace('mac', 'osx/').replace('linux', 'linux/').replace('x64', 'x86-64');
6161
ext.outputsFolder = file("$buildDir/outputs")
6262

6363
println("Building for $nativeName")
6464

6565
tasks.register('copyNativeLibrary', Sync) {
6666
from "${projectDir}/cmake_build/bin/"
6767
from "${projectDir}/cmake_build/lib/"
68-
into "${outputsFolder}/nativelibraries/${nativeName}/"
68+
into "${outputsFolder}/${nativeName}/"
6969
include "**/*.dll", "**/*.so"
70-
71-
// And flatten, since windows is stupid
72-
eachFile {
73-
path = name
74-
}
7570
includeEmptyDirs = false
7671

7772
build.dependsOn it

0 commit comments

Comments
 (0)