forked from build-trust/ockam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
116 lines (100 loc) · 2.65 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
plugins {
id 'network.ockam.gradle.host' version '1.0.0'
id 'network.ockam.gradle.builders' version '1.0.0'
}
task detectDockerProvider {
doLast {
def dockerDir = new File('.vagrant/machines/builder-debian/docker')
if (dockerDir.exists()) {
project.ext.useDockerProvider = true
} else {
project.ext.useDockerProvider = false
}
}
}
['build', 'test', 'clean'].each { t ->
task "${t}" {
group 'Ockam'
def implementationTasks = ['c', 'elixir', 'go', 'javascript', 'rust', 'swift'].stream().map { impl ->
tasks.create("${t}${impl.capitalize()}") {
group impl.capitalize()
dependsOn detectDockerProvider
doLast {
exec {
def useDockerProvider = project.ext.useDockerProvider
workingDir "implementations/${impl}"
commandLine '../../gradlew', '-q', "-PuseDockerProvider=${useDockerProvider}", "${t}"
}
}
}
}.toArray()
for (int i = 0; i < implementationTasks.length - 1; i++) {
implementationTasks.getAt(i + 1).mustRunAfter(implementationTasks.getAt(i))
}
dependsOn implementationTasks
}
}
task lint {
onlyIf { host.debianBuilder.enabled }
doLast {
builderExec 'debian', {
script '''
npx [email protected] check
'''
}
}
}
clean.doLast {
exec {
commandLine 'bash', '-c', """
vagrant global-status | grep builder- | awk '{ print \$1 }' | xargs -I {} vagrant destroy -f {}
"""
ignoreExitValue true
}
delete '.builder'
}
task setDockerProvider {
dependsOn detectDockerProvider
doLast {
if (!project.ext.useDockerProvider) {
def vboxDir = new File('.vagrant/machines/builder-debian/virtualbox/id')
if (vboxDir.exists()) {
throw new GradleException('Cannot build with Docker without removing VirtualBox builder first!')
}
project.ext.useDockerProvider = true
}
}
}
task buildDocker {
group 'Ockam'
description 'Build with Docker'
dependsOn setDockerProvider
dependsOn build
tasks.findByName('build').mustRunAfter 'setDockerProvider'
}
task debianBuilder {
group 'Build Setup'
description 'Build the builder-debian VirtualBox VM'
doLast {
exec {
commandLine 'bash', '-c', """
cd tools/builder/debian && \
./build
"""
}
}
}
task dockerBuilder {
group 'Build Setup'
description 'Build the builder-debian Docker image'
doLast {
exec {
commandLine 'bash', '-c', """
cd tools/builder/debian && \
DOCKER_BUILDKIT=1 docker build \
--build-arg public_key="\$(cat ~/.ssh/id_rsa.pub || echo '')" \
-t ockam-builder-debian-base:latest .
"""
}
}
}