Skip to content

Commit ba3d418

Browse files
committed
Rebuild JNI tests
1 parent 2a5a5e7 commit ba3d418

File tree

6 files changed

+257
-186
lines changed

6 files changed

+257
-186
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-22.04
2828
strategy:
2929
matrix:
30-
language: [cpp, java, asm] #, jni]
30+
language: [cpp, java, asm, jni]
3131
steps:
3232
- uses: actions/checkout@v4
3333
- uses: actions/setup-java@v4
@@ -40,8 +40,8 @@ jobs:
4040
path: ~/.m2/repository/
4141

4242
- name: Setup RoboRIO Toolchain
43-
if: ${{ (matrix.language == 'cpp') || (matrix.language == 'asm') }}
44-
run: ../../gradlew installRoboRioToolchain
43+
if: ${{ (matrix.language == 'cpp') || (matrix.language == 'asm') || (matrix.language == 'jni') }}
44+
run: ./gradlew installRoboRioToolchain
4545
working-directory: testing/${{ matrix.language }}
4646
- name: Test ${{ matrix.language }} Build
4747
run: ../../gradlew build

testing/jni/build.gradle

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,113 +2,124 @@ plugins {
22
id "java"
33
id "cpp"
44
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-2"
5-
id 'edu.wpi.first.GradleJni' version '0.10.1'
5+
id 'edu.wpi.first.GradleJni' version '1.1.0'
66
}
77

8-
sourceCompatibility = JavaVersion.VERSION_17
9-
targetCompatibility = JavaVersion.VERSION_17
8+
def projectFolder = project.buildFile.parentFile
9+
def testingFolder = projectFolder.parentFile
10+
11+
if (testingFolder.name != 'testing' || projectFolder.name != 'jni') {
12+
throw new GradleException("These projects are not to be used for robot projects. See README.md in the GradleRIO testing folder for the correct templates to use.")
13+
}
14+
15+
java {
16+
sourceCompatibility = JavaVersion.VERSION_11
17+
targetCompatibility = JavaVersion.VERSION_11
18+
}
1019

1120
def ROBOT_MAIN_CLASS = "frc.robot.Main"
1221

1322
// Define my targets (RoboRIO) and artifacts (deployable files)
1423
// This is added by GradleRIO's backing project DeployUtils.
1524
deploy {
1625
targets {
17-
roboRIO("roborio") {
26+
roborio(getTargetTypeClass('RoboRIO')) {
1827
// Team number is loaded either from the .wpilib/wpilib_preferences.json
1928
// or from command line. If not found an exception will be thrown.
2029
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
2130
// want to store a team number in this file.
2231
team = frc.getTeamNumber()
23-
}
24-
}
25-
artifacts {
26-
frcJavaArtifact('frcJava') {
27-
targets << "roborio"
28-
// Debug can be overridden by command line, for use with VSCode
29-
debug = frc.getDebugOrDefault(false)
30-
}
31-
// Built in artifact to deploy arbitrary files to the roboRIO.
32-
fileTreeArtifact('frcStaticFileDeploy') {
33-
// The directory below is the local directory to deploy
34-
files = fileTree(dir: 'src/main/deploy')
35-
// Deploy to RoboRIO target, into /home/lvuser/deploy
36-
targets << "roborio"
37-
directory = '/home/lvuser/deploy'
38-
}
39-
frcNativeLibraryArtifact('jniLibrary') {
40-
targets << "roborio"
41-
component = 'JNILibrary'
42-
buildType = 'release'
32+
debug = project.frc.getDebugOrDefault(false)
33+
34+
artifacts {
35+
frcJava(getArtifactTypeClass('FRCJavaArtifact')) {
36+
}
37+
38+
frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) {
39+
files = project.fileTree('src/main/deploy')
40+
directory = '/home/lvuser/deploy'
41+
}
42+
}
4343
}
4444
}
4545
}
4646

47-
// Set this to true to enable desktop support.
48-
def includeDesktopSupport = true
47+
def deployArtifact = deploy.targets.roborio.artifacts.frcJava
4948

5049
// Simulation configuration (e.g. environment variables).
51-
sim {
52-
// Sets the websocket client remote host.
53-
// envVar "HALSIMWS_HOST", "10.0.0.2"
54-
}
50+
51+
wpi.sim.addGui().defaultEnabled = true
52+
wpi.sim.addDriverstation()
53+
54+
//Sets the websocket client remote host.
55+
wpi.sim.envVar("HALSIMWS_HOST", "10.0.0.2")
56+
wpi.sim.addWebsocketsServer().defaultEnabled = true
57+
wpi.sim.addWebsocketsClient().defaultEnabled = true
5558

5659
model {
5760
components {
5861
JNILibrary(JniNativeLibrarySpec) {
5962
targetPlatform wpi.platforms.roborio
60-
if (includeDesktopSupport) {
61-
targetPlatform wpi.platforms.desktop
62-
}
6363

6464
enableCheckTask true
6565
javaCompileTasks << compileJava
6666
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio)
67-
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.raspbian)
68-
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.aarch64bionic)
67+
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm32)
68+
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64)
6969

7070
sources {
7171
cpp {
7272
source {
7373
srcDirs 'src/main/native/cpp'
7474
include '**/*.cpp'
7575
}
76-
exportedHeaders {
77-
srcDir 'src/main/native/include'
78-
include '**/*.h'
79-
}
80-
8176
}
8277
}
8378

84-
wpi.useLibrary(it, 'driver_shared')
79+
nativeUtils.useRequiredLibrary(it, "driver_shared")
8580
}
8681
}
8782
}
8883

8984
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
9085
// Also defines JUnit 4.
9186
dependencies {
92-
implementation wpi.deps.wpilib()
93-
nativeZip wpi.deps.wpilibJni(wpi.platforms.roborio)
94-
nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop)
87+
implementation wpi.java.deps.wpilib()
88+
implementation wpi.java.vendor.java()
9589

90+
roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio)
91+
roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio)
9692

97-
implementation wpi.deps.vendor.java()
98-
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
99-
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
93+
roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio)
94+
roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio)
10095

101-
testImplementation 'junit:junit:4.12'
96+
nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop)
97+
nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop)
98+
simulationDebug wpi.sim.enableDebug()
99+
100+
nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop)
101+
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
102+
simulationRelease wpi.sim.enableRelease()
102103

103-
// Enable simulation gui support. Must check the box in vscode to enable support
104-
// upon debugging
105-
simulation wpi.deps.sim.gui(wpi.platforms.desktop, false)
104+
testImplementation 'junit:junit:4.12'
106105
}
107106

108107
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
109108
// in order to make them all available at runtime. Also adding the manifest so WPILib
110109
// knows where to look for our Robot Class.
111110
jar {
112111
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
112+
113113
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
114+
115+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
116+
}
117+
118+
deployArtifact.jarTask = jar
119+
wpi.java.configureExecutableTasks(jar)
120+
wpi.java.configureTestTasks(test)
121+
122+
wrapper {
123+
gradleVersion = '8.5'
124+
distributionType = Wrapper.DistributionType.BIN
114125
}
-14.9 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=permwrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=permwrapper/dists

0 commit comments

Comments
 (0)