-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
433 lines (365 loc) · 11.8 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
import org.gradle.nativeplatform.NativeDependencySet
plugins {
id 'base'
id 'maven-publish'
id "com.jfrog.artifactory" version "4.29.3"
id 'edu.wpi.first.NativeUtils' version '2025.3.0'
id 'cpp'
id 'c'
}
publishing {
repositories {
if (project.hasProperty('releaseRepoPublish')) {
maven {
url "${System.getProperty('user.home')}/releases/maven/release"
}
} else {
maven {
url "${System.getProperty('user.home')}/releases/maven/development"
}
}
}
}
if (System.getenv()['RUN_AZURE_ARTIFACTORY_RELEASE'] != null) {
artifactory {
contextUrl = 'https://frcmaven.wpi.edu/artifactory' // base artifactory url
publish {
repository {
if (project.hasProperty('releaseRepoPublish')) {
repoKey = 'release'
} else {
repoKey = 'development'
}
username = System.getenv()['ARTIFACTORY_PUBLISH_USERNAME']
password = System.getenv()['ARTIFACTORY_PUBLISH_PASSWORD']
maven = true
}
defaults {
publications ('chipobject', 'netcomm', 'runtime', 'visa')
}
}
}
publish.dependsOn artifactoryPublish
}
nativeUtils.addWpiNativeUtils()
nativeUtils.withCrossRoboRIO()
nativeUtils.wpi.addWarnings()
nativeUtils.wpi.addWarningsAsErrors()
nativeUtils.setSinglePrintPerPlatform()
nativeUtils.platformConfigs.linuxathena.linker.args.add("-Wl,--fatal-warnings")
nativeUtils.crossCompilers.named(nativeUtils.wpi.platforms.roborio) { c ->
c.optional.set(false)
}
class FileDependencySet implements NativeDependencySet {
private FileCollection linkFiles;
private FileCollection emptySet
FileDependencySet(FileCollection files, FileCollection emptySet) {
linkFiles = files
this.emptySet = emptySet
}
@Override
FileCollection getIncludeRoots() {
return emptySet
}
@Override
FileCollection getLinkFiles() {
return linkFiles
}
@Override
FileCollection getRuntimeFiles() {
return emptySet
}
}
def netCommDependencySet = new FileDependencySet(project.files(
'src/lib/netcomm/libFRC_NetworkCommunication.so.25.0.0',
'src/lib/chipobject/libRoboRIO_FRC_ChipObject.so.25.0.0',
'src/lib/visa/libvisa.so.23.3.0'),
project.files())
model {
components {
test(NativeExecutableSpec) {
targetPlatform nativeUtils.wpi.platforms.roborio
sources {
cpp {
source {
srcDirs 'src/test'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/include'
}
}
}
binaries.all {
linker.args '-ldl'
lib netCommDependencySet
lib library: 'embcanshim', linkage: 'shared'
lib library: 'fpgalvshim', linkage: 'shared'
}
}
embcanshim(NativeLibrarySpec) {
targetPlatform nativeUtils.wpi.platforms.roborio
sources {
c {
source {
srcDirs 'src/shims/embcan'
include '**/*.c'
}
}
}
binaries.all {
tasks.withType(LinkSharedLibrary) {
installName = 'libnirio_emb_can.so.23'
}
}
}
fpgalvshim(NativeLibrarySpec) {
targetPlatform nativeUtils.wpi.platforms.roborio
sources {
c {
source {
srcDirs 'src/shims/fpgalv'
include '**/*.c'
}
}
}
binaries.all {
tasks.withType(LinkSharedLibrary) {
installName = 'libNiFpgaLv.so.13'
}
}
}
}
binaries {
withType(NativeBinarySpec).all {
nativeUtils.usePlatformArguments(it)
}
withType(StaticLibraryBinarySpec).all {
buildable = false
}
}
}
apply from: 'config.gradle'
def allOutputsFolder = file("$buildDir/allOutputs")
if (project.hasProperty('releaseRepoPublish')) {
allOutputsFolder = file("$buildDir/allOutputsRelease")
}
task copyAllOutputs(type: Copy) {
destinationDir = allOutputsFolder
}
build.dependsOn copyAllOutputs
ext.addTaskToCopyAllOutputs = { task ->
copyAllOutputs.dependsOn task
copyAllOutputs.inputs.file task.archivePath
copyAllOutputs.from task.archivePath
}
def pubVersion = '2025.0.0'
def baseArtifactId = 'chipobject'
def artifactGroupId = 'edu.wpi.first.ni-libraries'
def zipBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_chipobject_CLS'
def netcommBaseArtifactId = 'netcomm'
def netcommZipBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_netcomm_CLS'
def runtimeBaseArtifactId = 'runtime'
def runtimeZipBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_runtime_CLS'
def visaBaseArtifactId = 'visa'
def visaZipBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_visa_CLS'
def outputsFolder = file("$project.buildDir/outputs")
def versionFile = file("$outputsFolder/version.txt")
task outputVersions() {
description = 'Prints the versions of this to a file for use by the downstream packaging project'
group = 'Build'
outputs.files(versionFile)
doFirst {
buildDir.mkdir()
outputsFolder.mkdir()
}
doLast {
versionFile.write pubVersion
}
}
build.dependsOn outputVersions
copyAllOutputs.dependsOn outputVersions
copyAllOutputs.inputs.file versionFile
copyAllOutputs.from versionFile
task libZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "linuxathena"
from('src/lib/chipobject') {
into '/linux/athena/shared/'
}
}
task libZipDebug(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "linuxathenadebug"
from('src/lib/chipobject') {
into '/linux/athena/shared/'
}
}
task headersZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "headers"
from('src/include/FRC_FPGA_ChipObject') {
into '/FRC_FPGA_ChipObject'
}
}
task visaLib(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = visaZipBaseName
classifier = "linuxathena"
from('src/lib/visa') {
into '/linux/athena/shared/'
}
}
task visaLibDebug(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = visaZipBaseName
classifier = "linuxathenadebug"
from('src/lib/visa') {
into '/linux/athena/shared/'
}
}
task visaHeaders(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = visaZipBaseName
classifier = "headers"
from ('src/include/visa') {
into '/visa'
}
}
task netCommLib(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = netcommZipBaseName
classifier = "linuxathena"
from('src/lib/netcomm') {
into '/linux/athena/shared/'
}
}
task netCommLibDebug(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = netcommZipBaseName
classifier = "linuxathenadebug"
from('src/lib/netcomm') {
into '/linux/athena/shared/'
}
}
task netCommHeaders(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = netcommZipBaseName
classifier = "headers"
from('src/include/FRC_NetworkCommunication') {
into '/FRC_NetworkCommunication'
}
}
task runtimeLib(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = runtimeZipBaseName
classifier = "linuxathena"
}
task runtimeLibDebug(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = runtimeZipBaseName
classifier = "linuxathenadebug"
}
task imageZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = runtimeZipBaseName
classifier = "allowedimages"
from('allowed_images.txt')
}
build.dependsOn netCommLib
build.dependsOn headersZip
build.dependsOn netCommHeaders
build.dependsOn libZip
build.dependsOn libZipDebug
build.dependsOn netCommLibDebug
build.dependsOn visaLib
build.dependsOn visaLibDebug
build.dependsOn visaHeaders
build.dependsOn runtimeLib
build.dependsOn runtimeLibDebug
build.dependsOn imageZip
addTaskToCopyAllOutputs(netCommLib)
addTaskToCopyAllOutputs(headersZip)
addTaskToCopyAllOutputs(libZip)
addTaskToCopyAllOutputs(netCommHeaders)
addTaskToCopyAllOutputs(libZipDebug)
addTaskToCopyAllOutputs(netCommLibDebug)
addTaskToCopyAllOutputs(runtimeLib)
addTaskToCopyAllOutputs(runtimeLibDebug)
addTaskToCopyAllOutputs(visaLib)
addTaskToCopyAllOutputs(visaLibDebug)
addTaskToCopyAllOutputs(visaHeaders)
addTaskToCopyAllOutputs(imageZip)
model {
publishing {
def taskList = createComponentZipTasks($.components, ['embcanshim', 'fpgalvshim'], 'DoNotPublishRuntime', Zip, project, includeStandardZipFormat)
}
}
publishing {
publications {
chipobject(MavenPublication) {
artifact libZip
artifact headersZip
artifact libZipDebug
artifactId = "${baseArtifactId}"
groupId artifactGroupId
version pubVersion
}
netcomm(MavenPublication) {
artifact netCommLib
artifact netCommHeaders
artifact netCommLibDebug
artifactId = "${netcommBaseArtifactId}"
groupId artifactGroupId
version pubVersion
}
visa(MavenPublication) {
artifact visaLib
artifact visaHeaders
artifact visaLibDebug
artifactId = "${visaBaseArtifactId}"
groupId artifactGroupId
version pubVersion
}
runtime(MavenPublication) {
artifact runtimeLib
artifact runtimeLibDebug
artifact imageZip
artifactId = "${runtimeBaseArtifactId}"
groupId artifactGroupId
version pubVersion
}
}
}
task patchNiLibraries() {
doLast {
// Patch ChipObject headers to be self contained
FileTree chipTree = fileTree(dir: "$rootDir/src/include/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace")
chipTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('#include \"tSystemInterface.h\"', '#include \"../tSystem.h\"\n#include \"../tSystemInterface.h\"')
file.write(contents, 'UTF-8')
}
// Patch NetComm headers to work on Windows
FileTree netTree = fileTree(dir: "$rootDir/src/include/FRC_NetworkCommunication")
netTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('#ifdef WIN32', '#ifdef _WIN32')
contents = contents.replaceAll('# include <vxWorks_compat.h>', '#include <windows.h>')
contents = contents.replaceAll('#include <vxWorks_compat.h>', '#include <windows.h>')
file.write(contents, 'UTF-8')
}
FileTree allTree = fileTree(dir: "$rootDir/src/include/")
allTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('\r\n', '\n')
file.write(contents, 'UTF-8')
}
}
}
wrapper {
gradleVersion = '7.5.1'
}