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/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8c5ea4b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +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: 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 + + # 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 223fce8..c08dd21 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# RoboRIO SDK Readme +# CANBridge ## 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 @@ -15,16 +15,28 @@ 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 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 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 e620ab4..7ead092 100644 --- a/config.gradle +++ b/config.gradle @@ -1,16 +1,13 @@ -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" - opencvVersion = "3.4.7-2" - googleTestVersion = "1.9.0-3-437e100" + wpiVersion = "2023.+" + niLibVersion = "2023.3.0" + googleTestVersion = "1.11.0-3" } } } 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/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/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/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/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 +} diff --git a/vendordeps/CANBridge.json b/vendordeps/CANBridge.json index 3e73f36..08ac69f 100644 --- a/vendordeps/CANBridge.json +++ b/vendordeps/CANBridge.json @@ -1,34 +1,17 @@ { "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/" ], "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", "artifactId": "CANBridge-cpp", - "version": "2.0.1", + "version": "2.1.0", "libName": "CANBridge", "headerClassifier": "headers", "sharedLibrary": false,