-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies.gradle
136 lines (113 loc) · 4.25 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
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
}
}
}
ext.addUserLinks = { linker, targetPlatform, implLib ->
def libPattern = /.*((\\/|\\).*)+lib(?<libName>.+).(.+)$/
def libraryArgs = []
def libraryPath = file(driverLibraryLib).path
// adds all libraries found in the driver folder
def libraryTree = fileTree(libraryPath)
libraryTree.include '*.so'
libraryTree.include '*.a'
libraryTree.each { lib ->
def nameMatcher = (lib.path =~ libPattern)
if (nameMatcher[0].size() > 1) {
def name = nameMatcher.group('libName')
libraryArgs << '-l' + name
}
}
// Add all arguments
String architecture = targetPlatform.architecture
if (architecture.contains('arm')){
linker.args << '-L' + libraryPath
linker.args.addAll(libraryArgs)
}
}