2024 tweaks (#25)

* Add JavaDocs to VendorJNI

* Make the CI action not depend on the repository name

* Update the Github CI macOS env and make everything use checkoutv4

* Bump GradleJNI to 1.1.0
This commit is contained in:
Guinea Wheek 2023-12-17 15:46:48 -08:00 committed by GitHub
parent 3759fd438e
commit 63dc8dc664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 4 deletions

View File

@ -30,7 +30,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Fetch all history and metadata - name: Fetch all history and metadata
run: | run: |
git config --global --add safe.directory /__w/vendor-template/vendor-template git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew build --max-workers 1 ${{ matrix.build-options }} run: ./gradlew build --max-workers 1 ${{ matrix.build-options }}
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
@ -40,7 +40,7 @@ jobs:
build-host: build-host:
env: env:
MACOSX_DEPLOYMENT_TARGET: 11 MACOSX_DEPLOYMENT_TARGET: 12
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -54,7 +54,7 @@ jobs:
name: "Build - ${{ matrix.artifact-name }}" name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Fetch all history and metadata - name: Fetch all history and metadata

View File

@ -4,7 +4,7 @@ plugins {
id 'google-test' id 'google-test'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
id 'edu.wpi.first.NativeUtils' version '2024.6.1' id 'edu.wpi.first.NativeUtils' version '2024.6.1'
id 'edu.wpi.first.GradleJni' version '1.0.0' id 'edu.wpi.first.GradleJni' version '1.1.0'
id 'edu.wpi.first.GradleVsCode' version '2.1.0' id 'edu.wpi.first.GradleVsCode' version '2.1.0'
} }

View File

@ -5,17 +5,31 @@ import java.util.concurrent.atomic.AtomicBoolean;
import edu.wpi.first.util.RuntimeLoader; import edu.wpi.first.util.RuntimeLoader;
/**
* Demo class for loading the driver via JNI.
*/
public class VendorJNI { public class VendorJNI {
static boolean libraryLoaded = false; static boolean libraryLoaded = false;
static RuntimeLoader<VendorJNI> loader = null; static RuntimeLoader<VendorJNI> loader = null;
/**
* Helper class for determining whether or not to load the driver on static initialization.
*/
public static class Helper { public static class Helper {
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true); private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
/**
* Get whether to load the driver on static init.
* @return true if the driver will load on static init
*/
public static boolean getExtractOnStaticLoad() { public static boolean getExtractOnStaticLoad() {
return extractOnStaticLoad.get(); return extractOnStaticLoad.get();
} }
/**
* Set whether to load the driver on static init.
* @param load the new value
*/
public static void setExtractOnStaticLoad(boolean load) { public static void setExtractOnStaticLoad(boolean load) {
extractOnStaticLoad.set(load); extractOnStaticLoad.set(load);
} }
@ -47,5 +61,12 @@ public class VendorJNI {
libraryLoaded = true; libraryLoaded = true;
} }
/**
* Tells the driver to initialize.
* This is a demo of a native JNI method from the driver.
*
* @return the int returned by the driver
* @see "VendorJNI.cpp"
*/
public static native int initialize(); public static native int initialize();
} }