forked from R3Conclave/conclave-core-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
159 lines (143 loc) · 5.86 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
plugins {
id 'java-gradle-plugin'
id 'org.jetbrains.kotlin.jvm'
}
gradlePlugin {
plugins {
enclavePlugin {
id = 'com.r3.conclave.enclave'
implementationClass = 'com.r3.conclave.plugin.enclave.gradle.GradleEnclavePlugin'
}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect"
// We need conclave-common to get the hash implementations in order to be able to parse the enclave
// metadata file.
implementation project(":conclave-common")
implementation "com.github.jengelman.gradle.plugins:shadow:5.2.0"
implementation "io.github.classgraph:classgraph:$classgraph_version"
implementation "org.bouncycastle:bcpkix-jdk15on:$bouncycastle_version"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version"
implementation "org.apache.commons:commons-compress:$apache_commons_compress"
testImplementation "org.assertj:assertj-core:$assertj_version"
testImplementation "org.junit.jupiter:junit-jupiter:$junit_jupiter_version"
}
/**
* Generates the CAP cache by running native-image on the cap-cache subproject.
* The CAP cache is packaged in the graal jar file together with the tarball of the Graal distribution.
* Relevant native-image options:
* -H:±ExitAfterCAPCache Exit image generation after C Annotation Processor Cache creation. Default: - (disabled).
* -H:±NewCAPCache Create a C Annotation Processor Cache. Will erase any previous cache at that same location. Default: - (disabled).
* -H:CAPCacheDir Directory where information generated by the CAnnotation Processor are cached.
*/
task generateCAPCache(type: Exec) {
String capCacheDir = "${project.buildDir}/graalvm-cap-cache"
outputs.dir(capCacheDir)
doFirst {
commandLine "${System.getenv("GRAAL_HOME")}/bin/native-image", '--shared',
'-H:+ExitAfterCAPCache', '-H:+NewCAPCache', "-H:CAPCacheDir=$capCacheDir",
"--no-fallback",
"--language:js",
"--language:python",
"-H:Name=cap-cache"
}
}
// Bundle the various tools and components needed by the plugin to build enclaves
processResources {
// The ld executable in this case is produced by compileLinuxSgx<Debug|Release> depending on whether the flag
// -PnativeDebug is set or not. We do not always build ld with debug symbols because if the user sets
// -PnativeDebug, the build will depend on both the release and debug versions of linuxSgx, meaning the SDK will
// potentially be built twice.
String cmakeBuildType = project.hasProperty("nativeDebug") ? "Debug" : "Release"
dependsOn(":cpp:compileLinuxSgx$cmakeBuildType")
dependsOn(":cpp:compileFatFsEnclave$cmakeBuildType")
dependsOn(":cpp:compileSubstrateVMLib$cmakeBuildType")
dependsOn(":cpp:compileJvmEnclaveCommon$cmakeBuildType")
dependsOn(":cpp:compileJvmEdl$cmakeBuildType")
dependsOn("generateCAPCache")
dependsOn(":python-enclave-adapter:shadowJar")
def cppProject = project(":cpp")
String cppBuildDir = "${cppProject.buildDir}/$cmakeBuildType"
String linuxSgxBuildDir = "$cppBuildDir/linux-sgx/src/linux-sgx"
String sgxSdkBuildDir = "$cppBuildDir/linux-sgx/linux-sgx-ext-prefix/src/linux-sgx-ext-build/sgxsdk"
into("conclave-build") {
from("${rootProject.projectDir}/containers/conclave-build")
}
// C common headers
into("include") {
from("${cppProject.projectDir}/jvm-enclave-common/include/public") {
include "*.h"
}
}
// SGX tools
into("sgx-tools") {
from("$linuxSgxBuildDir/build/linux") {
include "sgx_sign"
}
from("$linuxSgxBuildDir/external/toolset/ubuntu20.04/ld") {
include "ld"
}
}
// linux-sgx libs
into("linux-sgx-libs/common") { // All enclave modes use these libs
from("$sgxSdkBuildDir/include") {
include "tlibc/**/*"
include "libcxx/**/*"
}
from("$sgxSdkBuildDir/lib64") {
include "libsgx_pthread.a"
include "libsgx_tcrypto.a"
include "libsgx_tcxx.a"
include "libsgx_tstdc.a"
}
}
into("linux-sgx-libs/hardware") { // Only release and debug modes use these libs
from("$sgxSdkBuildDir/lib64") {
include "libsgx_trts.a"
include "libsgx_tservice.a"
}
}
into("linux-sgx-libs/simulation") { // Only simulation mode uses these libs
from("$sgxSdkBuildDir/lib64") {
include "libsgx_trts_sim.a"
include "libsgx_tservice_sim.a"
}
}
// substratevm libs
into("substratevm-libs/common") { // All enclave modes use these libs
from("$cppBuildDir/substratevm") {
include "libsubstratevm.a"
}
from("$cppBuildDir/fatfs/enclave") {
include "libfatfs_enclave.a"
}
from("$cppBuildDir/jvm-edl") {
include "libjvm_enclave_edl.a"
}
from("$cppBuildDir/jvm-host-enclave-common") {
include "libjvm_host_enclave_common_enclave.a"
}
from ("$cppBuildDir/zlib/zlib-ext-prefix/src/zlib-ext-build") {
include "libz.a"
}
}
for (enclaveMode in ["release", "debug", "simulation"]) {
into("substratevm-libs/$enclaveMode") {
from("$cppBuildDir/jvm-enclave-common") {
include "libjvm_enclave_common_${enclaveMode}.a"
rename "libjvm_enclave_common_${enclaveMode}.a", "libjvm_enclave_common.a"
}
}
}
// GraalVM CAP cache
into("graalvm-cap-cache") {
from(generateCAPCache)
}
into("python-support") {
from(tasks.findByPath(":python-enclave-adapter:shadowJar")) {
rename { "enclave-adapter.jar" }
}
}
}