-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
207 lines (177 loc) · 7.08 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
plugins {
id 'com.gradle.build-scan' version '2.0.2'
id 'org.ysb33r.doxygen' version '0.5' apply false
id 'edu.wpi.first.Toolchain' version '2019.1.1-beta-3-pre4' apply false
}
import org.gradle.internal.os.OperatingSystem
import edu.wpi.first.toolchain.NativePlatforms
task subclean();
allprojects {
apply plugin: 'idea'
apply plugin: 'maven-publish'
project.group = "grpl.pathfinder"
project.version = "2.0.0-prealpha"
plugins.withType(CppPlugin).whenPluginAdded {
project.apply plugin: "visual-studio"
project.apply plugin: "org.ysb33r.doxygen"
project.apply plugin: 'edu.wpi.first.Toolchain'
toolchainsPlugin.withRaspbian()
toolchainsPlugin.withRoboRIO()
toolchainsPlugin.getByName('roboRio').optional = true
rootProject.tasks.subclean.dependsOn tasks.clean
ext.is64 = NativePlatforms.desktopArch() == "x86-64"
ext.desktop32Classifier = NativePlatforms.desktopOS() + "x86"
project.model {
buildTypes {
release
debug
}
platforms {
// If we're on x86 64-bit, also compile for x86 32-bit
if (is64) {
"${desktop32Classifier}" {
architecture 'x86'
}
}
}
toolChains {
def ci = System.getenv("CI_COMPILER")
if (ci != null) {
if (ci == "GCC")
gcc(Gcc)
else if (ci == "MSVC")
msvc(VisualCpp)
else if (ci == "CLANG")
clang(Clang)
else if (ci == "ROBORIO")
roborio(edu.wpi.first.toolchain.roborio.RoboRioGcc)
else if (ci == "RASPBIAN")
raspbian(edu.wpi.first.toolchain.raspbian.RaspbianGcc)
} else {
msvc(VisualCpp)
// Define Clang first - for ASAN (Default)
clang(Clang)
gcc(Gcc)
roborio(edu.wpi.first.toolchain.roborio.RoboRioGcc)
raspbian(edu.wpi.first.toolchain.raspbian.RaspbianGcc)
}
}
components {
withType(TargetedNativeComponent) {
targetPlatform NativePlatforms.desktop
targetPlatform NativePlatforms.raspbian
targetPlatform NativePlatforms.roborio
if (is64)
targetPlatform ext.desktop32Classifier
}
}
binaries {
withType(NativeBinarySpec) {
if (toolChain instanceof GccCompatibleToolChain) {
cppCompiler.args << '-std=c++14' << '-O2' << '-Werror'
if (buildType == buildTypes.debug) {
cppCompiler.args "-g"
}
} else {
// MSVC
cppCompiler.args << '/std:c++14' << '/O2'
if (buildType == buildTypes.debug) {
cppCompiler.args << '/Zi' << '/FS'
cppCompiler.define 'DEBUG'
linker.args '/DEBUG'
}
}
}
}
}
// ext.binaryDists = []
// ext.binaryArtifacts = { scope, name, jar ->
// binaryDists.each { z ->
// if (z.binary.component.name == name) {
// scope.artifact(jar ? z.jartask : z.ziptask) {
// classifier z.binary.targetPlatform.name
// }
// }
// }
// }
ext.binaryPublishers = [:]
ext.binaryArtifacts = { scope, name, jar ->
binaryPublishers[name] = [scope: scope, jar: jar]
}
project.model {
binaries {
withType(NativeBinarySpec) {
def bin = it
if (buildType.name == "release" && !(it instanceof StaticLibraryBinary) && it.buildable) {
def taskSuffix = "${component.name}${targetPlatform.name}"
def source = (bin instanceof SharedLibraryBinary ? bin.sharedLibraryFile : bin.executable.file)
def ziptask = task "zip${taskSuffix}"(type: Zip) {
from(source)
into(targetPlatform.name)
baseName = component.name
classifier = targetPlatform.name
dependsOn bin.tasks.withType(AbstractLinkTask)
}
def jartask = task "jar${taskSuffix}"(type: Jar) {
from(source)
into(targetPlatform.name)
baseName = component.name
classifier = targetPlatform.name
dependsOn bin.tasks.withType(AbstractLinkTask)
}
if (binaryPublishers[bin.component.name] != null) {
def entry = binaryPublishers[bin.component.name]
entry.scope.artifact(entry.jar ? jartask : ziptask) {
classifier targetPlatform.name
}
}
// println "Bin: ${bin}"
// binaryDists << [ binary: bin, jartask: jartask, ziptask: ziptask ]
}
}
}
}
}
plugins.withType(GoogleTestPlugin).whenPluginAdded {
model {
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
lib project: ":libs", library: "googleTest", linkage: "static"
boolean applies = false
if (targetPlatform.name == edu.wpi.first.toolchain.NativePlatforms.desktop)
applies = true
if (ext.is64 && targetPlatform.name == ext.desktop32Classifier)
applies = true
if (!applies) {
tasks.withType(RunTestExecutable) { RunTestExecutable task ->
task.enabled = false
}
}
}
}
}
}
publishing {
repositories {
maven {
name = "distLocal"
url = "${rootProject.buildDir}/mvnDistRepo"
}
}
publications.all {
groupId 'grpl.pathfinder'
}
}
}
apply from: 'vendordeps.gradle'
task cleanMaven(type: Delete) {
delete "$buildDir/mvnDistRepo"
}
task clean(dependsOn: cleanMaven)
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service';
termsOfServiceAgree = 'yes'
}
wrapper {
gradleVersion = '5.0'
}