diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Dockerfile | 2 | ||||
-rwxr-xr-x | scripts/build_emscripten.sh | 6 | ||||
-rw-r--r-- | scripts/bytecodecompare/deploy_key.enc | bin | 0 -> 1680 bytes | |||
-rwxr-xr-x | scripts/bytecodecompare/prepare_report.py | 24 | ||||
-rw-r--r-- | scripts/bytecodecompare/storebytecode.bat | 41 | ||||
-rwxr-xr-x | scripts/bytecodecompare/storebytecode.sh | 104 | ||||
-rwxr-xr-x | scripts/create_source_tarball.sh | 5 | ||||
-rwxr-xr-x | scripts/docker_build.sh | 8 | ||||
-rwxr-xr-x | scripts/docker_deploy.sh | 6 | ||||
-rw-r--r-- | scripts/install_deps.bat | 1 | ||||
-rwxr-xr-x | scripts/install_deps.sh | 6 | ||||
-rw-r--r-- | scripts/install_eth.cmake | 76 | ||||
-rwxr-xr-x | scripts/isolate_tests.py | 32 | ||||
-rwxr-xr-x | scripts/release.sh | 4 | ||||
-rwxr-xr-x | scripts/tests.sh | 10 | ||||
-rwxr-xr-x | scripts/travis-emscripten/build_emscripten.sh | 2 | ||||
-rwxr-xr-x | scripts/update_bugs_by_version.py | 43 |
17 files changed, 261 insertions, 109 deletions
diff --git a/scripts/Dockerfile b/scripts/Dockerfile index ad448fd3..c984ce99 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -14,3 +14,5 @@ make solc && install -s solc/solc /usr/bin &&\ cd / && rm -rf solidity &&\ apk del sed build-base git make cmake gcc g++ musl-dev curl-dev boost-dev &&\ rm -rf /var/cache/apk/* + +ENTRYPOINT ["/usr/bin/solc"]
\ No newline at end of file diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 9b432e95..6046978e 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -29,12 +29,6 @@ set -e if [[ "$OSTYPE" != "darwin"* ]]; then - if [ "$TRAVIS_BRANCH" = release ] - then - echo -n > prerelease.txt - else - date -u +"nightly.%Y.%-m.%-d" > prerelease.txt - fi ./scripts/travis-emscripten/install_deps.sh docker run -v $(pwd):/src trzeci/emscripten:sdk-tag-1.35.4-64bit ./scripts/travis-emscripten/build_emscripten.sh fi diff --git a/scripts/bytecodecompare/deploy_key.enc b/scripts/bytecodecompare/deploy_key.enc Binary files differnew file mode 100644 index 00000000..acab2a27 --- /dev/null +++ b/scripts/bytecodecompare/deploy_key.enc diff --git a/scripts/bytecodecompare/prepare_report.py b/scripts/bytecodecompare/prepare_report.py new file mode 100755 index 00000000..5a770981 --- /dev/null +++ b/scripts/bytecodecompare/prepare_report.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import sys +import glob +import subprocess +import json + +solc = sys.argv[1] +report = open("report.txt", "w") + +for optimize in [False, True]: + for f in sorted(glob.glob("*.sol")): + args = [solc, '--combined-json', 'bin,metadata', f] + if optimize: + args += ['--optimize'] + proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (out, err) = proc.communicate() + try: + result = json.loads(out.strip()) + for contractName in sorted(result['contracts'].keys()): + report.write(contractName + ' ' + result['contracts'][contractName]['bin'] + '\n') + report.write(contractName + ' ' + result['contracts'][contractName]['metadata'] + '\n') + except: + report.write(f + ": ERROR\n") diff --git a/scripts/bytecodecompare/storebytecode.bat b/scripts/bytecodecompare/storebytecode.bat new file mode 100644 index 00000000..969a42a4 --- /dev/null +++ b/scripts/bytecodecompare/storebytecode.bat @@ -0,0 +1,41 @@ +@ECHO OFF + +REM --------------------------------------------------------------------------- +REM This file is part of solidity. +REM +REM solidity is free software: you can redistribute it and/or modify +REM it under the terms of the GNU General Public License as published by +REM the Free Software Foundation, either version 3 of the License, or +REM (at your option) any later version. +REM +REM solidity is distributed in the hope that it will be useful, +REM but WITHOUT ANY WARRANTY; without even the implied warranty of +REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +REM GNU General Public License for more details. +REM +REM You should have received a copy of the GNU General Public License +REM along with solidity. If not, see <http://www.gnu.org/licenses/> +REM +REM Copyright (c) 2017 solidity contributors. +REM --------------------------------------------------------------------------- + +set CONFIGURATION=%1 +set COMMIT=%2 + +mkdir bytecode +cd bytecode +..\scripts\isolate_tests.py ..\test\ +..\scripts\bytecodecompare\prepare_report.py ..\build\solc\%CONFIGURATION%\solc.exe + +git clone --depth 2 git@github.com:ethereum/solidity-test-bytecode.git +cd solidity-test-bytecode +git config user.name "travis" +git config user.email "chris@ethereum.org" +git clean -f -d -x + +mkdir %COMMIT% +set REPORT=%COMMIT%/windows.txt +cp ../report.txt %REPORT% +git add %REPORT% +git commit -a -m "Added report." +git push origin diff --git a/scripts/bytecodecompare/storebytecode.sh b/scripts/bytecodecompare/storebytecode.sh new file mode 100755 index 00000000..9a40bc6d --- /dev/null +++ b/scripts/bytecodecompare/storebytecode.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +#------------------------------------------------------------------------------ +# Script used for cross-platform comparison as part of the travis automation. +# Splits all test source code into multiple files, generates bytecode and +# uploads the bytecode into github.com/ethereum/solidity-test-bytecode where +# another travis job is triggered to do the actual comparison. +# +# ------------------------------------------------------------------------------ +# 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")"/../.. + +echo "Compiling all test contracts into bytecode..." +TMPDIR=$(mktemp -d) +( + cd "$REPO_ROOT" + REPO_ROOT=$(pwd) # make it absolute + cd "$TMPDIR" + + "$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/ + + if [[ "$SOLC_EMSCRIPTEN" = "On" ]] + then + cp "$REPO_ROOT/build/solc/soljson.js" . + npm install solc + cat > solc <<EOF +#!/usr/bin/env node +var process = require('process') +var fs = require('fs') + +var compiler = require('solc/wrapper.js')(require('./soljson.js')) + +for (var optimize of [false, true]) +{ + for (var filename of process.argv.slice(2)) + { + if (filename !== undefined) + { + var inputs = {} + inputs[filename] = fs.readFileSync(filename).toString() + var result = compiler.compile({sources: inputs}, optimize) + if (!('contracts' in result) || Object.keys(result['contracts']).length === 0) + { + console.log(filename + ': ERROR') + } + else + { + for (var contractName in result['contracts']) + { + console.log(contractName + ' ' + result['contracts'][contractName].bytecode) + console.log(contractName + ' ' + result['contracts'][contractName].metadata) + } + } + } + } +} +EOF + chmod +x solc + ./solc *.sol > report.txt + else + $REPO_ROOT/scripts/bytecodecompare/prepare_report.py $REPO_ROOT/build/solc/solc + fi + + if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ] + then + openssl aes-256-cbc -K $encrypted_60701c962b9c_key -iv $encrypted_60701c962b9c_iv -in "$REPO_ROOT"/scripts/bytecodecompare/deploy_key.enc -out deploy_key -d + chmod 600 deploy_key + eval `ssh-agent -s` + ssh-add deploy_key + + git clone --depth 2 git@github.com:ethereum/solidity-test-bytecode.git + cd solidity-test-bytecode + git config user.name "travis" + git config user.email "chris@ethereum.org" + git clean -f -d -x + + mkdir -p "$TRAVIS_COMMIT" + REPORT="$TRAVIS_COMMIT/$ZIP_SUFFIX.txt" + cp ../report.txt "$REPORT" + git add "$REPORT" + git commit -a -m "Added report $REPORT" + git push origin + fi +) +rm -rf "$TMPDIR"
\ No newline at end of file diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index 1f78e12c..9ca72c31 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -15,7 +15,7 @@ REPO_ROOT="$(dirname "$0")"/.. then versionstring="$version" else - versionstring="$version-develop-$commitdate-$commithash" + versionstring="$version-nightly-$commitdate-$commithash" fi TEMPDIR=$(mktemp -d) @@ -29,6 +29,7 @@ REPO_ROOT="$(dirname "$0")"/.. # Add dependencies mkdir -p "$SOLDIR/deps/downloads/" 2>/dev/null || true wget -O "$SOLDIR/deps/downloads/jsoncpp-1.7.7.tar.gz" https://github.com/open-source-parsers/jsoncpp/archive/1.7.7.tar.gz - tar czf "$REPO_ROOT/solidity_$versionstring.tar.gz" -C "$TEMPDIR" "solidity_$versionstring" + mkdir -p "$REPO_ROOT/upload" + tar czf "$REPO_ROOT/upload/solidity_$versionstring.tar.gz" -C "$TEMPDIR" "solidity_$versionstring" rm -r "$TEMPDIR" ) diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh new file mode 100755 index 00000000..22657a8c --- /dev/null +++ b/scripts/docker_build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +set -e + +docker build -t ethereum/solc:build -f scripts/Dockerfile . +tmp_container=$(docker create ethereum/solc:build sh) +mkdir -p upload +docker cp ${tmp_container}:/usr/bin/solc upload/solc-static-linux diff --git a/scripts/docker_deploy.sh b/scripts/docker_deploy.sh index d2810a3e..0abde840 100755 --- a/scripts/docker_deploy.sh +++ b/scripts/docker_deploy.sh @@ -10,13 +10,11 @@ then docker tag ethereum/solc:build ethereum/solc:nightly-"$version"-"$TRAVIS_COMMIT" docker push ethereum/solc:nightly-"$version"-"$TRAVIS_COMMIT"; docker push ethereum/solc:nightly; -elif [ "$TRAVIS_BRANCH" = "release" ] -then - docker tag ethereum/solc:build ethereum/solc:stable; - docker push ethereum/solc:stable; elif [ "$TRAVIS_TAG" = v"$version" ] then + docker tag ethereum/solc:build ethereum/solc:stable; docker tag ethereum/solc:build ethereum/solc:"$version"; + docker push ethereum/solc:stable; docker push ethereum/solc:"$version"; else echo "Not publishing docker image from branch $TRAVIS_BRANCH or tag $TRAVIS_TAG" diff --git a/scripts/install_deps.bat b/scripts/install_deps.bat index bd68b07a..512a28df 100644 --- a/scripts/install_deps.bat +++ b/scripts/install_deps.bat @@ -59,4 +59,3 @@ REM Copyright (c) 2016 solidity contributors. REM --------------------------------------------------------------------------- cmake -P deps\install_deps.cmake -cmake -P scripts\install_eth.cmake diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 7cfc92f2..24cf49d5 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -96,7 +96,7 @@ case $(uname -s) in brew update brew install boost brew install cmake - if ["$CI" = true]; then + if [ "$CI" = true ]; then brew upgrade cmake brew tap ethereum/ethereum brew install cpp-ethereum @@ -314,12 +314,12 @@ case $(uname -s) in libboost-all-dev if [ "$CI" = true ]; then # Install 'eth', for use in the Solidity Tests-over-IPC. + # We will not use this 'eth', but its dependencies sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get -y update sudo apt-get -y install eth fi - ;; #------------------------------------------------------------------------------ @@ -394,4 +394,4 @@ case $(uname -s) in echo "If you would like to get your operating system working, that would be fantastic." echo "Drop us a message at https://gitter.im/ethereum/solidity." ;; -esac
\ No newline at end of file +esac diff --git a/scripts/install_eth.cmake b/scripts/install_eth.cmake deleted file mode 100644 index 25f449e0..00000000 --- a/scripts/install_eth.cmake +++ /dev/null @@ -1,76 +0,0 @@ -#------------------------------------------------------------------------------ -# Cmake script for installing pre-requisite package eth for solidity. -# -# The aim of this script is to simply download and unpack eth binaries to the deps folder. -# -# 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. -#------------------------------------------------------------------------------ - -function(download URL DST_FILE STATUS) - set(TMP_FILE "${DST_FILE}.part") - - get_filename_component(FILE_NAME ${DST_FILE} NAME) - if (NOT EXISTS ${DST_FILE}) - message("Downloading ${FILE_NAME}") - file(DOWNLOAD ${URL} ${TMP_FILE} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) - list(GET DOWNLOAD_STATUS 0 STATUS_CODE) - if (STATUS_CODE EQUAL 0) - file(RENAME ${TMP_FILE} ${DST_FILE}) - else() - file(REMOVE ${TMP_FILE}) - list(GET DOWNLOAD_STATUS 1 ERROR_MSG) - - message("ERROR! Downloading '${FILE_NAME}' failed.") - message(STATUS "URL: ${URL}") - message(STATUS "Error: ${STATUS_CODE} ${ERROR_MSG}") - set(STATUS FALSE PARENT_SCOPE) - return() - endif() - else() - message("Using cached ${FILE_NAME}") - endif() - set(STATUS TRUE PARENT_SCOPE) -endfunction(download) - -function(download_and_unpack PACKAGE_URL DST_DIR) - get_filename_component(FILE_NAME ${PACKAGE_URL} NAME) - - set(DST_FILE "${CACHE_DIR}/${FILE_NAME}") - set(TMP_FILE "${DST_FILE}.part") - - file(MAKE_DIRECTORY ${CACHE_DIR}) - file(MAKE_DIRECTORY ${DST_DIR}) - - download(${PACKAGE_URL} ${DST_FILE} STATUS) - - if (STATUS) - message("Unpacking ${FILE_NAME} to ${DST_DIR}") - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${DST_FILE} - WORKING_DIRECTORY ${DST_DIR}) - endif() -endfunction(download_and_unpack) - -get_filename_component(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) -set(CACHE_DIR "${ROOT_DIR}/deps/cache") -set(INSTALL_DIR "${ROOT_DIR}/deps/install/x64/eth") -download_and_unpack("https://github.com/bobsummerwill/cpp-ethereum/releases/download/develop-v1.3.0.401/cpp-ethereum-develop-windows.zip" ${INSTALL_DIR}) diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 91900aa6..a1d1c75c 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -7,38 +7,42 @@ # scripts/isolate_tests.py test/libsolidity/* import sys - +import re +import os +import hashlib +from os.path import join def extract_cases(path): - lines = open(path).read().splitlines() + lines = open(path, 'rb').read().splitlines() inside = False + delimiter = '' tests = [] for l in lines: if inside: - if l.strip().endswith(')";'): + if l.strip().endswith(')' + delimiter + '";'): inside = False else: tests[-1] += l + '\n' else: - if l.strip().endswith('R"('): + m = re.search(r'R"([^(]*)\($', l.strip()) + if m: inside = True + delimiter = m.group(1) tests += [''] return tests -def write_cases(tests, start=0): - for i, test in enumerate(tests, start=start): - open('test%d.sol' % i, 'w').write(test) - +def write_cases(tests): + for test in tests: + open('test_%s.sol' % hashlib.sha256(test).hexdigest(), 'wb').write(test) if __name__ == '__main__': - files = sys.argv[1:] + path = sys.argv[1] - i = 0 - for path in files: - cases = extract_cases(path) - write_cases(cases, start=i) - i += len(cases) + for root, dir, files in os.walk(path): + for f in files: + cases = extract_cases(join(root, f)) + write_cases(cases) diff --git a/scripts/release.sh b/scripts/release.sh index e9f43f6c..a2f4d98a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -88,5 +88,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then fi # And ZIP it all up, with a filename suffix passed in on the command-line. - -zip -j $REPO_ROOT/solidity-$ZIP_SUFFIX.zip $ZIP_TEMP_DIR/* +mkdir -p $REPO_ROOT/upload +zip -j $REPO_ROOT/upload/solidity-$ZIP_SUFFIX.zip $ZIP_TEMP_DIR/* diff --git a/scripts/tests.sh b/scripts/tests.sh index d47edd28..6b76c154 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -42,8 +42,16 @@ test "${output//[[:blank:]]/}" = "3" # instead. This will go away soon. if [[ "$OSTYPE" == "darwin"* ]]; then ETH_PATH="$REPO_ROOT/eth" -else +elif [ -z $CI ]; then ETH_PATH="eth" +else + mkdir -p /tmp/test + wget -O /tmp/test/eth https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/eth + test "$(shasum /tmp/test/eth)" = "c132e8989229e4840831a4fb1a1d058b732a11d5 /tmp/test/eth" + sync + chmod +x /tmp/test/eth + sync # Otherwise we might get a "text file busy" error + ETH_PATH="/tmp/test/eth" fi # This trailing ampersand directs the shell to run the command in the background, diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index a6eb01a0..02740e6c 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -94,6 +94,8 @@ emmake make -j 4 cd .. cp build/solc/soljson.js ./ +mkdir -p upload +cp soljson.js upload/ OUTPUT_SIZE=`ls -la build/solc/soljson.js` diff --git a/scripts/update_bugs_by_version.py b/scripts/update_bugs_by_version.py new file mode 100755 index 00000000..c4bc0c9b --- /dev/null +++ b/scripts/update_bugs_by_version.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# +# This script is used to generate the list of bugs per compiler version +# from the list of bugs. +# It updates the list in place and signals failure if there were changes. +# This makes it possible to use this script as part of CI to check +# that the list is up to date. + +import os +import json +import re +import sys + +def comp(version_string): + return [int(c) for c in version_string.split('.')] + +path = os.path.dirname(os.path.realpath(__file__)) +with open(path + '/../docs/bugs.json') as bugsFile: + bugs = json.load(bugsFile) + +versions = {} +with open(path + '/../Changelog.md') as changelog: + for line in changelog: + m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line) + if m: + versions[m.group(1)] = {} + versions[m.group(1)]['released'] = m.group(2) + +for v in versions: + versions[v]['bugs'] = [] + for bug in bugs: + if 'introduced' in bug and comp(bug['introduced']) > comp(v): + continue + if comp(bug['fixed']) <= comp(v): + continue + versions[v]['bugs'] += [bug['name']] + +with open(path + '/../docs/bugs_by_version.json', 'r+') as bugs_by_version: + old_contents = bugs_by_version.read() + new_contents = json.dumps(versions, sort_keys=True, indent=4) + bugs_by_version.seek(0) + bugs_by_version.write(new_contents) + sys.exit(old_contents != new_contents)
\ No newline at end of file |