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
|
|
|
|
|
|
|
# Boost
|
|
|
|
echo -en 'travis_fold:start:compiling_boost\\r'
|
2019-06-06 17:20:31 +00:00
|
|
|
test -e "$WORKSPACE"/boost_1_70_0_install/include/boost/version.hpp || (
|
2019-06-06 15:19:18 +00:00
|
|
|
cd "$WORKSPACE"/boost_1_70_0
|
2018-07-11 15:15:03 +00:00
|
|
|
./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \
|
2019-10-16 00:31:41 +00:00
|
|
|
--with-system --with-filesystem --with-test --with-program_options cxxflags="-Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \
|
2019-06-06 15:19:18 +00:00
|
|
|
--prefix="$WORKSPACE"/boost_1_70_0_install install
|
2016-08-01 05:25:37 +00:00
|
|
|
)
|
2019-11-28 12:36:25 +00:00
|
|
|
ln -sf "$WORKSPACE"/boost_1_70_0_install/lib/* /emsdk_portable/emscripten/sdk/system/lib
|
|
|
|
ln -sf "$WORKSPACE"/boost_1_70_0_install/include/* /emsdk_portable/emscripten/sdk/system/include
|
2016-08-01 05:25:37 +00:00
|
|
|
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_USE_STATIC_LIBS=1 \
|
|
|
|
-DBoost_USE_STATIC_RUNTIME=1 \
|
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-02-25 13:58:54 +00:00
|
|
|
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'
|