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:
|
|
|
|
#
|
2020-11-18 14:20:34 +00:00
|
|
|
# https://docs.soliditylang.org
|
2016-08-01 05:25:37 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# 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
|
|
|
|
|
2021-11-09 17:07:15 +00:00
|
|
|
apt-get update && apt-get install lz4
|
|
|
|
|
2017-09-14 21:13:37 +00:00
|
|
|
WORKSPACE=/root/project
|
2016-08-01 05:25:37 +00:00
|
|
|
|
|
|
|
cd $WORKSPACE
|
2020-10-19 15:54:20 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2166
|
|
|
|
if [[ "$CIRCLE_BRANCH" = release || -n "$CIRCLE_TAG" || -n "$FORCE_RELEASE" || "$(git tag --points-at HEAD 2>/dev/null)" == v* ]]
|
|
|
|
then
|
2021-01-14 18:58:58 +00:00
|
|
|
echo -n >prerelease.txt
|
|
|
|
else
|
|
|
|
# Use last commit date rather than build date to avoid ending up with builds for
|
|
|
|
# different platforms having different version strings (and therefore producing different bytecode)
|
|
|
|
# if the CI is triggered just before midnight.
|
|
|
|
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="ci.%cd" >prerelease.txt
|
2020-10-19 15:54:20 +00:00
|
|
|
fi
|
|
|
|
if [ -n "$CIRCLE_SHA1" ]
|
|
|
|
then
|
2021-01-14 18:58:58 +00:00
|
|
|
echo -n "$CIRCLE_SHA1" >commit_hash.txt
|
2020-10-19 15:54:20 +00:00
|
|
|
fi
|
|
|
|
|
2020-12-11 17:19:53 +00:00
|
|
|
mkdir -p "$BUILD_DIR"
|
|
|
|
cd "$BUILD_DIR"
|
2021-01-13 00:09:34 +00:00
|
|
|
emcmake cmake \
|
2020-12-11 17:15:16 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DBoost_USE_STATIC_LIBS=1 \
|
|
|
|
-DBoost_USE_STATIC_RUNTIME=1 \
|
|
|
|
-DTESTS=0 \
|
2016-08-01 05:25:37 +00:00
|
|
|
..
|
2020-07-15 10:10:56 +00:00
|
|
|
make soljson
|
2016-08-01 05:25:37 +00:00
|
|
|
|
|
|
|
cd ..
|
2017-03-16 17:36:48 +00:00
|
|
|
mkdir -p upload
|
2021-11-09 17:07:15 +00:00
|
|
|
scripts/ci/pack_soljson.sh "$BUILD_DIR/libsolc/soljson.js" "$BUILD_DIR/libsolc/soljson.wasm" upload/soljson.js
|
|
|
|
cp upload/soljson.js ./
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2020-12-11 17:47:51 +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"
|