diff --git a/.circleci/build_win.ps1 b/.circleci/build_win.ps1 deleted file mode 100644 index e95caa7c1cf6..000000000000 --- a/.circleci/build_win.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -$ErrorActionPreference = "Stop" - -cd "$PSScriptRoot\.." - -if ("$Env:FORCE_RELEASE" -Or "$Env:CIRCLE_TAG") { - New-Item prerelease.txt -type file - Write-Host "Building release version." -} -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. - $last_commit_timestamp = git log -1 --date=unix --format=%cd HEAD - $last_commit_date = (Get-Date -Date "1970-01-01 00:00:00Z").toUniversalTime().addSeconds($last_commit_timestamp).ToString("yyyy.M.d") - -join("ci.", $last_commit_date) | out-file -encoding ascii prerelease.txt -} - -mkdir build -cd build -$boost_dir=(Resolve-Path $PSScriptRoot\..\deps\boost\lib\cmake\Boost-*) -..\deps\cmake\bin\cmake -G "Visual Studio 16 2019" -DBoost_DIR="$boost_dir\" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_INSTALL_PREFIX="$PSScriptRoot\..\upload" .. -if ( -not $? ) { throw "CMake configure failed." } -msbuild solidity.sln /p:Configuration=Release /m:10 /v:minimal -if ( -not $? ) { throw "Build failed." } -..\deps\cmake\bin\cmake --build . -j 10 --target install --config Release -if ( -not $? ) { throw "Install target failed." } diff --git a/.circleci/config.yml b/.circleci/config.yml index 0931fae8e832..0b526ae70d59 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1640,8 +1640,7 @@ jobs: - .\deps - run: name: "Building solidity" - command: .circleci/build_win.ps1 - shell: powershell.exe + command: scripts/ci/build_win.sh - run: name: "Run solc.exe to make sure build was successful." command: .\build\solc\Release\solc.exe --version diff --git a/scripts/ci/build_win.sh b/scripts/ci/build_win.sh new file mode 100755 index 000000000000..647cb02d95b6 --- /dev/null +++ b/scripts/ci/build_win.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +(( $# <= 1 )) || { >&2 echo "Usage: $0 [PRERELEASE_SOURCE]"; exit 1; } +prerelease_source="${1:-ci}" +ROOTDIR="$(realpath "$(dirname "$0")/../../")" +FORCE_RELEASE="${FORCE_RELEASE:-}" +CIRCLE_TAG="${CIRCLE_TAG:-}" + +cd "$ROOTDIR" +if [[ $FORCE_RELEASE != "" || $CIRCLE_TAG != "" ]]; then + 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. + # NOTE: The -local suffix makes git not use the timezone from the commit but instead convert to + # local one, which we explicitly set to UTC. + # NOTE: git --date is supposed to support the %-m/%-d format too, but it does not seem to + # work on Windows. Without it we get leading zeros for month and day. + last_commit_date=$(TZ=UTC git show --quiet --date="format-local:%Y-%m-%d" --format="%cd") + last_commit_date_stripped=$(date --date="$last_commit_date" "+%Y.%-m.%-d") + echo -n "${prerelease_source}.${last_commit_date_stripped}" > prerelease.txt +fi + +mkdir -p build/ +cd build/ + +# NOTE: Using an array to force Bash to do wildcard expansion +boost_dir=("${ROOTDIR}/deps/boost/lib/cmake/Boost-"*) + +"${ROOTDIR}/deps/cmake/bin/cmake" \ + -G "Visual Studio 16 2019" \ + -DBoost_DIR="${boost_dir[*]}" \ + -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded \ + -DCMAKE_INSTALL_PREFIX="${ROOTDIR}/uploads/" \ + .. +MSBuild.exe solidity.sln \ + -property:Configuration=Release \ + -maxCpuCount:10 \ + -verbosity:minimal +"${ROOTDIR}/deps/cmake/bin/cmake" \ + --build . \ + -j 10 \ + --target install \ + --config Release diff --git a/scripts/install_cmake.sh b/scripts/install_cmake.sh deleted file mode 100755 index 0533de7234e4..000000000000 --- a/scripts/install_cmake.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env sh - -# This script downloads the CMake binary and installs it in ~/.local directory -# (the cmake executable will be in ~/.local/bin). -# This is mostly suitable for CIs, not end users. - -set -eu - -VERSION_MAJOR=3 -VERSION_MINOR=15 -VERSION_MICRO=2 -VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_MICRO -PREFIX="/usr/local" - -OS=$(uname -s) -case $OS in -Linux) SHA256=f8cbec2abc433938bd9378b129d1d288bb33b8b5a277afe19644683af6e32a59;; -Darwin) SHA256=7ec056d641b8cbea98b220efdcc99da1991758a370063dcac3a0cd388d6b30b6;; -esac - -BIN=$PREFIX/bin - -PATH=$PREFIX/bin:$PATH - -if test -f $BIN/cmake && ($BIN/cmake --version | grep -q "$VERSION"); then - echo "CMake $VERSION already installed in $BIN" -else - FILE=cmake-$VERSION-$OS-x86_64.tar.gz - URL=https://cmake.org/files/v$VERSION_MAJOR.$VERSION_MINOR/$FILE - TMPFILE=$(mktemp --tmpdir "cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz") - echo "Downloading CMake ($URL)..." - wget "$URL" -O "$TMPFILE" -nv - if ! (shasum -a256 "$TMPFILE" | grep -q "$SHA256"); then - echo "Checksum mismatch ($TMPFILE)" - exit 1 - fi - mkdir -p "$PREFIX" - tar xzf "$TMPFILE" -C "$PREFIX" --strip 1 - rm "$TMPFILE" -fi