Skip to content

Commit 6655b12

Browse files
authored
Add gradle templates for XRP (#595)
1 parent c0015d3 commit 6655b12

File tree

7 files changed

+193
-0
lines changed

7 files changed

+193
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "disabled",
3+
"java.import.gradle.enabled": false,
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.svn": true,
7+
"**/.hg": true,
8+
"**/CVS": true,
9+
"**/.DS_Store": true,
10+
"bin/": true,
11+
"**/.classpath": true,
12+
"**/.project": true,
13+
"**/.settings": true,
14+
"**/.factorypath": true,
15+
"**/*~": true
16+
},
17+
"C_Cpp.default.configurationProvider": "vscode-wpilib",
18+
"wpilib.skipSelectSimulateExtension": true
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enableCppIntellisense": true,
3+
"currentLanguage": "cpp",
4+
"projectYear": "2023",
5+
"teamNumber": -1
6+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
plugins {
2+
id "cpp"
3+
id "google-test-test-suite"
4+
id "edu.wpi.first.GradleRIO" version "###GRADLERIOREPLACE###"
5+
}
6+
7+
// Simulation configuration (e.g. environment variables).
8+
wpi.sim.addGui().defaultEnabled = true
9+
wpi.sim.addDriverstation()
10+
11+
//Sets the websocket client remote host.
12+
wpi.sim.envVar("HALSIMWS_HOST", "192.168.42.1")
13+
wpi.sim.envVar("HALSIMWS_FILTERS", "AIO,DIO,DriverStation,Encoder,Gyro,XRPMotor,XRPServo")
14+
wpi.sim.addWebsocketsServer().defaultEnabled = true
15+
wpi.sim.addWebsocketsClient().defaultEnabled = true
16+
17+
model {
18+
components {
19+
frcUserProgram(NativeExecutableSpec) {
20+
targetPlatform wpi.platforms.desktop
21+
22+
sources.cpp {
23+
source {
24+
srcDir 'src/main/cpp'
25+
include '**/*.cpp', '**/*.cc'
26+
}
27+
exportedHeaders {
28+
srcDir 'src/main/include'
29+
}
30+
}
31+
32+
wpi.cpp.enableExternalTasks(it)
33+
34+
wpi.sim.enable(it)
35+
36+
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
37+
wpi.cpp.vendor.cpp(it)
38+
wpi.cpp.deps.wpilib(it)
39+
}
40+
}
41+
testSuites {
42+
frcUserProgramTest(GoogleTestTestSuiteSpec) {
43+
testing $.components.frcUserProgram
44+
45+
sources.cpp {
46+
source {
47+
srcDir 'src/test/cpp'
48+
include '**/*.cpp'
49+
}
50+
}
51+
52+
wpi.cpp.enableExternalTasks(it)
53+
54+
wpi.cpp.vendor.cpp(it)
55+
wpi.cpp.deps.wpilib(it)
56+
wpi.cpp.deps.googleTest(it)
57+
}
58+
}
59+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <hal/HAL.h>
2+
3+
#include "gtest/gtest.h"
4+
5+
int main(int argc, char** argv) {
6+
HAL_Initialize(500, 0);
7+
::testing::InitGoogleTest(&argc, argv);
8+
int ret = RUN_ALL_TESTS();
9+
return ret;
10+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.server.launchMode": "Standard",
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.svn": true,
7+
"**/.hg": true,
8+
"**/CVS": true,
9+
"**/.DS_Store": true,
10+
"bin/": true,
11+
"**/.classpath": true,
12+
"**/.project": true,
13+
"**/.settings": true,
14+
"**/.factorypath": true,
15+
"**/*~": true
16+
},
17+
"wpilib.skipSelectSimulateExtension": true,
18+
"java.test.config": [
19+
{
20+
"name": "WPIlibUnitTests",
21+
"workingDirectory": "${workspaceFolder}/build/jni/release",
22+
"vmargs": [ "-Djava.library.path=${workspaceFolder}/build/jni/release" ],
23+
"env": {
24+
"LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" ,
25+
"DYLD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release"
26+
}
27+
},
28+
],
29+
"java.test.defaultConfig": "WPIlibUnitTests"
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enableCppIntellisense": false,
3+
"currentLanguage": "java",
4+
"projectYear": "2023",
5+
"teamNumber": -1
6+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
plugins {
2+
id "java"
3+
id "edu.wpi.first.GradleRIO" version "###GRADLERIOREPLACE###"
4+
}
5+
6+
sourceCompatibility = JavaVersion.VERSION_11
7+
targetCompatibility = JavaVersion.VERSION_11
8+
9+
def ROBOT_MAIN_CLASS = "###ROBOTCLASSREPLACE###"
10+
11+
// Set this to true to enable desktop support.
12+
def includeDesktopSupport = true
13+
14+
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
15+
// Also defines JUnit 5.
16+
dependencies {
17+
implementation wpi.java.deps.wpilib()
18+
implementation wpi.java.vendor.java()
19+
20+
nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop)
21+
nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop)
22+
simulationDebug wpi.sim.enableDebug()
23+
24+
nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop)
25+
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
26+
simulationRelease wpi.sim.enableRelease()
27+
28+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
29+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
30+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
31+
}
32+
33+
test {
34+
useJUnitPlatform()
35+
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
36+
}
37+
38+
// Simulation configuration (e.g. environment variables).
39+
wpi.sim.addGui().defaultEnabled = true
40+
wpi.sim.addDriverstation()
41+
42+
//Sets the websocket client remote host.
43+
wpi.sim.envVar("HALSIMWS_HOST", "192.168.42.1")
44+
wpi.sim.envVar("HALSIMWS_FILTERS", "AIO,DIO,DriverStation,Encoder,Gyro,XRPMotor,XRPServo")
45+
wpi.sim.addWebsocketsServer().defaultEnabled = true
46+
wpi.sim.addWebsocketsClient().defaultEnabled = true
47+
48+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
49+
// in order to make them all available at runtime. Also adding the manifest so WPILib
50+
// knows where to look for our Robot Class.
51+
jar {
52+
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
53+
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
54+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
55+
}
56+
57+
wpi.java.configureExecutableTasks(jar)
58+
wpi.java.configureTestTasks(test)
59+
60+
// Configure string concat to always inline compile
61+
tasks.withType(JavaCompile) {
62+
options.compilerArgs.add '-XDstringConcat=inline'
63+
}

0 commit comments

Comments
 (0)