From 63dc8dc664c1e80411487b44c4a75a22894bc327 Mon Sep 17 00:00:00 2001 From: Guinea Wheek Date: Sun, 17 Dec 2023 15:46:48 -0800 Subject: [PATCH] 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 --- .github/workflows/ci.yml | 6 +++--- build.gradle | 2 +- src/main/java/com/vendor/jni/VendorJNI.java | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 239b4b9..9a3ffeb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: fetch-depth: 0 - name: Fetch all history and metadata 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 run: ./gradlew build --max-workers 1 ${{ matrix.build-options }} - uses: actions/upload-artifact@v3 @@ -40,7 +40,7 @@ jobs: build-host: env: - MACOSX_DEPLOYMENT_TARGET: 11 + MACOSX_DEPLOYMENT_TARGET: 12 strategy: fail-fast: false matrix: @@ -54,7 +54,7 @@ jobs: name: "Build - ${{ matrix.artifact-name }}" runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Fetch all history and metadata diff --git a/build.gradle b/build.gradle index 5b84905..297b35b 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'google-test' id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' 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' } diff --git a/src/main/java/com/vendor/jni/VendorJNI.java b/src/main/java/com/vendor/jni/VendorJNI.java index db5ba12..3e4e01b 100644 --- a/src/main/java/com/vendor/jni/VendorJNI.java +++ b/src/main/java/com/vendor/jni/VendorJNI.java @@ -5,17 +5,31 @@ import java.util.concurrent.atomic.AtomicBoolean; import edu.wpi.first.util.RuntimeLoader; +/** + * Demo class for loading the driver via JNI. + */ public class VendorJNI { static boolean libraryLoaded = false; static RuntimeLoader loader = null; + /** + * Helper class for determining whether or not to load the driver on static initialization. + */ public static class Helper { 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() { return extractOnStaticLoad.get(); } + /** + * Set whether to load the driver on static init. + * @param load the new value + */ public static void setExtractOnStaticLoad(boolean load) { extractOnStaticLoad.set(load); } @@ -47,5 +61,12 @@ public class VendorJNI { 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(); }