From 8fe27ac4b49f0848c374ca6c32e8d237814a0008 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 12 May 2020 14:52:21 +0200 Subject: [PATCH] Add Dockerfile for an Emscripten build environment and use it for CI runs. --- .circleci/config.yml | 14 +--- .circleci/docker/Dockerfile.emscripten | 66 +++++++++++++++++++ .../docker}/emscripten.jam | 8 +-- .travis.yml | 2 +- scripts/build_emscripten.sh | 4 +- scripts/travis-emscripten/build_emscripten.sh | 31 +-------- scripts/travis-emscripten/install_deps.sh | 49 -------------- 7 files changed, 74 insertions(+), 100 deletions(-) create mode 100644 .circleci/docker/Dockerfile.emscripten rename {scripts/travis-emscripten => .circleci/docker}/emscripten.jam (96%) delete mode 100755 scripts/travis-emscripten/install_deps.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 0620cd667..81acd1383 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -558,27 +558,15 @@ jobs: b_ems: docker: - - image: trzeci/emscripten:sdk-tag-1.39.3-64bit + - image: ethereum/solidity-buildpack-deps:emsdk-1.39.15-1 environment: TERM: xterm steps: - checkout - - restore_cache: - name: Restore Boost build - key: &boost-cache-key emscripten-boost-{{ checksum "scripts/travis-emscripten/install_deps.sh" }}{{ checksum "scripts/build_emscripten.sh" }}{{ checksum "scripts/travis-emscripten/build_emscripten.sh" }} - - run: - name: Bootstrap Boost - command: | - scripts/travis-emscripten/install_deps.sh - run: name: Build command: | scripts/travis-emscripten/build_emscripten.sh - - save_cache: - name: Save Boost build - key: *boost-cache-key - paths: - - boost_1_70_0_install - store_artifacts: path: emscripten_build/libsolc/soljson.js destination: soljson.js diff --git a/.circleci/docker/Dockerfile.emscripten b/.circleci/docker/Dockerfile.emscripten new file mode 100644 index 000000000..67432f6c5 --- /dev/null +++ b/.circleci/docker/Dockerfile.emscripten @@ -0,0 +1,66 @@ +# vim:syntax=dockerfile +#------------------------------------------------------------------------------ +# Dockerfile for building and testing Solidity Compiler on CI +# Target: Emscripten +# URL: https://hub.docker.com/r/ethereum/solidity-buildpack-deps +# +# 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 +# +# (c) 2016-2019 solidity contributors. +#------------------------------------------------------------------------------ +# +# The Emscripten SDK at https://github.com/emscripten-core/emsdk/ +# contains a Makefile in the docker/ subdirectory that can be used to create the +# required base image using: +# +# make version=1.39.15-fastcomp build +# +# TODO: switch to the upstream backend by removing "-fastcomp". +# +FROM emscripten/emsdk:1.39.15-fastcomp AS base + +ADD emscripten.jam /usr/src +RUN set -ex; \ + cd /usr/src; \ + git clone https://github.com/Z3Prover/z3.git -b z3-4.8.8 --depth 1 ; \ + cd z3; \ + mkdir build; \ + cd build; \ + emcmake cmake \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DCMAKE_INSTALL_PREFIX=/emsdk/emscripten/sdk/system/ \ + -DZ3_BUILD_LIBZ3_SHARED=OFF \ + -DZ3_ENABLE_EXAMPLE_TARGETS=OFF \ + -DZ3_BUILD_TEST_EXECUTABLES=OFF \ + -DZ3_BUILD_EXECUTABLE=OFF \ + -DZ3_SINGLE_THREADED=ON \ + ..; \ + make; make install; \ + rm -r /usr/src/z3; \ + cd /usr/src; \ + wget -q 'https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2' -O boost.tar.bz2; \ + test "$(sha256sum boost.tar.bz2)" = "4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402 boost.tar.bz2"; \ + tar -xf boost.tar.bz2; \ + rm boost.tar.bz2; \ + cd boost_1_73_0; \ + mv ../emscripten.jam .; \ + ./bootstrap.sh; \ + echo "using emscripten : : em++ ;" >> project-config.jam ; \ + ./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \ + --with-system --with-filesystem --with-test --with-program_options \ + cxxflags="-Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ + --prefix=/emsdk/emscripten/sdk/system install; \ + rm -r /usr/src/boost_1_73_0 diff --git a/scripts/travis-emscripten/emscripten.jam b/.circleci/docker/emscripten.jam similarity index 96% rename from scripts/travis-emscripten/emscripten.jam rename to .circleci/docker/emscripten.jam index 0cc92bd56..2d0ad524c 100644 --- a/scripts/travis-emscripten/emscripten.jam +++ b/.circleci/docker/emscripten.jam @@ -79,10 +79,10 @@ rule init ( version ? : command * : options * ) # @todo this seems to be the right way, but this is a list somehow toolset.add-requirements emscripten:node ; - toolset.flags emscripten.compile STDHDRS $(condition) : /emsdk_portable/emscripten/sdk/system/include ; - toolset.flags emscripten.link STDLIBPATH $(condition) : /emsdk_portable/emscripten/sdk/system/lib ; - toolset.flags emscripten AR $(condition) : /emsdk_portable/emscripten/sdk/emar ; - toolset.flags emscripten RANLIB $(condition) : /emsdk_portable/emscripten/sdk/emranlib ; + toolset.flags emscripten.compile STDHDRS $(condition) : /emsdk/emscripten/sdk/system/include ; + toolset.flags emscripten.link STDLIBPATH $(condition) : /emsdk/emscripten/sdk/system/lib ; + toolset.flags emscripten AR $(condition) : /emsdk/emscripten/sdk/emar ; + toolset.flags emscripten RANLIB $(condition) : /emsdk/emscripten/sdk/emranlib ; } type.set-generated-target-suffix EXE : emscripten : js ; diff --git a/.travis.yml b/.travis.yml index 38d59fa93..36d3943df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -110,7 +110,7 @@ matrix: before_install: - nvm install 8 - nvm use 8 - - docker pull trzeci/emscripten:sdk-tag-1.39.3-64bit + - docker pull ethereum/solidity-buildpack-deps:emsdk-1.39.15-1 env: - SOLC_EMSCRIPTEN=On - SOLC_INSTALL_DEPS_TRAVIS=Off diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index cf6cbdd79..3d6e17210 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -34,7 +34,5 @@ else BUILD_DIR="$1" fi -docker run -v $(pwd):/root/project -w /root/project trzeci/emscripten:sdk-tag-1.39.3-64bit \ - ./scripts/travis-emscripten/install_deps.sh -docker run -v $(pwd):/root/project -w /root/project trzeci/emscripten:sdk-tag-1.39.3-64bit \ +docker run -v $(pwd):/root/project -w /root/project ethereum/solidity-buildpack-deps:emsdk-1.39.15-1 \ ./scripts/travis-emscripten/build_emscripten.sh $BUILD_DIR diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index 7d3253515..c338a1977 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -40,37 +40,8 @@ else BUILD_DIR="$1" fi -if ! type git &>/dev/null; then - # We need git for extracting the commit hash - apt-get update - apt-get -y install git-core -fi - -if ! type wget &>/dev/null; then - # We need wget to install cmake - apt-get update - apt-get -y install wget -fi - WORKSPACE=/root/project -# Boost -echo -en 'travis_fold:start:compiling_boost\\r' -test -e "$WORKSPACE"/boost_1_70_0_install/include/boost/version.hpp || ( -cd "$WORKSPACE"/boost_1_70_0 -./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \ - --with-system --with-filesystem --with-test --with-program_options cxxflags="-Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ - --prefix="$WORKSPACE"/boost_1_70_0_install install -) -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 -echo -en 'travis_fold:end:compiling_boost\\r' - -echo -en 'travis_fold:start:install_cmake.sh\\r' -source $WORKSPACE/scripts/install_cmake.sh -echo -en 'travis_fold:end:install_cmake.sh\\r' - -# Build dependent components and solidity itself echo -en 'travis_fold:start:compiling_solidity\\r' cd $WORKSPACE mkdir -p $BUILD_DIR @@ -82,7 +53,7 @@ cmake \ -DBoost_USE_STATIC_RUNTIME=1 \ -DTESTS=0 \ .. -make -j 4 +make -j 4 soljson cd .. mkdir -p upload diff --git a/scripts/travis-emscripten/install_deps.sh b/scripts/travis-emscripten/install_deps.sh deleted file mode 100755 index 7544da4e2..000000000 --- a/scripts/travis-emscripten/install_deps.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -#------------------------------------------------------------------------------ -# Bash script for installing pre-requisite packages for building solidity -# using Emscripten on Ubuntu Trusty. -# -# 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 -# -# (c) 2016 solidity contributors. -#------------------------------------------------------------------------------ - -set -ev - -SCRIPT_DIR="$(realpath $(dirname $0))" - -echo -en 'travis_fold:start:installing_dependencies\\r' -test -e boost_1_70_0_install/include/boost/version.hpp || ( -rm -rf boost_1_70_0 -rm -f boost.tar.gz -wget -q 'https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz/download'\ - -O boost.tar.gz -test "$(shasum boost.tar.gz)" = "7804c782deb00f36ac80b1000b71a3707eadb620 boost.tar.gz" -tar -xzf boost.tar.gz -rm boost.tar.gz -cd boost_1_70_0 -./bootstrap.sh -cp "${SCRIPT_DIR}/emscripten.jam" . -echo "using emscripten : : em++ ;" >> project-config.jam -) -cd .. -echo -en 'travis_fold:end:installing_dependencies\\r'