forked from LF-Decentralized-Trust-labs/paladin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
249 lines (201 loc) · 5.68 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
def libraries = [
'core/go/build/libs',
'core/java/build/libs',
'toolkit/go/build/libs'
]
def domains = [
'domains/noto/build/libs',
'domains/pente/build/libs',
'domains/zeto/build/libs'
]
def registries = [
'registries/static/build/libs',
'registries/evm/build/libs',
]
def transports = [
'transports/grpc/build/libs',
]
def uiClient = [
'ui/client/dist',
]
def assembleSubprojects = [
':core:go',
':core:java',
':toolkit:go',
':domains:pente',
':domains:noto',
':domains:zeto',
':registries:static',
':registries:evm',
':transports:grpc',
':ui:client',
]
ext {
helpers = [
lockResource: { task, lockFile ->
// If two tasks share an output file, they will not be able to run concurrently.
// This helper creates an empty "lock" file in the root build directory, which allows
// tasks to use it as a representation of some shared resource.
def f = new File(task.project.rootProject.buildDir, lockFile)
task.outputs.file(f)
task.doLast { f.createNewFile() }
},
dumpLogsOnFailure: { task, dockerTaskPath ->
// If invoked with -PcomposeLogs=true and the given Exec task fails, look up the
// DockerCompose task specified, and ask it to dump logs.
task.ignoreExitValue(true)
task.doLast {
def execResult = getExecutionResult().get()
def composeLogs = project.findProperty('composeLogs')
if (execResult.exitValue != 0 && composeLogs == "true") {
def docker = project.tasks.getByPath(dockerTaskPath)
println "\nTask '${task.path}' failed. Dumping Docker logs from '${dockerTaskPath}'."
docker.dumpLogs()
}
execResult.assertNormalExitValue()
}
}
]
}
task jar {
enabled = false
}
task installProtocGenGo(type: GoInstall) {
tool = "google.golang.org/protobuf/cmd/protoc-gen-go"
toolVersion = "v1.34.2"
}
task installProtocGenGoRPC(type: GoInstall) {
tool = "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
toolVersion = "v1.5.1"
}
task installGolangCILint(type: GoInstall) {
tool = "github.com/golangci/golangci-lint/cmd/golangci-lint"
toolVersion = "v1.61.0"
}
task installMockery(type: GoInstall) {
tool = "github.com/vektra/mockery/v2"
toolVersion = "v2.46.0"
}
// Task to copy all executables and binaries to the root-level build/libs directory
task copyLibraries(type: Copy) {
def libsDir = file("${buildDir}/libs")
doFirst {
libsDir.mkdirs()
}
libraries.each { dir ->
from dir
}
into libsDir
outputs.upToDateWhen { false }
doLast {
println "Copied executables to ${libsDir}"
}
}
task copyDomains(type: Copy) {
def domainsDir = file("${buildDir}/domains")
doFirst {
domainsDir.mkdirs()
}
domains.each { dir ->
from dir
}
into domainsDir
outputs.upToDateWhen { false }
doLast {
println "Copied domains to ${domainsDir}"
}
}
task copyRegistries(type: Copy) {
def registriesDir = file("${buildDir}/registries")
doFirst {
registriesDir.mkdirs()
}
registries.each { dir ->
from dir
}
into registriesDir
outputs.upToDateWhen { false }
doLast {
println "Copied registries to ${registriesDir}"
}
}
task copyTransports(type: Copy) {
def transportsDir = file("${buildDir}/transports")
doFirst {
transportsDir.mkdirs()
}
transports.each { dir ->
from dir
}
into transportsDir
outputs.upToDateWhen { false }
doLast {
println "Copied transports to ${transportsDir}"
}
}
task copyUIFiles(type: Copy) {
def uiDir = file("${buildDir}/ui")
doFirst {
uiDir.mkdirs()
}
uiClient.each { dir ->
from dir
}
into uiDir
outputs.upToDateWhen { false }
doLast {
println "Copied UI files to ${uiDir}"
}
}
task copyZetoZKPFiles(type: Copy) {
def zetoZkpDir = file("${buildDir}/domains/zeto/zkp")
doFirst {
zetoZkpDir.mkdirs()
}
// These can be very large binaries, so adding to this list in the base image should be done with care.
// Likely if the range of circuits grows, a separate docker tag will be required for builds
// of Paladin that have a wider range of pre-built circuits included.
from fileTree('domains/zeto/zkp') {
include 'anon.zkey'
include 'anon-vkey.json'
include 'anon_js/anon.wasm'
// anon_enc
include 'anon_enc.zkey'
include 'anon_enc-vkey.json'
include 'anon_enc_js/anon_enc.wasm'
// anon_nullifier
include 'anon_nullifier.zkey'
include 'anon_nullifier-vkey.json'
include 'anon_nullifier_js/anon_nullifier.wasm'
}
into zetoZkpDir
outputs.upToDateWhen { false }
doLast {
println "Copied zetoZkp files to ${zetoZkpDir}"
}
}
// Root assemble task that depends on subproject's assemble tasks
task assemble {
assembleSubprojects.each { projectPath ->
dependsOn "${projectPath}:assemble"
}
}
assemble.finalizedBy(copyLibraries, copyDomains, copyRegistries, copyTransports, copyUIFiles, copyZetoZKPFiles)
defaultTasks 'build'
// Clean task to clean all projects
task clean {
delete "${buildDir}"
}
task docker(type: Exec) {
executable 'docker'
args 'build'
args '-t', 'paladin:test'
args '.'
}
task dockerx(type: Exec) {
executable 'docker'
args 'buildx', 'build'
args '--platform', 'linux/amd64,linux/arm64'
args '-t', 'paladin:test'
args '.'
}