This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
232 lines (195 loc) · 6.37 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id 'edu.wpi.first.NativeUtils' version '2.1.2'
id "edu.wpi.first.GradleJni" version "0.3.1"
id "cpp"
id "java"
id "eclipse"
id "checkstyle"
id "pmd"
id "jacoco"
}
ext.allwpilibVersion = '2020.2.2'
ext.rev_library_version = "1.5.0"
ext.release_version = rev_library_version + "_V2"
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://frcmaven.wpi.edu/artifactory/release/"
}
maven {
url "http://www.revrobotics.com/content/sw/max/sdk/maven/"
}
}
sourceSets {
main {
java {
srcDirs += "rev_source/java"
}
}
}
apply from: "config.gradle"
model {
dependencyConfigs {
wpiutil(DependencyConfig) {
groupId = 'edu.wpi.first.wpiutil'
artifactId = 'wpiutil-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = allwpilibVersion
sharedConfigs = [ SparkMaxDriver: [], SparkMaxDriverDev:[] ]
}
halsim(DependencyConfig) {
groupId = 'edu.wpi.first.hal'
artifactId = 'hal-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = allwpilibVersion
sharedConfigs = [ SparkMaxDriver: [], SparkMaxDriverDev:[] ]
}
}
components {
SparkMaxDriver(JniNativeLibrarySpec) {
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
sources {
cpp {
source {
srcDirs = ["src/main/native/cpp"]
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["src/main/native/include",
"rev_source/native/include"]
}
}
}
}
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
SparkMaxDriverDev(NativeExecutableSpec) {
targetBuildTypes 'release'
sources {
cpp {
source {
srcDirs "${projectDir}"
include 'dummy.cpp'
}
exportedHeaders {
srcDir 'src/main/native/include'
if (project.hasProperty('generatedHeaders')) {
srcDir generatedHeaders
}
}
}
}
binaries.all {
lib library: "SparkMaxDriver", linkage: 'shared'
}
}
}
tasks {
def c = $.components
project.tasks.create('runCpp', Exec) {
def found = false
def systemArch = getCurrentArch()
c.each {
if (it in NativeExecutableSpec && it.name == "SparkMaxDriverDev") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.name
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
test.dependsOn it.tasks.install
test.systemProperty 'java.library.path', filePath
test.environment 'LD_LIBRARY_PATH', filePath
test.workingDir filePath
found = true
}
}
}
}
}
println("Found " + found)
}
}
}
ext.use_real_library = true
if(!use_real_library)
{
sourceSets {
main {
java {
srcDirs += ["src/rev/java"]
}
}
}
}
ext.get_os_arc_name = {
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX())
{
return "osx" + getCurrentArch();
}
return org.gradle.internal.os.OperatingSystem.current().getFamilyName() + getCurrentArch()
}
dependencies {
compile 'edu.wpi.first.wpiutil:wpiutil-java:' + allwpilibVersion
compile 'edu.wpi.first.wpilibj:wpilibj-java:' + allwpilibVersion
compile 'edu.wpi.first.hal:hal-java:' + allwpilibVersion
testRuntime 'edu.wpi.first.hal:hal-jni:' + allwpilibVersion + ':' + get_os_arc_name()
if(use_real_library)
{
compile 'com.revrobotics.frc:SparkMax-java:' + rev_library_version
}
testCompile 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.2.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
testRuntime 'org.junit.platform:junit-platform-launcher:1.2.0'
compile 'org.apache.logging.log4j:log4j-api:2.11.0'
compile 'org.apache.logging.log4j:log4j-core:2.11.0'
testCompile 'com.revrobotics.frc:SparkMax-driver:' + rev_library_version + ":headers@zip"
}
test {
useJUnitPlatform()
testLogging {
events TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
exceptionFormat "full"
}
}
/////////////////////////////////////////////////////////////////////////////////
// Style/Formatting stuff
checkstyle {
toolVersion = "8.12"
configDir = file("${project.rootDir}/styleguide")
config = resources.text.fromFile(new File(configDir, "checkstyle.xml"))
}
pmd {
toolVersion = '6.7.0'
consoleOutput = true
reportsDir = file("${project.buildDir}/reports/pmd")
ruleSetFiles = files(file("$rootDir/styleguide/pmd-ruleset.xml"))
ruleSets = []
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
check.dependsOn jacocoTestReport
/////////////////////////////////////////////////////////////////////////////////
javadoc {
failOnError = false
}
wrapper {
gradleVersion = '5.0'
}
apply from: "publish.gradle"
//apply from: "${rootDir}/extract_native_libraries.gradle"
//test.dependsOn extract_wpilib