-
Notifications
You must be signed in to change notification settings - Fork 78
/
build.gradle
149 lines (121 loc) · 4.51 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
plugins {
id 'edu.wpi.first.Toolchain' version '2019.1.1-beta-3-pre4' apply false
}
import edu.wpi.first.toolchain.NativePlatforms
allprojects {
apply plugin: 'idea'
apply plugin: 'maven-publish'
group = 'jaci.pathfinder'
version = '2019.3.06-UNSTABLE'
publishing {
repositories {
maven {
name = "distLocal"
url = "${rootProject.buildDir}/mvnDistRepo"
}
publications.all {
groupId project.group
}
}
}
}
subprojects {
plugins.withType(CPlugin).whenPluginAdded {
project.apply plugin: 'visual-studio'
project.apply plugin: 'edu.wpi.first.Toolchain'
toolchainsPlugin.withRaspbian()
toolchainsPlugin.withRoboRIO()
toolchainsPlugin.getByName('roboRio').optional = true
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'
}
}
}
components {
withType(TargetedNativeComponent) {
targetPlatform NativePlatforms.desktop
targetPlatform NativePlatforms.raspbian
targetPlatform NativePlatforms.roborio
if (is64)
targetPlatform ext.desktop32Classifier
}
}
}
}
plugins.withType(CppPlugin).whenPluginAdded {
project.apply plugin: 'visual-studio'
project.apply plugin: 'edu.wpi.first.Toolchain'
toolchainsPlugin.withRaspbian()
toolchainsPlugin.withRoboRIO()
toolchainsPlugin.getByName('roboRio').optional = true
project.model {
components {
withType(TargetedNativeComponent) {
targetPlatform NativePlatforms.desktop
targetPlatform NativePlatforms.raspbian
targetPlatform NativePlatforms.roborio
}
}
}
}
ext.binaryPublishers = [:]
ext.binaryArtifacts = { scope, name, jar ->
if (binaryPublishers[name] == null)
binaryPublishers[name] = []
binaryPublishers[name] << [scope: scope, jar: jar]
}
project.model {
binaries {
withType(NativeBinarySpec) {
def bin = it
if (it.buildable && !(it instanceof StaticLibraryBinary)) {
def shared = bin instanceof SharedLibraryBinary
def taskSuffix = "${component.name}${targetPlatform.name}${buildType.name}"
def source = (shared ? bin.sharedLibraryFile : bin.executable.file)
def ziptask = task "zip${taskSuffix}"(type: Zip) {
def allsrc = [source]
if (shared && bin.targetPlatform.operatingSystem.isWindows()) {
allsrc << bin.sharedLibraryLinkFile
}
from(allsrc as Set<File>)
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) {
binaryPublishers[bin.component.name].each { entry ->
entry.scope.artifact(entry.jar ? jartask : ziptask) {
classifier targetPlatform.name + (buildType.name == 'debug' ? 'debug' : '')
}
}
}
}
}
}
}
}
apply from: 'vendordeps.gradle'
task cleanMaven(type: Delete) {
delete "$buildDir/mvnDistRepo"
}
wrapper {
gradleVersion = '5.0'
}