forked from wpilibsuite/allwpilib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
171 lines (148 loc) · 5.76 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
evaluationDependsOn(':hal')
evaluationDependsOn(':ntcore')
evaluationDependsOn(':cscore')
evaluationDependsOn(':cameraserver')
ext {
baseId = 'wpilibj'
groupId = 'edu.wpi.first.wpilibj'
devMain = 'edu.wpi.first.wpilibj.DevMain'
}
apply from: "${rootDir}/shared/java/javacommon.gradle"
def wpilibVersionFileInput = file("src/generate/WPILibVersion.java.in")
def wpilibVersionFileOutput = file("$buildDir/generated/java/edu/wpi/first/wpilibj/util/WPILibVersion.java")
task generateJavaVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput
if (WPILibVersion.releaseType.toString().equalsIgnoreCase('official')) {
outputs.upToDateWhen { false }
}
// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new verison file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
println "Writing version ${WPILibVersion.version} to $wpilibVersionFileOutput"
if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', WPILibVersion.version)
wpilibVersionFileOutput.write(read)
}
}
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateJavaVersion.outputs.upToDateWhen { false }
}
}
sourceSets.main.java.srcDir "${buildDir}/generated/java/"
compileJava {
dependsOn generateJavaVersion
}
dependencies {
compile project(':hal')
compile project(':wpiutil')
compile project(':ntcore')
compile project(':cscore')
compile project(':cameraserver')
testCompile 'com.google.guava:guava:19.0'
devCompile project(':hal')
devCompile project(':wpiutil')
devCompile project(':ntcore')
devCompile project(':cscore')
devCompile project(':cameraserver')
devCompile sourceSets.main.output
}
apply plugin: 'cpp'
apply plugin: 'edu.wpi.first.NativeUtils'
apply plugin: ExtraTasks
apply from: "${rootDir}/shared/config.gradle"
project(':').libraryBuild.dependsOn build
ext {
sharedCvConfigs = [wpilibjDev: []]
staticCvConfigs = [:]
useJava = true
useCpp = true
}
ext {
chipObjectComponents = ['wpilibjDev']
netCommComponents = ['wpilibjDev']
useNiJava = true
}
apply from: "${rootDir}/shared/nilibraries.gradle"
apply from: "${rootDir}/shared/opencv.gradle"
model {
components {
wpilibjDev(NativeExecutableSpec) {
targetBuildTypes 'debug'
sources {
cpp {
source {
srcDirs 'src/dev/native/cpp'
include '**/*.cpp'
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
lib project: ':cscore', library: 'cscore', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared'
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
}
exportedHeaders {
srcDirs 'src/dev/native/include'
}
}
}
binaries.all {
project(':hal').addHalDependency(it, 'shared')
project(':hal').addHalJniDependency(it)
}
}
}
tasks {
def c = $.components
project.tasks.create('runCpp', Exec) {
group = 'WPILib'
description = "Run the wpilibjDev executable"
def found = false
def systemArch = getCurrentArch()
c.each {
//println it.name
if (it in NativeExecutableSpec && it.name == "wpilibjDev") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.architecture.name
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
test.dependsOn it.tasks.install
test.systemProperty 'java.library.path', filePath
test.environment 'LD_LIBRARY_PATH', filePath
test.workingDir filePath
run.dependsOn it.tasks.install
run.systemProperty 'java.library.path', filePath
run.environment 'LD_LIBRARY_PATH', filePath
run.workingDir filePath
found = true
}
}
}
}
}
}
}
}
def oldWpilibVersionFile = file('src/main/java/edu/wpi/first/wpilibj/util/WPILibVersion.java')
clean {
delete oldWpilibVersionFile
}
test {
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
}
}