-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
184 lines (155 loc) · 5.04 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
import org.gradle.internal.os.OperatingSystem
plugins {
id 'net.ltgt.errorprone' version '0.0.8'
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '1.6'
id "de.undercouch.download" version "3.2.0"
}
allprojects {
repositories {
mavenCentral()
}
}
import de.undercouch.gradle.tasks.download.Download
if (!hasProperty('releaseType')) {
WPILibVersion {
releaseType = 'official'
}
}
ext.buildArm = !project.hasProperty('skipArm')
ext.buildNative = !project.hasProperty('skipNative')
ext.buildx86 = !project.hasProperty('skipx86')
task downloadCompiler(type: Download) {
src 'http://first.wpi.edu/FRC/roborio/toolchains/FRC-2017-Windows-Toolchain-4.9.3.zip'
dest buildDir
overwrite false
onlyIfNewer true
}
ext.compilerUnzipLocation = "${buildDir}/compiler"
task unzipCompiler(type: Copy) {
dependsOn downloadCompiler
from zipTree("${buildDir}/FRC-2017-Windows-Toolchain-4.9.3.zip")
into compilerUnzipLocation
}
if (new File(compilerUnzipLocation).exists()) {
ext.toolChainPath = "${compilerUnzipLocation}/frc/bin"
}
if (hasProperty('makeDesktop')) {
println 'Making desktop classifier jar. NOTE: This desktop version should only be used for local testing.' +
'It will only support the current platform, and will override fetching the latest development version from' +
' the maven repo until you manually delete it!'
}
ext.getPlatformPath2 = { targetPlatform ->
if (targetPlatform.architecture.arm) {
return 'Linux/arm'
} else if (targetPlatform.operatingSystem.linux) {
if (targetPlatform.architecture.amd64) {
return 'Linux/amd64'
} else {
return 'Linux/' + targetPlatform.architecture.name
}
} else if (targetPlatform.operatingSystem.windows) {
if (targetPlatform.architecture.amd64) {
return 'Windows/amd64'
} else {
return 'Windows/' + targetPlatform.architecture.name
}
} else if (targetPlatform.operatingSystem.macOsX) {
if (targetPlatform.architecture.amd64) {
return 'Mac OS X/x86_64'
} else {
return 'Mac OS X/' + targetPlatform.architecture.name
}
} else {
return targetPlatform.operatingSystem.name + '/' + targetPlatform.architecture.name
}
}
ext.getPlatformPath = { binary ->
return getPlatformPath2(binary.targetPlatform)
}
apply from: "locations.gradle"
apply from: "properties.gradle"
apply from: "dependencies.gradle"
ext.setupDefines = { project, binaries ->
binaries.all {
if (project.hasProperty('debug')) {
project.setupDebugDefines(cppCompiler, linker)
} else {
project.setupReleaseDefines(cppCompiler, linker)
}
tasks.withType(CppCompile) {
if (!project.hasProperty('compilerPrefix') && targetPlatform.architecture.name == 'arm-v7') {
// RoboRio, Link Nothing
} else {
// Everything else, link cscore and wpiutil
project.addWpiUtilStaticLibraryLinks(it, linker, targetPlatform)
// CsCore not currently supported
project.addCsCoreStaticLibraryLinks(it, linker, targetPlatform)
}
project.addOpenCvLibraryLinks(it, linker, targetPlatform)
}
}
}
apply from: "cpp.gradle"
// Empty task for build so that zips will be
// built when running ./gradlew build
task build
task clean(type: Delete) {
description = "Deletes the build directory"
group = "Build"
delete buildDir
}
def outputDir = file("${rootDir}/output")
task copyOutputs(type: Copy) {
destinationDir = outputDir
def ntv = project(":native")
dependsOn ntv.opencvZip
def arm = project(":arm")
if (buildArm) {
dependsOn arm.opencvZip
}
from (ntv.opencvZip.outputs) {}
if (buildArm) {
from (arm.opencvZip.outputs) {}
}
if (project.hasProperty("copywpilibs")) {
dependsOn ntv.depsZip
from (ntv.depsZip.outputs) {
into project.getWpiLibDeps(ntv)
}
if (buildArm) {
dependsOn arm.depsZip
from (arm.depsZip.outputs) {
into project.getWpiLibDeps(arm)
}
}
}
}
task copyToNet(type: Copy) {
destinationDir = file("${rootDir}/src/FRC.OpenCvSharp.DesktopLibraries/Libraries")
project(':native').model {
binaries {
withType(SharedLibraryBinarySpec) { binary ->
from(binary.sharedLibraryFile) {
if (targetPlatform.architecture.amd64) {
into 'amd64'
} else {
into targetPlatform.architecture.name
}
}
}
}
}
}
project(':native').tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("sharedlibrary") || name.contains("staticlibrary")) {
copyToNet.dependsOn task
}
}
build.dependsOn copyOutputs
clean {
delete outputDir
}
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
}