build.py 5.07 KB
Newer Older
kladkogex's avatar
kladkogex committed
1
#!/usr/bin/env python
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

#------------------------------------------------------------------------------
# Bash script to build cpp-ethereum within TravisCI.
#
# The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
#
# ------------------------------------------------------------------------------
# This file is part of cpp-ethereum.
#
# cpp-ethereum 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.
#
# cpp-ethereum 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 cpp-ethereum.  If not, see <http://www.gnu.org/licenses/>
#
# (c) 2016 cpp-ethereum contributors.
#------------------------------------------------------------------------------
#
#    Copyright (C) 2018-2019 SKALE Labs
#
#    This file is part of skale-consensus.
#
#    skale-consensus 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, eithe    r version 3 of the License, or
#    (at your option) any later version.
#
#    skale-consensus 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 skale-consensus.  If not, see <http://www.gnu.org/licenses/>.
#
#    @file  build.py
#    @author Stan Kladko
#    @date 2018
#

import sys
import os
import subprocess

kladkogex's avatar
kladkogex committed
53
os.chdir("..");
54 55 56 57 58 59 60 61 62

topDir = os.getcwd();

print("Starting build")

print("Top directory is:" + topDir )

makeExecutable = subprocess.check_output(["which", "make"])

kladkogex's avatar
kladkogex committed
63 64
SCRIPTS_DIR = topDir + "/scripts" 
GMP_DIR = topDir +  "/sgx-gmp"
65 66 67 68
SSL_DIR =  topDir + "/intel-sgx-ssl"
SSL_SOURCE_DIR = SSL_DIR + "/openssl_source"
SSL_MAKE_DIR = SSL_DIR + "/Linux"
SGX_SDK_DIR_SSL = topDir + "/sgx-sdk-build/sgxsdk"
69 70 71
LEVELDB_DIR = topDir + "/leveldb"

LEVELDB_BUILD_DIR = LEVELDB_DIR + "/build"
72 73 74



75 76
GMP_BUILD_DIR = topDir + "/gmp-build"
TGMP_BUILD_DIR = topDir + "/tgmp-build"
77
SDK_DIR = topDir + "/sgx-sdk-build"
78

79 80 81 82 83

BLS_DIR = topDir +  "/libBLS"
BLS_BUILD_DIR = BLS_DIR + "/build"


84
AUTOMAKE_DIR = "/usr/share/automake-1.15"
85

86
if not os.path.isdir(AUTOMAKE_DIR):
87
    raise Exception("Could not find " + AUTOMAKE_DIR)
88 89 90 91




92
subprocess.call(["git", "submodule",  "update", "--init"])
93

94 95 96 97
subprocess.call(["rm", "-f",  "install-sh"])
subprocess.call(["rm", "-f",  "compile"])
subprocess.call(["rm", "-f",  "missing"])
subprocess.call(["rm", "-f",  "depcomp"])
98

99 100 101
subprocess.call(["rm", "-rf",  GMP_BUILD_DIR])
subprocess.call(["rm", "-rf", TGMP_BUILD_DIR])
subprocess.call(["rm", "-rf", SDK_DIR])
102

103 104


105 106 107 108 109
subprocess.call(["ln", "-s", AUTOMAKE_DIR + "/install-sh", "install-sh"])
subprocess.call(["ln", "-s", AUTOMAKE_DIR + "/depcomp", "depcomp"])
subprocess.call(["ln", "-s", AUTOMAKE_DIR + "/missing", "missing"])
subprocess.call(["ln", "-s", AUTOMAKE_DIR + "/compile", "compile"])

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

112 113 114 115 116 117 118 119
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


120 121 122 123 124 125
os.chdir(BLS_DIR);

assert subprocess.call(["bash","-c", "cmake -H. -Bbuild"]) == 0

os.chdir(BLS_BUILD_DIR);

kladkogex's avatar
kladkogex committed
126
assert subprocess.call(["bash","-c", "make -j8"]) == 0
127

kladkogex's avatar
kladkogex committed
128

kladkogex's avatar
kladkogex committed
129 130 131 132
os.chdir(SCRIPTS_DIR)


assert subprocess.call(["bash","-c", "./sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=" + topDir + "/sgx-sdk-build"]) == 0 
133

134

kladkogex's avatar
kladkogex committed
135
os.chdir(GMP_DIR);
136 137


kladkogex's avatar
kladkogex committed
138
assert subprocess.call(["bash", "-c", "./configure --prefix=" + TGMP_BUILD_DIR + " --disable-shared " +
kladkogex's avatar
kladkogex committed
139
                        " --enable-static --with-pic --enable-sgx  --with-sgxsdk=" + SDK_DIR + "/sgxsdk" ]) == 0
140 141


kladkogex's avatar
kladkogex committed
142 143
assert subprocess.call(["make", "install"]) == 0
assert subprocess.call(["make", "clean"]) == 0
144 145


kladkogex's avatar
kladkogex committed
146 147 148 149
assert subprocess.call(["bash", "-c", "./configure --prefix=" + GMP_BUILD_DIR + " --disable-shared " +
                        " --enable-static  --with-pic --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0
assert subprocess.call(["make", "install"]) == 0
assert subprocess.call(["make", "clean"]) == 0
150 151 152

os.chdir(topDir)

kladkogex's avatar
kladkogex committed
153
assert subprocess.call(["cp", "sgx_tgmp.h", TGMP_BUILD_DIR + "/include/sgx_tgmp.h"]) == 0
154

kladkogex's avatar
kladkogex committed
155
os.chdir(SSL_DIR);
156

157

kladkogex's avatar
kladkogex committed
158
print "===>>> Downloading vanilla openssl source package"
159

kladkogex's avatar
kladkogex committed
160
os.chdir(SSL_SOURCE_DIR);
161 162


kladkogex's avatar
kladkogex committed
163
assert subprocess.call(["wget", "https://www.openssl.org/source/openssl-1.1.1b.tar.gz"]) == 0
164

kladkogex's avatar
kladkogex committed
165
print "===>>> Making SSL  project"
166

kladkogex's avatar
kladkogex committed
167
os.chdir(SSL_MAKE_DIR);
168

kladkogex's avatar
kladkogex committed
169
assert subprocess.call(["make",  "-j8", "SGX_SDK=" + SGX_SDK_DIR_SSL, "all",  "test"]) == 0
170

kladkogex's avatar
kladkogex committed
171
os.chdir(topDir)
172

173

174

175 176 177 178
print("Build successfull.")