2016-08-01 05:25:37 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# This script builds the solidity binary using Emscripten.
|
|
|
|
# Emscripten is a way to compile C/C++ to JavaScript.
|
|
|
|
#
|
|
|
|
# http://kripken.github.io/emscripten-site/
|
|
|
|
#
|
|
|
|
# First run install_dep.sh OUTSIDE of docker and then
|
|
|
|
# run this script inside a docker image trzeci/emscripten
|
|
|
|
#
|
|
|
|
# The documentation for solidity is hosted at:
|
|
|
|
#
|
|
|
|
# http://solidity.readthedocs.io/
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# This file is part of solidity.
|
|
|
|
#
|
|
|
|
# solidity 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.
|
|
|
|
#
|
|
|
|
# solidity 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 solidity. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
#
|
|
|
|
# (c) 2016 solidity contributors.
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
set -ev
|
|
|
|
|
2019-02-25 13:58:54 +00:00
|
|
|
if test -z "$1"; then
|
|
|
|
BUILD_DIR="emscripten_build"
|
|
|
|
else
|
|
|
|
BUILD_DIR="$1"
|
|
|
|
fi
|
|
|
|
|
2017-09-14 21:13:37 +00:00
|
|
|
if ! type git &>/dev/null; then
|
|
|
|
# We need git for extracting the commit hash
|
|
|
|
apt-get update
|
|
|
|
apt-get -y install git-core
|
|
|
|
fi
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2018-02-27 18:06:33 +00:00
|
|
|
if ! type wget &>/dev/null; then
|
|
|
|
# We need wget to install cmake
|
|
|
|
apt-get update
|
|
|
|
apt-get -y install wget
|
|
|
|
fi
|
|
|
|
|
2017-09-14 21:13:37 +00:00
|
|
|
WORKSPACE=/root/project
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2018-02-07 19:27:16 +00:00
|
|
|
# Increase nodejs stack size
|
2018-07-11 15:15:03 +00:00
|
|
|
if ! [ -e /emsdk_portable/node/bin/node_orig ]
|
2018-02-08 13:59:17 +00:00
|
|
|
then
|
2018-07-11 15:15:03 +00:00
|
|
|
mv /emsdk_portable/node/bin/node /emsdk_portable/node/bin/node_orig
|
|
|
|
echo -e '#!/bin/sh\nexec /emsdk_portable/node/bin/node_orig --stack-size=8192 $@' > /emsdk_portable/node/bin/node
|
|
|
|
chmod 755 /emsdk_portable/node/bin/node
|
2018-02-08 13:59:17 +00:00
|
|
|
fi
|
2018-02-07 19:27:16 +00:00
|
|
|
|
2016-08-01 05:25:37 +00:00
|
|
|
# Boost
|
|
|
|
echo -en 'travis_fold:start:compiling_boost\\r'
|
2019-01-07 09:55:52 +00:00
|
|
|
cd "$WORKSPACE"/boost_1_68_0
|
2016-08-01 05:25:37 +00:00
|
|
|
# if b2 exists, it is a fresh checkout, otherwise it comes from the cache
|
|
|
|
# and is already compiled
|
|
|
|
test -e b2 && (
|
2018-07-11 15:15:03 +00:00
|
|
|
./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \
|
|
|
|
system regex filesystem unit_test_framework program_options cxxflags="-Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all"
|
2016-08-01 05:25:37 +00:00
|
|
|
find . -name 'libboost*.a' -exec cp {} . \;
|
|
|
|
rm -rf b2 libs doc tools more bin.v2 status
|
|
|
|
)
|
|
|
|
echo -en 'travis_fold:end:compiling_boost\\r'
|
|
|
|
|
2018-02-27 18:06:33 +00:00
|
|
|
echo -en 'travis_fold:start:install_cmake.sh\\r'
|
|
|
|
source $WORKSPACE/scripts/install_cmake.sh
|
|
|
|
echo -en 'travis_fold:end:install_cmake.sh\\r'
|
|
|
|
|
2016-08-01 05:25:37 +00:00
|
|
|
# Build dependent components and solidity itself
|
|
|
|
echo -en 'travis_fold:start:compiling_solidity\\r'
|
|
|
|
cd $WORKSPACE
|
2019-02-25 13:58:54 +00:00
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
cd $BUILD_DIR
|
2017-08-21 06:19:55 +00:00
|
|
|
cmake \
|
2017-08-28 15:04:41 +00:00
|
|
|
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/emscripten.cmake \
|
2016-08-01 05:25:37 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DBoost_FOUND=1 \
|
|
|
|
-DBoost_USE_STATIC_LIBS=1 \
|
|
|
|
-DBoost_USE_STATIC_RUNTIME=1 \
|
2019-01-07 09:55:52 +00:00
|
|
|
-DBoost_INCLUDE_DIR="$WORKSPACE"/boost_1_68_0/ \
|
|
|
|
-DBoost_FILESYSTEM_LIBRARY_RELEASE="$WORKSPACE"/boost_1_68_0/libboost_filesystem.a \
|
|
|
|
-DBoost_PROGRAM_OPTIONS_LIBRARY_RELEASE="$WORKSPACE"/boost_1_68_0/libboost_program_options.a \
|
|
|
|
-DBoost_REGEX_LIBRARY_RELEASE="$WORKSPACE"/boost_1_68_0/libboost_regex.a \
|
|
|
|
-DBoost_SYSTEM_LIBRARY_RELEASE="$WORKSPACE"/boost_1_68_0/libboost_system.a \
|
|
|
|
-DBoost_UNIT_TEST_FRAMEWORK_LIBRARY_RELEASE="$WORKSPACE"/boost_1_68_0/libboost_unit_test_framework.a \
|
2017-08-18 10:38:08 +00:00
|
|
|
-DTESTS=0 \
|
2016-08-01 05:25:37 +00:00
|
|
|
..
|
2017-08-18 10:38:08 +00:00
|
|
|
make -j 4
|
2016-08-01 05:25:37 +00:00
|
|
|
|
|
|
|
cd ..
|
2017-03-16 17:36:48 +00:00
|
|
|
mkdir -p upload
|
2019-01-21 14:30:29 +00:00
|
|
|
# Patch soljson.js to provide backwards-compatibility with older emscripten versions
|
2019-02-25 13:58:54 +00:00
|
|
|
echo ";/* backwards compatibility */ Module['Runtime'] = Module;" >> $BUILD_DIR/libsolc/soljson.js
|
|
|
|
cp $BUILD_DIR/libsolc/soljson.js upload/
|
|
|
|
cp $BUILD_DIR/libsolc/soljson.js ./
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2017-08-25 13:44:03 +00:00
|
|
|
OUTPUT_SIZE=`ls -la soljson.js`
|
2016-11-08 23:09:40 +00:00
|
|
|
|
2017-06-27 09:50:42 +00:00
|
|
|
echo "Emscripten output size: $OUTPUT_SIZE"
|
2016-11-08 23:09:40 +00:00
|
|
|
|
2016-08-01 05:25:37 +00:00
|
|
|
echo -en 'travis_fold:end:compiling_solidity\\r'
|