forked from PeterJohnson/sweep-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies.gradle
283 lines (231 loc) · 9.06 KB
/
dependencies.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
task downloadWpiUtil() {
description = 'Downloads the C++ ARM wpiutil maven dependency.'
group = 'WPILib'
def depFolder = "$buildDir/dependencies"
def utilZip = file("$depFolder/wpiutil.zip")
outputs.file(utilZip)
def armWpiUtil
doFirst {
def armWpiUtilDependency = project.dependencies.create("edu.wpi.first.wpilib:wpiutil:+:arm@zip")
def armWpiUtilConfig = project.configurations.detachedConfiguration(armWpiUtilDependency)
armWpiUtilConfig.setTransitive(false)
armWpiUtil = armWpiUtilConfig.files[0].canonicalFile
}
doLast {
copy {
from armWpiUtil
rename 'wpiutil(.+)', 'wpiutil.zip'
into depFolder
}
}
}
def wpiUtilUnzipLocation = "$buildDir/wpiutil"
// Create a task that will unzip the wpiutil files into a temporary build directory
task unzipWpiUtil(type: Copy) {
description = 'Unzips the wpiutil maven dependency so that the include files and libraries can be used'
group = 'WPILib'
dependsOn downloadWpiUtil
from zipTree(downloadWpiUtil.outputs.files.singleFile)
into wpiUtilUnzipLocation
}
ext.defineWpiUtilProperties = {
ext.wpiUtil = wpiUtilUnzipLocation
ext.wpiUtilInclude = "$wpiUtilUnzipLocation/include"
ext.wpiUtilLibArmLocation = "$wpiUtilUnzipLocation/Linux/arm"
ext.wpiUtilSharedLib = "$wpiUtilLibArmLocation/libwpiutil.so"
ext.wpiUtilSharedLibDebug = "$wpiUtilLibArmLocation/libwpiutil.so.debug"
ext.addWpiUtilLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project(':').unzipWpiUtil
String architecture = targetPlatform.architecture
if (architecture.contains('arm')) {
linker.args wpiUtilSharedLib
}
}
}
def halUnzipLocation = "$buildDir/hal"
task downloadHAL() {
description = 'Downloads the C++ ARM HAL maven dependency.'
group = 'WPILib'
def depFolder = "$buildDir/dependencies"
def libZip = file("$depFolder/hal.zip")
outputs.file(libZip)
def armHal
doFirst {
def armHALDependency = project.dependencies.create("edu.wpi.first.wpilib:hal:+@zip")
def armHALConfig = project.configurations.detachedConfiguration(armHALDependency)
armHALConfig.setTransitive(false)
armHal = armHALConfig.files[0].canonicalFile
}
doLast {
copy {
from armHal
rename 'hal(.+)', 'hal.zip'
into depFolder
}
}
}
// Create a task that will unzip the hal files into a temporary build directory
task unzipHAL(type: Copy) {
description = 'Unzips the hal maven dependency so that the include files and libraries can be used'
group = 'WPILib'
dependsOn downloadHAL
from zipTree(downloadHAL.outputs.files.singleFile)
into halUnzipLocation
}
ext.defineHALProperties = {
ext.hal = halUnzipLocation
ext.halInclude = "$halUnzipLocation/include"
ext.halLocation = "$halUnzipLocation/lib"
ext.halSharedLib = "$halLocation/libHALAthena.so"
ext.addHalLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project(':').unzipHAL
String architecture = targetPlatform.architecture
if (architecture.contains('arm')) {
// Grab all the shared libraries and link them
linker.args halSharedLib
linker.args "$halLocation/libnilibraries.so"
def libraryPath = halLocation
linker.args << '-L' + libraryPath
}
}
}
task downloadNetworkTables() {
description = 'Downloads the C++ ARM NetworkTables maven dependency.'
group = 'WPILib'
def depFolder = "$buildDir/dependencies"
def ntZip = file("$depFolder/ntcore.zip")
outputs.file(ntZip)
def armNetTables
doFirst {
def armNtDependency = project.dependencies.create('edu.wpi.first.wpilib.networktables.cpp:NetworkTables:+:arm@zip')
def armConfig = project.configurations.detachedConfiguration(armNtDependency)
armConfig.setTransitive(false)
armNetTables = armConfig.files[0].canonicalFile
}
doLast {
copy {
from armNetTables
rename 'NetworkTables(.+)', 'ntcore.zip'
into depFolder
}
}
}
def netTablesUnzipLocation = "$buildDir/networktables"
// Create a task that will unzip the networktables files into a temporary build directory
task unzipNetworkTables(type: Copy) {
description = 'Unzips the networktables maven dependency so that the include files and libraries can be used'
group = 'WPILib'
dependsOn downloadNetworkTables
from zipTree(downloadNetworkTables.outputs.files.singleFile)
into netTablesUnzipLocation
}
// This defines a project property that projects depending on network tables can use to setup that dependency.
ext.defineNetworkTablesProperties = {
ext.netTables = netTablesUnzipLocation
ext.netTablesInclude = "$netTablesUnzipLocation/include"
ext.netLibArmLocation = "$netTablesUnzipLocation/Linux/arm"
ext.netSharedLib = "$netLibArmLocation/libntcore.so"
ext.netSharedLibDebug = "$netLibArmLocation/libntcore.so.debug"
ext.addNetworkTablesLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project(':').unzipNetworkTables
String architecture = targetPlatform.architecture
if (architecture.contains('arm')) {
linker.args netSharedLib
}
addWpiUtilLibraryLinks(compileTask, linker, targetPlatform)
}
}
def wpilibUnzipLocation = "$buildDir/wpilib"
task downloadWpilib() {
description = 'Downloads the C++ ARM wpilib maven dependency.'
group = 'WPILib'
def depFolder = "$buildDir/dependencies"
def libZip = file("$depFolder/athena-wpilibc.zip")
outputs.file(libZip)
def armWPILib
doFirst {
def armWpiLibDependency = project.dependencies.create("edu.wpi.first.wpilibc:athena:+@zip")
def armWpiLibConfig = project.configurations.detachedConfiguration(armWpiLibDependency)
armWpiLibConfig.setTransitive(false)
armWPILib = armWpiLibConfig.files[0].canonicalFile
}
doLast {
copy {
from armWPILib
rename 'athena(.+)', 'athena-wpilibc.zip'
into depFolder
}
}
}
// Create a task that will unzip the wpilib files into a temporary build directory
task unzipWpilib(type: Copy) {
description = 'Unzips the wpilib maven dependency so that the include files and libraries can be used'
group = 'WPILib'
dependsOn downloadWpilib
from zipTree(downloadWpilib.outputs.files.singleFile)
into wpilibUnzipLocation
}
ext.defineWpiLibProperties = {
ext.wpilib = wpilibUnzipLocation
ext.wpilibInclude = "$wpilibUnzipLocation/include"
ext.wpilibLocation = "$wpilibUnzipLocation/lib"
ext.wpilibSharedLib = "$wpilibLocation/libwpilibc.so"
ext.addWpilibLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project(':').unzipWpilib
String architecture = targetPlatform.architecture
if (architecture.contains('arm')) {
// Grab all the shared libraries and link them
linker.args wpilibSharedLib
def libraryPath = wpilibLocation
linker.args << '-L' + libraryPath
}
}
}
def cscoreUnzipLocation = "$buildDir/cscore"
task downloadCsCore() {
description = 'Downloads the C++ ARM CsCore maven dependency.'
group = 'WPILib'
def depFolder = "$buildDir/dependencies"
def libZip = file("$depFolder/cscore.zip")
outputs.file(libZip)
def armCsCore
doFirst {
def armCsDependency = project.dependencies.create("edu.wpi.cscore.cpp:cscore:+:athena-uberzip@zip")
def armCsConfig = project.configurations.detachedConfiguration(armCsDependency)
armCsConfig.setTransitive(false)
armCsCore = armCsConfig.files[0].canonicalFile
}
doLast {
copy {
from armCsCore
rename 'cscore(.+)', 'cscore.zip'
into depFolder
}
}
}
// Create a task that will unzip the cscore files into a temporary build directory
task unzipCsCore(type: Copy) {
description = 'Unzips the cscore maven dependency so that the include files and libraries can be used'
group = 'WPILib'
dependsOn downloadCsCore
from zipTree(downloadCsCore.outputs.files.singleFile)
into cscoreUnzipLocation
}
ext.defineCsCoreProperties = {
ext.cscore = cscoreUnzipLocation
ext.cscoreInclude = "$cscoreUnzipLocation/include"
ext.cscoreLocation = "$cscoreUnzipLocation/lib"
ext.opencvSharedLib = "$cscoreLocation/libopencv.so"
ext.cscoreSharedLib = "$cscoreLocation/libcscore.so"
ext.addCsCoreLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project(':').unzipCsCore
String architecture = targetPlatform.architecture
if (architecture.contains('arm')) {
// Grab all the shared libraries and link them
linker.args opencvSharedLib
linker.args cscoreSharedLib
def libraryPath = cscoreLocation
linker.args << '-L' + libraryPath
}
}
}