From b62c43694dc498acd9a7013426b301e58ed102fe Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 15:16:48 -0500 Subject: [PATCH 1/9] Remove Java code --- dependencies.gradle | 7 --- .../com/revrobotics/jni/RevJNIWrapper.java | 51 ------------------- vendordeps/CANBridge.json | 17 ------- 3 files changed, 75 deletions(-) delete mode 100644 src/main/java/com/revrobotics/jni/RevJNIWrapper.java diff --git a/dependencies.gradle b/dependencies.gradle index 4dc62a1..7d82dc7 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,9 +1,2 @@ dependencies { - implementation 'edu.wpi.first.cscore:cscore-java:2020.+' - implementation 'edu.wpi.first.cameraserver:cameraserver-java:2020.+' - implementation 'edu.wpi.first.ntcore:ntcore-java:2020.+' - implementation 'edu.wpi.first.wpilibj:wpilibj-java:2020.+' - implementation 'edu.wpi.first.wpiutil:wpiutil-java:2020.+' - implementation 'edu.wpi.first.hal:hal-java:2020.+' - implementation 'edu.wpi.first.thirdparty.frc2020.opencv:opencv-java:3.4.7-2' } diff --git a/src/main/java/com/revrobotics/jni/RevJNIWrapper.java b/src/main/java/com/revrobotics/jni/RevJNIWrapper.java deleted file mode 100644 index db3fdab..0000000 --- a/src/main/java/com/revrobotics/jni/RevJNIWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019 REV Robotics - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of REV Robotics nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.revrobotics.jni; - -import java.io.IOException; - -import edu.wpi.first.wpiutil.RuntimeLoader; - -public class RevJNIWrapper { - static boolean libraryLoaded = false; - static RuntimeLoader loader = null; - - static { - if (!libraryLoaded) { - try { - loader = new RuntimeLoader<>("SparkMaxDriver", RuntimeLoader.getDefaultExtractionRoot(), RevJNIWrapper.class); - loader.loadLibrary(); - } catch (IOException ex) { - ex.printStackTrace(); - System.exit(1); - } - libraryLoaded = true; - } - } -} diff --git a/vendordeps/CANBridge.json b/vendordeps/CANBridge.json index 3e73f36..f475b4c 100644 --- a/vendordeps/CANBridge.json +++ b/vendordeps/CANBridge.json @@ -7,23 +7,6 @@ "http://www.revrobotics.com/content/sw/max/sdk/maven/" ], "jsonUrl": "http://www.revrobotics.com/content/sw/max/sdk/CANBridge.json", - "javaDependencies": [ - { - "groupId": "com.revrobotics.usb", - "artifactId": "CANBridge-java", - "version": "2.0.1" - } - ], - "jniDependencies": [ - { - "groupId": "com.revrobotics.usb", - "artifactId": "CANBridge-jni", - "version": "2.0.1", - "skipInvalidPlatforms": true, - "isJar": false, - "validPlatforms": [] - } - ], "cppDependencies": [ { "groupId": "com.revrobotics.usb", From 97e18f9dbc022a52a675692a6e69ef071e9552f6 Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 15:17:05 -0500 Subject: [PATCH 2/9] Don't specify OpenCV version --- config.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/config.gradle b/config.gradle index e620ab4..f73d001 100644 --- a/config.gradle +++ b/config.gradle @@ -9,7 +9,6 @@ nativeUtils { configureDependencies { wpiVersion = "2020.+" niLibVersion = "2020.9.1" - opencvVersion = "3.4.7-2" googleTestVersion = "1.9.0-3-437e100" } } From 94540fc3f41c34c4cd1c5243d757567b599af096 Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 15:18:28 -0500 Subject: [PATCH 3/9] Update gradle and WPILib deps, fix build --- build.gradle | 12 ++++++------ config.gradle | 12 ++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- .../include/rev/Drivers/DriverDeviceThread.h | 2 +- src/test/gtest/cpp/MockDS.cpp | 15 ++++++++------- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 4208d55..7d96251 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,9 @@ plugins { id 'cpp' id 'java' id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' - id 'edu.wpi.first.NativeUtils' version '2020.7.2' - id 'edu.wpi.first.GradleJni' version '0.10.1' - id 'edu.wpi.first.GradleVsCode' version '0.12.0' + id 'edu.wpi.first.NativeUtils' version '2023.11.1' + id 'edu.wpi.first.GradleJni' version '1.1.0' + id 'edu.wpi.first.GradleVsCode' version '1.3.0' id 'google-test-test-suite' } @@ -99,8 +99,8 @@ model { binaries.all { if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio - || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian - || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) { + || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32 + || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) { it.buildable = false } // lib library: "SparkMaxDriver", linkage: 'shared' @@ -113,5 +113,5 @@ model { apply from: 'publish.gradle' wrapper { - gradleVersion = '6.0.1' + gradleVersion = '7.5.1' } diff --git a/config.gradle b/config.gradle index f73d001..abbf8c2 100644 --- a/config.gradle +++ b/config.gradle @@ -1,15 +1,15 @@ import org.gradle.internal.os.OperatingSystem nativeUtils.addWpiNativeUtils() -nativeUtils.withRoboRIO() -nativeUtils.withRaspbian() -nativeUtils.withBionic() +nativeUtils.withCrossRoboRIO() +nativeUtils.withCrossLinuxArm32() +nativeUtils.withCrossLinuxArm64() nativeUtils { wpi { configureDependencies { - wpiVersion = "2020.+" - niLibVersion = "2020.9.1" - googleTestVersion = "1.9.0-3-437e100" + wpiVersion = "2023.+" + niLibVersion = "2023.3.0" + googleTestVersion = "1.11.0-3" } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9492014..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/native/include/rev/Drivers/DriverDeviceThread.h b/src/main/native/include/rev/Drivers/DriverDeviceThread.h index 1d8ff6b..8ad1214 100644 --- a/src/main/native/include/rev/Drivers/DriverDeviceThread.h +++ b/src/main/native/include/rev/Drivers/DriverDeviceThread.h @@ -235,4 +235,4 @@ class DriverDeviceThread { } // namespace usb -} // namespace rev \ No newline at end of file +} // namespace rev diff --git a/src/test/gtest/cpp/MockDS.cpp b/src/test/gtest/cpp/MockDS.cpp index 03247fd..fe2e61d 100644 --- a/src/test/gtest/cpp/MockDS.cpp +++ b/src/test/gtest/cpp/MockDS.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -28,16 +28,17 @@ static void LoggerFunc(unsigned int level, const char* file, unsigned int line, return; } - wpi::StringRef levelmsg; + oss << "DS: "; + if (level >= 50) - levelmsg = "CRITICAL: "; + oss << "CRITICAL: "; else if (level >= 40) - levelmsg = "ERROR: "; + oss << "ERROR: "; else if (level >= 30) - levelmsg = "WARNING: "; + oss << "WARNING: "; else return; - oss << "DS: " << levelmsg << msg << " (" << file << ':' << line << ")\n"; + oss << msg << " (" << file << ":" << std::to_string(line) << ")\n"; wpi::errs() << oss.str(); } @@ -102,4 +103,4 @@ void MockDS::enable() { void MockDS::disable() { m_enable = false; -} \ No newline at end of file +} From 2dcf411bcdecd584999c1f4283ff99e05980670b Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 15:18:38 -0500 Subject: [PATCH 4/9] Fix README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 223fce8..e3332b1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Overview -This respository is for the CANBridge software that is run on non-roboRIO platforms. +This repository is for the CANBridge software that is run on non-roboRIO platforms. ## Build Requirements From fe71ed261c82501af6dcdd58a1c63beaedb32c9a Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 15:19:32 -0500 Subject: [PATCH 5/9] Remove unused Gradle import --- config.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/config.gradle b/config.gradle index abbf8c2..7ead092 100644 --- a/config.gradle +++ b/config.gradle @@ -1,5 +1,3 @@ -import org.gradle.internal.os.OperatingSystem - nativeUtils.addWpiNativeUtils() nativeUtils.withCrossRoboRIO() nativeUtils.withCrossLinuxArm32() From bbfc961649f0309c9a50887ef38720f131917791 Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 15:41:34 -0500 Subject: [PATCH 6/9] Bump version to 2.1.0 --- publish.gradle | 2 +- vendordeps/CANBridge.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/publish.gradle b/publish.gradle index a0e8407..0485877 100644 --- a/publish.gradle +++ b/publish.gradle @@ -2,7 +2,7 @@ apply plugin: 'maven-publish' ext.licenseFile = files("$rootDir/LICENSE.txt") -def pubVersion = '2.0.1' +def pubVersion = '2.1.0' def outputsFolder = file("$buildDir/allOutputs") diff --git a/vendordeps/CANBridge.json b/vendordeps/CANBridge.json index f475b4c..08ac69f 100644 --- a/vendordeps/CANBridge.json +++ b/vendordeps/CANBridge.json @@ -1,7 +1,7 @@ { "fileName": "CANBridge.json", "name": "CANBridge", - "version": "2.0.1", + "version": "2.1.0", "uuid": "34b37c7c-8acc-405f-9631-d21f20dc59d8", "mavenUrls": [ "http://www.revrobotics.com/content/sw/max/sdk/maven/" @@ -11,7 +11,7 @@ { "groupId": "com.revrobotics.usb", "artifactId": "CANBridge-cpp", - "version": "2.0.1", + "version": "2.1.0", "libName": "CANBridge", "headerClassifier": "headers", "sharedLibrary": false, From 8baedbf38257b44ccf4bf8e2aad8ec1aa7c1c0ff Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 16:37:42 -0500 Subject: [PATCH 7/9] Add build workflow --- .github/workflows/build.yml | 75 +++++++++++++++++++++++++++++++++++++ README.md | 19 +++++++--- 2 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..63c0cc7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,75 @@ +name: Build + +on: + push: + branches: + - 'main' + pull_request: + branches: + - '*' + +defaults: + run: + shell: bash + +jobs: + build: + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + container: '' + name: windows64 + name: "build-${{ matrix.name }}" + runs-on: ${{ matrix.os }} + container: ${{ matrix.container }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 11 + + - name: Cache + uses: actions/cache@v3 + with: + path: | + .gradle + bin + build + key: ${{ matrix.name }}-build-${{ github.sha }} + restore-keys: | + ${{ matrix.name }}-build- + + - name: Publish + run: | + ./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode + + # Put release files together in one directory + - name: Create Artifact + run: | + mkdir CANBridge-artifacts + cp -r build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib + cp -r build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.dll + cp -r build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib + + # Upload build artifact + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: CANBridge-${{ github.sha }} + path: CANBridge-artifacts/ + + # Upload version.txt + - name: Upload version artifact + uses: actions/upload-artifact@v3 + with: + name: version + path: build/allOutputs/version.txt diff --git a/README.md b/README.md index e3332b1..eabd418 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# RoboRIO SDK Readme +# CANBridge ## Overview -This repository is for the CANBridge software that is run on non-roboRIO platforms. +This repository is for the CANBridge software that is run on non-roboRIO platforms. ## Build Requirements @@ -15,16 +15,25 @@ All of these, excluding Git, can be installed and configured with the [WPILib In ## Building and Publishing -Build and publish steps are done using the Gradle wrapper, `gradlew`. The Gradle wrapper is located in the root of the project, so Gradle commands must be run from there. +Building is done using the Gradle wrapper, `gradlew`. The Gradle wrapper is located in the root of the project, so Gradle commands must be run from there. 1. Clone this repository and open in VS Code - When VS Code first opens, select `Add workspace folder...` underneath `Start` on the Welcome Screen 2. Open the VS Code terminal - `View -> Terminal` or ``Ctrl+` `` 3. Run `./gradlew build` from root -4. Run `./gradlew publish` from root -The output folders will be generated under `~\releases\maven\`. +The output is placed at `~\releases\maven\release\com\revrobotics\usb\CANBridge-cpp\\`. + +### Publishing a new version + +Before publishing a new version, run `./gradlew build` locally to run the tests. GitHub Actions +cannot run the tests because they depend on having a USB CAN device connected. + +1. Bump the version number in `publish.gradle` and `CANBridge.json` +2. Commit the version bump +3. Create a new tag at that commit +4. Push the tag to GitHub ## Changelog From 5767be66ecf41085f049269e3e4cbac16f7c4343 Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Tue, 25 Apr 2023 18:29:08 -0500 Subject: [PATCH 8/9] Add release workflow --- .github/workflows/release.yml | 71 +++++++++++++++++++++++++++++++++++ README.md | 5 ++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9a90457 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Create release + +on: + push: + tags: + - 'v*' + +defaults: + run: + shell: bash + +jobs: + check-versions: + runs-on: ubuntu-latest + outputs: + TAG_NAME: ${{ env.TAG_NAME }} + VERSION: ${{ steps.get_version.outputs.version }} + steps: + - name: Get tag name + run: | + echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + # Download artifacts from build workflow + - name: Download workflow artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: build.yml + commit: ${{ github.sha }} + path: '.' + + # Get publish.gradle version + - name: Get publish.gradle version + id: get_version + run: | + echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT + echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT + + # Check publish.gradle version + - name: publish.gradle version check FAILED + if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }} + run: | + echo Tag name: ${{ env.TAG_NAME }} + echo publish.gradle version: ${{ steps.get_version.outputs.version }} + exit 1 + + prepare-release: + runs-on: ubuntu-latest + needs: check-versions + steps: + # Download API, docs, and version.txt + - name: Download workflow artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: build.yml + commit: ${{ github.sha }} + path: './artifacts' + + # Create new release draft + - name: Create release + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION=${{ needs.check-versions.outputs.version }} + TAG=v$VERSION + gh release create $TAG --draft --title "Version $VERSION" + + echo "Sleep after creating release to avoid race condition" + sleep 5 + + gh release upload $TAG CANBridge-${{ github.sha }}/* diff --git a/README.md b/README.md index eabd418..c08dd21 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,11 @@ cannot run the tests because they depend on having a USB CAN device connected. 1. Bump the version number in `publish.gradle` and `CANBridge.json` 2. Commit the version bump -3. Create a new tag at that commit +3. Create a new tag named `vX.X.X` at that commit 4. Push the tag to GitHub +5. Wait for the draft release to be created +6. Add release notes to the draft release +7. Publish the draft release ## Changelog From 4f8e0af1b813412bfb63418c2f4c3c69f82c81c2 Mon Sep 17 00:00:00 2001 From: NoahAndrews Date: Wed, 26 Apr 2023 11:45:28 -0500 Subject: [PATCH 9/9] Wait for build to finish before releasing --- .github/workflows/release.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a90457..8c5ea4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,13 @@ jobs: TAG_NAME: ${{ env.TAG_NAME }} VERSION: ${{ steps.get_version.outputs.version }} steps: + - name: Wait for build to finish + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.ref }} + check-name: 'build-windows64' + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 - name: Get tag name run: | echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV