2017-03-22 19:19:57 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
2022-02-10 15:17:51 +00:00
|
|
|
# Script used for cross-platform comparison of the bytecode generated by the compiler.
|
|
|
|
# Splits all test source code into multiple files, generates bytecode and metadata
|
|
|
|
# for each file and combines it into a single report.txt file.
|
|
|
|
#
|
|
|
|
# The script is meant to be executed in CI on all supported platforms. All generated
|
|
|
|
# reports must be identical for a given compiler version.
|
2017-03-22 19:19:57 +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) 2017 solidity contributors.
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
REPO_ROOT="$(dirname "$0")"/../..
|
2020-11-20 13:56:12 +00:00
|
|
|
cd "$REPO_ROOT"
|
|
|
|
REPO_ROOT=$(pwd) # make it absolute
|
2017-03-22 19:19:57 +00:00
|
|
|
|
2020-11-20 13:56:12 +00:00
|
|
|
BUILD_DIR="${1:-${REPO_ROOT}/build}"
|
2019-02-25 13:58:54 +00:00
|
|
|
|
2017-03-22 19:19:57 +00:00
|
|
|
echo "Compiling all test contracts into bytecode..."
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
(
|
|
|
|
cd "$TMPDIR"
|
|
|
|
|
|
|
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
|
|
|
|
|
|
|
|
if [[ "$SOLC_EMSCRIPTEN" = "On" ]]
|
|
|
|
then
|
2022-01-25 16:12:35 +00:00
|
|
|
echo "Installing solc-js..."
|
2018-10-31 12:39:32 +00:00
|
|
|
# npm install solc
|
2018-11-06 14:14:44 +00:00
|
|
|
git clone --depth 1 https://github.com/ethereum/solc-js.git solc-js
|
2019-02-25 13:58:54 +00:00
|
|
|
cp "$REPO_ROOT/emscripten_build/libsolc/soljson.js" solc-js/
|
2022-01-25 16:12:35 +00:00
|
|
|
pushd solc-js/
|
|
|
|
npm install
|
|
|
|
npm run build
|
|
|
|
popd
|
|
|
|
|
2020-12-11 17:19:53 +00:00
|
|
|
cp "$REPO_ROOT/scripts/bytecodecompare/prepare_report.js" .
|
2022-02-03 13:52:58 +00:00
|
|
|
npm install ./solc-js/dist
|
2022-01-25 16:12:35 +00:00
|
|
|
|
2020-05-27 07:39:45 +00:00
|
|
|
echo "Running the compiler..."
|
2020-12-11 17:28:19 +00:00
|
|
|
# shellcheck disable=SC2035
|
2020-12-12 23:40:48 +00:00
|
|
|
./prepare_report.js *.sol > report.txt
|
2020-05-27 07:39:45 +00:00
|
|
|
echo "Finished running the compiler."
|
2017-03-22 19:19:57 +00:00
|
|
|
else
|
2020-11-20 13:56:12 +00:00
|
|
|
"$REPO_ROOT/scripts/bytecodecompare/prepare_report.py" "$BUILD_DIR/solc/solc"
|
2017-03-22 19:19:57 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-20 13:56:12 +00:00
|
|
|
cp report.txt "$REPO_ROOT"
|
2017-03-22 19:19:57 +00:00
|
|
|
)
|
2017-05-24 12:36:46 +00:00
|
|
|
rm -rf "$TMPDIR"
|
2020-10-14 16:26:18 +00:00
|
|
|
echo "Storebytecode finished."
|