Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 14 additions & 101 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:

env:
BUILD_TYPE: Release
# Keep in sync with
# https://github.com/PhotonVision/photonvision/blob/main/.github/workflows/build.yml
IMAGE_VERSION: v2026.0.3

jobs:
build-host:
Expand All @@ -22,12 +19,17 @@ jobs:
include:
- os: ubuntu-22.04
arch-name: linuxx86-64
- os: ubuntu-22.04-arm
arch-name: linuxarm64
- os: windows-latest
arch-name: windowsx86-64
extra-flags: -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl

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

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5
with:
submodules: 'true'
fetch-depth: 0
Expand All @@ -37,110 +39,21 @@ jobs:
- run: git describe --tags

- name: Install Java 17
uses: actions/setup-java@v3
uses: actions/setup-java@v5
with:
java-version: 17
distribution: temurin

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.13

- name: Install deps
if: runner.os == 'Linux'
run: |
sudo bash -c "echo 'deb [trusted=yes] http://mrcal.secretsauce.net/packages/jammy/public/ jammy main' >> /etc/apt/sources.list"
sudo apt update
sudo apt-get install -y cmake gcc g++ liblist-moreutils-perl
sudo apt-get install -y cmake ninja-build gcc g++ liblist-moreutils-perl

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=${{ matrix.arch-name }}

- name: Build shared mrcal_jni
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/cmake_build --config ${{env.BUILD_TYPE}} ${{ (startsWith(matrix.arch-name, 'windowx86-64') && '--config Release') || '' }} -j --target mrcal_jni

- name: Gradle build
# Build your program with the given configuration
run: ./gradlew build

- run: ./gradlew publish
name: Publish
env:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
if: github.event_name == 'push'

- uses: actions/upload-artifact@v4
with:
name: libmrcal-jar-${{ matrix.arch-name }}
path: |
${{ github.workspace }}/build/libs/*.jar

build-raspi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 0
- name: Fetch tags
run: git fetch --tags --force
- run: git describe --tags
- uses: pguyot/arm-runner-action@v2
with:
base_image: https://github.com/PhotonVision/photon-image-modifier/releases/download/$IMAGE_VERSION/photonvision_raspi.img.xz
cpu: cortex-a7
image_additional_mb: 5000
bind_mount_repository: true
# Mark kernel packages as held to avoid automatic updates (which don't work in a chroot)
commands: |
sudo bash -c "echo 'deb [trusted=yes] http://mrcal.secretsauce.net/packages/jammy/public/ jammy main' >> /etc/apt/sources.list"
sudo apt-get update
sudo apt-mark hold 'linux-image-*'
sudo apt-get install --no-install-recommends cmake default-jdk default-jre git gcc g++ liblist-moreutils-perl ninja-build -y
cmake -B cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=linuxarm64 -G Ninja
cmake --build cmake_build --config ${{env.BUILD_TYPE}} -j --target mrcal_jni

- run: |
./gradlew build ${{ (startsWith(github.event_name, 'push') && 'publish') || '' }} -PArchOverride=linuxarm64
env:
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}

- uses: actions/upload-artifact@v4
name: Upload jar
with:
name: libmrcal-jar-pi
path: ${{ github.workspace }}/build/libs/*.jar

build-windows:
runs-on: windows-latest

name: "mrcal-jni - Build - Windows"

env:
BUILD_TYPE: "Release"

steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 0

- name: Fetch tags
run: git fetch --tags --force
- run: git describe --tags

- name: Install Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.13

- name: Configure CMake
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
run: cmake -B ${{github.workspace}}/cmake_build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENCV_ARCH=${{ matrix.arch-name }} ${{ matrix.extra-flags }}

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

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v5
with:
name: libmrcal-jar-windowsx64
name: libmrcal-jar-${{ matrix.arch-name }}
path: ${{ github.workspace }}/build/libs/*.jar

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

- run: find

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ See: http://mrcal.secretsauce.net/install.html
- Install cmake

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

For windows: `cmake -B build -S . -T ClangCl -A x64 -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="vcpkg/scripts/buildsystems/vcpkg.cmake"`

and cvpkg install suitesparse:x64-windows
For windows: `cmake -B build -S . -T ClangCl -A x64 -G "Visual Studio 17 2022"
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,16 @@ test {
useJUnitPlatform()
}

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

println("Building for $nativeName")

tasks.register('copyNativeLibrary', Sync) {
from "${projectDir}/cmake_build/bin/"
from "${projectDir}/cmake_build/lib/"
into "${outputsFolder}/nativelibraries/${nativeName}/"
into "${outputsFolder}/${nativeName}/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this drive changes upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We'll finally be able to use the tool plugin and CombinedRuntimeLoader to manage this library.

include "**/*.dll", "**/*.so"

// And flatten, since windows is stupid
eachFile {
path = name
}
includeEmptyDirs = false

build.dependsOn it
Expand Down