-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
404 lines (328 loc) · 11.8 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/*
* Starcoder - a server to read/write data from/to the stars, written in Go.
* Copyright (C) 2018 InfoStellar, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import com.google.common.io.CharStreams
import com.google.common.io.LineProcessor
buildscript {
repositories {
jcenter()
mavenCentral()
gradlePluginPortal()
maven {
url 'http://dl.bintray.com/curioswitch/curiostack'
}
maven {
url 'http://palantir.bintray.com/releases'
}
mavenLocal()
}
dependencies {
classpath 'org.curioswitch.curiostack:gradle-curiostack-plugin:0.0.162.5'
}
}
apply plugin: 'org.curioswitch.gradle-curiostack-plugin'
apply plugin: 'org.curioswitch.gradle-golang-plugin'
apply plugin: 'org.curioswitch.gradle-grpc-api-plugin'
repositories {
jcenter()
mavenCentral()
}
conda {
gnuradio {
version = 'Miniconda2-4.4.10'
packages = [
'autoconf',
'automake',
'boost',
'cmake',
'gcc_linux-64',
'gfortran_linux-64',
'gxx_linux-64',
'git',
'gsl',
'libtool',
'llvm',
'make',
'numpy',
'pkg-config',
'protobuf',
'subprocess32',
'swig',
'wget',
'libpng',
]
pythonPackages = [
'cheetah',
'construct',
'google-auth',
'grpcio',
'grpcio-testing',
'lxml',
'mako',
'matplotlib',
'pybombs',
'requests',
'ruamel.yaml==0.15.51',
'stellarstation',
]
}
}
golang {
conda = 'gnuradio'
}
protobuf {
generateProtoTasks {
all().each { task ->
task.plugins {
gofast {
option 'plugins=grpc'
option 'paths=source_relative'
option 'Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types'
option 'Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types'
// Output into root directory for gogradle
outputSubDir = '../../../../../api'
}
}
}
}
plugins {
gofast {
path = project.file("${gopath}/bin/protoc-gen-gofast")
}
}
}
sourceSets {
main {
proto {
srcDir 'api'
}
}
}
task deleteGeneratedFiles(type: Delete) {
delete fileTree(project.projectDir) {
include '**/*.pb.go'
include '**/*.mock.go'
include '**/rice-box.go'
}
}
tasks.clean.dependsOn deleteGeneratedFiles
gcloud {
clusterBaseName = 'infostellar-starcoder'
cloudRegion = 'asia-northeast1'
}
// protobuf-gradle-plugin always apply Java plugin, but we don't need it.
tasks.compileJava.enabled = false
tasks.compileTestJava.enabled = false
license {
header file('LICENSE.header')
mapping {
proto = 'SLASHSTAR_STYLE'
}
}
ext.gnuradioRoot = toolManager.getToolDir('gnuradio')
def condaCommand(command) {
return """
. ${gnuradioRoot.resolve('etc/profile.d/conda.sh')} && \\
conda activate > /dev/null && \\
${command}
"""
}
task installProtocGoPlugin(type: org.curioswitch.gradle.golang.tasks.GoTask) {
args 'get', 'github.com/gogo/protobuf/[email protected]'
}
task installRice(type: org.curioswitch.gradle.golang.tasks.GoTask) {
args 'get', 'github.com/GeertJohan/go.rice/rice@c02ca9a983da5807ddf7d796784928f5be4afd09'
}
task useRice(type:Exec) {
dependsOn installRice
inputs.dir 'flowgraphs'
outputs.file 'cmd/rice-box.go'
workingDir project.file('cmd').toString()
commandLine project.file("${gopath}/bin/rice").toString(), 'embed-go'
}
afterEvaluate {
tasks.generateProto.dependsOn installProtocGoPlugin
tasks.withType(org.curioswitch.gradle.golang.tasks.GoTask).configureEach {task->
if (task.name.startsWith('goBuild') || task.name == 'goTest') {
task.dependsOn tasks.generateProto, useRice
task.execCustomizer {exec->
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
exec.environment 'CPLUS_INCLUDE_PATH', "${gnuradioRoot}/include"
}
}
}
}
task setupPrefix(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
onlyIf { !project.file("${gnuradioRoot}/lib/libgnuradio-blocks.so").exists() }
dependsOn 'toolsSetupGnuradio'
condaName 'gnuradio'
command """pybombs auto-config && \\
pybombs -y recipes add gr-starcoder ${project.file('gr-recipes')} && \\
pybombs -y recipes add-defaults && \\
pybombs -y -v prefix init ${gnuradioRoot} -a gnuradio -R gnuradio-nogui && \\
${gnuradioRoot}/lib/uhd/utils/uhd_images_downloader.py
"""
execCustomizer {exec->
// For some reason, cmake has trouble finding boost in certain situations.
exec.environment 'BOOST_ROOT', gnuradioRoot
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
if (System.getenv('CI')) {
def stdOutPipedInput = new PipedInputStream()
def stdOutPipedOutput = new PipedOutputStream(stdOutPipedInput)
def readerThread = Thread.startDaemon {
def standardLogPrefixes = ['Cloning', 'Configuring', 'Building', 'Installing']
def previousLogPrefix = ''
def reader = new BufferedReader(new InputStreamReader(stdOutPipedInput))
CharStreams.readLines(reader, new LineProcessor<Void>() {
@Override
boolean processLine(String line) throws IOException {
// Don't print empty lines
if (line.trim() == '') {
return true
}
// Don't spam with percentages.
if (line.contains("%")) {
return true
}
// Only print cmake logs once per type
for (logPrefix in standardLogPrefixes) {
if (line.startsWith(logPrefix)) {
if (previousLogPrefix == logPrefix) {
return true
}
previousLogPrefix = logPrefix
break
}
}
println line
return true
}
@Override
Void getResult() {
return null
}
})
}
exec.standardOutput = stdOutPipedOutput
}
}
doFirst {
// Trick cmake into thinking pygtk exists to allow normal grc installation. We don't actually
// use gtk so this shouldn't cause problems.
copy {
from project.file('mockpygtk')
into "${gnuradioRoot}/lib/python2.7/site-packages/gtk"
}
}
doLast {
delete "${gnuradioRoot}/src"
}
}
task compileGrStarcoder(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn setupPrefix
condaName 'gnuradio'
command """cmake ../../gr-starcoder -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=${gnuradioRoot} -Wno-dev && \\
make
"""
execCustomizer {exec->
exec.workingDir project.file('build/starcoder-cmake')
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
}
doFirst {
project.mkdir('build/starcoder-cmake')
}
}
task installGrStarcoder(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn compileGrStarcoder
condaName 'gnuradio'
command 'make install'
execCustomizer {exec->
exec.workingDir project.file('build/starcoder-cmake')
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
}
}
task testGrStarcoder(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn installGrStarcoder
condaName 'gnuradio'
command 'make test ARGS=-VV'
execCustomizer {exec->
exec.workingDir project.file('build/starcoder-cmake')
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
}
}
task compileGrStarcoderUtils(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn setupPrefix
condaName 'gnuradio'
command """cmake ../../gr-starcoder_utils -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=${gnuradioRoot} -Wno-dev && \\
make
"""
execCustomizer {exec->
exec.workingDir project.file('build/starcoder_utils-cmake')
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
}
doFirst {
project.mkdir('build/starcoder_utils-cmake')
}
}
task installGrStarcoderUtils(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn compileGrStarcoderUtils
condaName 'gnuradio'
command 'make install'
execCustomizer {exec->
exec.workingDir project.file('build/starcoder_utils-cmake')
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
}
}
task testGrStarcoderUtils(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn installGrStarcoderUtils
condaName 'gnuradio'
command 'make test ARGS=-VV'
execCustomizer {exec->
exec.workingDir project.file('build/starcoder_utils-cmake')
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
}
}
tasks.test.dependsOn testGrStarcoder
tasks.test.dependsOn testGrStarcoderUtils
task installGrStarcoderFromRecipe(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn setupPrefix
condaName 'gnuradio'
command 'pybombs -y install gr-starcoder'
execCustomizer {exec->
exec.environment 'PKG_CONFIG_PATH', "${gnuradioRoot}/lib/pkgconfig"
exec.environment 'PYBOMBS_PREFIX', gnuradioRoot
}
}
task installStarcoder(type: Copy) {
dependsOn build
from 'build/exe/current'
into "${gnuradioRoot}/bin"
}
task install {
dependsOn installGrStarcoder, installGrStarcoderUtils, installStarcoder
}
task clangFormat(type: org.curioswitch.gradle.conda.tasks.CondaExecTask) {
dependsOn 'toolsSetupGnuradio'
def ccFiles = fileTree('.').filter { it.isFile() && it.name.endsWith('.cc') }.files.path.join(' ')
def hIncFiles = fileTree('./gr-starcoder/include').filter { it.isFile() && it.name.endsWith('.h') }.files.path.join(' ')
def hLibFiles = fileTree('./gr-starcoder/lib').filter { it.isFile() && it.name.endsWith('.h') }.files.path.join(' ')
def hIncFilesUtil = fileTree('./gr-starcoder_utils/include').filter { it.isFile() && it.name.endsWith('.h') }.files.path.join(' ')
def hLibFilesUtil = fileTree('./gr-starcoder_utils/lib').filter { it.isFile() && it.name.endsWith('.h') }.files.path.join(' ')
condaName 'gnuradio'
command "clang-format -style=Google -i ${ccFiles} ${hIncFiles} ${hLibFiles} ${hIncFilesUtil} ${hLibFilesUtil}"
}