build_deps.py 3.93 KB
Newer Older
kladkogex's avatar
kladkogex committed
1
#!/usr/bin/env python
2

3
# ------------------------------------------------------------------------------
4
#    Copyright (C) 2018-Present SKALE Labs
5
#
6
#    This file is part of sgxwallet.
7
#
8 9 10 11
#   libBLS is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published
#   by the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
12
#
13 14 15 16
#   sgxwallet 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 Affero General Public License for more details.
17
#
18 19
#   You should have received a copy of the GNU Affero General Public License
#   along with sgxwallet.  If not, see <https://www.gnu.org/licenses/>.
20
#
21
#    @file  build_deps.py
22 23 24 25 26 27 28
#    @author Stan Kladko
#    @date 2018
#

import sys
import os
import subprocess
29 30
os.chdir("..")
topDir = os.getcwd()
31
print("Starting build")
32
print("Top directory is:" + topDir)
33
makeExecutable = subprocess.check_output(["which", "make"])
34 35
SCRIPTS_DIR = topDir + "/scripts"
GMP_DIR = topDir + "/sgx-gmp"
36
SGX_SDK_DIR_SSL = topDir + "/sgx-sdk-build/sgxsdk"
kladko's avatar
kladko committed
37
ZMQ_DIR = topDir + "/libzmq"
kladko's avatar
kladko committed
38
ZMQ_BUILD_DIR = ZMQ_DIR + "/build"
kladko's avatar
kladko committed
39 40 41
CZMQ_DIR = topDir + "/cppzmq"
CZMQ_BUILD_DIR = CZMQ_DIR + "/build"

42 43
LEVELDB_DIR = topDir + "/leveldb"
LEVELDB_BUILD_DIR = LEVELDB_DIR + "/build"
44 45
GMP_BUILD_DIR = topDir + "/gmp-build"
TGMP_BUILD_DIR = topDir + "/tgmp-build"
46
SDK_DIR = topDir + "/sgx-sdk-build"
kladko's avatar
kladko committed
47

48
JSON_LIBS_DIR = topDir +  "/jsonrpc"
49

kladko's avatar
kladko committed
50 51 52
BLS_DIR = topDir +  "/libBLS"
BLS_BUILD_DIR = BLS_DIR + "/build"

kladko's avatar
kladko committed
53 54
print("Cleaning")

55 56 57 58 59 60 61
subprocess.call(["rm", "-f",  "install-sh"])
subprocess.call(["rm", "-f",  "compile"])
subprocess.call(["rm", "-f",  "missing"])
subprocess.call(["rm", "-f",  "depcomp"])
subprocess.call(["rm", "-rf",  GMP_BUILD_DIR])
subprocess.call(["rm", "-rf", TGMP_BUILD_DIR])
subprocess.call(["rm", "-rf", SDK_DIR])
62

63 64 65
subprocess.call(["rm", "-rf",  GMP_BUILD_DIR])
subprocess.call(["rm", "-rf", TGMP_BUILD_DIR])
subprocess.call(["rm", "-rf", SDK_DIR])
66

kladko's avatar
kladko committed
67

kladko's avatar
kladko committed
68 69 70 71 72





kladkogex's avatar
kladkogex committed
73
assert subprocess.call(["cp", "configure.gmp", GMP_DIR + "/configure"]) == 0
kladko's avatar
kladko committed
74

kladko's avatar
kladko committed
75 76 77 78 79 80 81 82 83 84

print("Build LibBLS");
os.chdir(BLS_DIR + "/deps")
assert subprocess.call(["bash", "-c", "./build.sh"]) == 0
os.chdir(BLS_DIR)
assert subprocess.call(["bash", "-c", "cmake -H. -Bbuild"]) == 0
os.chdir(BLS_DIR + "/build")
assert subprocess.call(["bash", "-c", "make"]) == 0


kladko's avatar
kladko committed
85 86 87 88
print("Build ZMQ");

os.chdir(ZMQ_DIR)
assert subprocess.call(["bash", "-c", "mkdir -p build"]) == 0
kladko's avatar
kladko committed
89
os.chdir(ZMQ_BUILD_DIR)
kladko's avatar
kladko committed
90
assert subprocess.call(["bash", "-c", "cmake -DDZMQ_EXPERIMENTAL=1 -DCMAKE_BUILD_TYPE=Release .. && cmake --build ."]) == 0
kladko's avatar
kladko committed
91

kladko's avatar
kladko committed
92

kladko's avatar
kladko committed
93 94
print("Build LevelDB");

95 96 97 98 99
os.chdir(LEVELDB_DIR)
assert subprocess.call(["bash", "-c", "mkdir -p build"]) == 0
os.chdir(LEVELDB_BUILD_DIR)
assert subprocess.call(["bash", "-c", "cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build ."]) == 0

kladko's avatar
kladko committed
100
print("Build JSON"); 
kladkogex's avatar
kladkogex committed
101

102 103 104
os.chdir(JSON_LIBS_DIR)
assert subprocess.call(["bash", "-c", "./build.sh"]) == 0

kladko's avatar
kladko committed
105 106
print("Install Linux SDK");

kladkogex's avatar
kladkogex committed
107
os.chdir(SCRIPTS_DIR)
108
assert subprocess.call(["bash", "-c", "./sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=" + topDir + "/sgx-sdk-build"]) == 0
kladkogex's avatar
kladkogex committed
109

kladko's avatar
kladko committed
110 111
print("Make GMP");

112 113
os.chdir(GMP_DIR)
assert subprocess.call(["bash", "-c", "./configure --prefix=" + TGMP_BUILD_DIR + " --disable-shared --enable-static --with-pic --enable-sgx  --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0
114

kladkogex's avatar
kladkogex committed
115 116
assert subprocess.call(["make", "install"]) == 0
assert subprocess.call(["make", "clean"]) == 0
117

118
assert subprocess.call(["bash", "-c", "./configure --prefix=" + GMP_BUILD_DIR + " --disable-shared --enable-static --with-pic --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0
119

kladkogex's avatar
kladkogex committed
120 121
assert subprocess.call(["make", "install"]) == 0
assert subprocess.call(["make", "clean"]) == 0
122 123

os.chdir(topDir)
kladko's avatar
kladko committed
124
assert subprocess.call(["cp", "third_party/gmp/sgx_tgmp.h.fixed", TGMP_BUILD_DIR + "/include/sgx_tgmp.h"]) ==  0  
125

kladkogex's avatar
kladkogex committed
126
os.chdir(topDir)
127
print("Build successfull.")