From 860226e25dca397b5afd70680530963712aff050 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 15 Sep 2020 14:16:22 +0200 Subject: [PATCH 1/4] Allow statically linked windows build in CMake. --- cmake/EthDependencies.cmake | 3 +++ cmake/EthPolicy.cmake | 6 +++++- cmake/jsoncpp.cmake | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index d8bca8a31..04cb876be 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -25,6 +25,9 @@ set(ETH_SCRIPTS_DIR ${ETH_CMAKE_DIR}/scripts) ## use multithreaded boost libraries, with -mt suffix set(Boost_USE_MULTITHREADED ON) option(Boost_USE_STATIC_LIBS "Link Boost statically" ON) +if(WIN32) + option(Boost_USE_STATIC_RUNTIME "Link Boost against static C++ runtime libraries" ON) +endif() set(BOOST_COMPONENTS "filesystem;unit_test_framework;program_options;system") diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake index 4e29898cb..cc404e794 100644 --- a/cmake/EthPolicy.cmake +++ b/cmake/EthPolicy.cmake @@ -15,5 +15,9 @@ macro (eth_policy) # do not interpret if() arguments as variables! cmake_policy(SET CMP0054 NEW) endif() -endmacro() + if (POLICY CMP0091) + # Allow selecting MSVC runtime library using CMAKE_MSVC_RUNTIME_LIBRARY. + cmake_policy(SET CMP0091 NEW) + endif() +endmacro() diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 80a16f8d5..29b8f5f05 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -34,6 +34,12 @@ if(CMAKE_VERSION VERSION_GREATER 3.1) set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}") endif() +# Propagate CMAKE_MSVC_RUNTIME_LIBRARY on Windows builds, if set. +if (WIN32 AND POLICY CMP0091 AND CMAKE_MSVC_RUNTIME_LIBRARY) + list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW") + list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}") +endif() + ExternalProject_Add(jsoncpp-project PREFIX "${prefix}" DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" @@ -51,6 +57,7 @@ ExternalProject_Add(jsoncpp-project -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF -DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${JSONCPP_CMAKE_ARGS} ${byproducts} ) From d66b6f1c467469ea6c1e346f09f60384868837c7 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 15 Sep 2020 14:47:30 +0200 Subject: [PATCH 2/4] CircleCI Windows config and install_deps.ps1 script. --- .circleci/build_win.ps1 | 7 +++++++ .circleci/config.yml | 37 +++++++++++++++++++++++++++++++++++++ scripts/install_deps.ps1 | 15 +++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 .circleci/build_win.ps1 create mode 100644 scripts/install_deps.ps1 diff --git a/.circleci/build_win.ps1 b/.circleci/build_win.ps1 new file mode 100644 index 000000000..a3d0abc00 --- /dev/null +++ b/.circleci/build_win.ps1 @@ -0,0 +1,7 @@ +cd "$PSScriptRoot\.." +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" .. +msbuild solidity.sln /p:Configuration=Release /m:5 /v:minimal +..\deps\cmake\bin\cmake --build . -j 5 --target install --config Release diff --git a/.circleci/config.yml b/.circleci/config.yml index 0cf54d7e1..7d44f12f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,6 +27,9 @@ parameters: type: string default: "solbuildpackpusher/solidity-buildpack-deps@sha256:23dad3b34deae8107c8551804ef299f6a89c23ed506e8118fac151e2bdc9018c" +orbs: + win: circleci/windows@2.2.0 + defaults: # -------------------------------------------------------------------------- @@ -64,6 +67,11 @@ defaults: path: build/solc/solc destination: solc + # windows binary archive + - artifact_solc_windows: &artifact_solc_windows + path: upload/solidity-windows.zip + destination: solidity-windows.zip + # compiled tool executable target - artifacts_tools: &artifacts_tools path: build/tools/solidity-upgrade @@ -876,6 +884,32 @@ jobs: - run: *gitter_notify_failure - run: *gitter_notify_success + b_win: + executor: + name: win/default + shell: powershell.exe + steps: + - checkout + - restore_cache: + keys: + - dependencies-win-{{ checksum "scripts/install_deps.ps1" }} + - run: + name: "Installing dependencies" + command: if ( -not (Test-Path .\deps\boost) ) { .\scripts\install_deps.ps1 } + - save_cache: + key: dependencies-win-{{ checksum "scripts/install_deps.ps1" }} + paths: + - .\deps\boost + - .\deps\cmake + - run: + name: "Building solidity" + command: .circleci/build_win.ps1 + - run: + name: "Package solidity" + command: Compress-Archive -Path .\upload\bin\* -DestinationPath .\upload\solidity-windows.zip + - store_artifacts: *artifact_solc_windows + - persist_to_workspace: *artifacts_build_dir + workflows: version: 2 @@ -927,6 +961,9 @@ workflows: - t_ems_compile_ext_gnosis: *workflow_emscripten - t_ems_compile_ext_zeppelin: *workflow_emscripten + # Windows build and tests + - b_win: *workflow_trigger_on_tags + nightly: triggers: diff --git a/scripts/install_deps.ps1 b/scripts/install_deps.ps1 new file mode 100644 index 000000000..bcf10eed9 --- /dev/null +++ b/scripts/install_deps.ps1 @@ -0,0 +1,15 @@ +# Needed for Invoke-WebRequest to work via CI. +$progressPreference = "silentlyContinue" + +New-Item -ItemType Directory -Force -Path "$PSScriptRoot\..\deps" + +Invoke-WebRequest -URI "https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-win64-x64.zip" -OutFile cmake.zip +tar -xf cmake.zip +mv cmake-3.18.2-win64-x64 "$PSScriptRoot\..\deps\cmake" + +Invoke-WebRequest -URI "https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.zip" -OutFile boost.zip +tar -xf boost.zip +cd boost_1_74_0 +.\bootstrap.bat +.\b2 -j4 -d0 link=static runtime-link=static variant=release threading=multi address-model=64 --with-filesystem --with-system --with-program_options --with-test --prefix="$PSScriptRoot\..\deps\boost" install +cd .. From d0fa9a5a6db3cba4e024614aa72b1a62b9dfa658 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 16 Sep 2020 13:25:44 +0200 Subject: [PATCH 3/4] Update AppVeyor config to set Boost_USE_STATIC_RUNTIME. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d7211e14b..15ad9b57b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,7 +59,7 @@ install: before_build: - if not exist build mkdir build - cd build - - cmake -G "Visual Studio 15 2017 Win64" .. -DTESTS=On + - cmake -G "Visual Studio 15 2017 Win64" .. -DTESTS=On -DBoost_USE_STATIC_RUNTIME=OFF build_script: - msbuild solidity.sln /p:Configuration=%CONFIGURATION% /m:%NUMBER_OF_PROCESSORS% /v:minimal - cd %APPVEYOR_BUILD_FOLDER% From b97ce763c56819877ba1eedf3102617523f82930 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 16 Sep 2020 17:19:41 +0200 Subject: [PATCH 4/4] Upload binaries individually as artifacts. --- .circleci/config.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7d44f12f1..651bd55d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,10 +67,9 @@ defaults: path: build/solc/solc destination: solc - # windows binary archive + # windows artifacts - artifact_solc_windows: &artifact_solc_windows - path: upload/solidity-windows.zip - destination: solidity-windows.zip + path: upload/ # compiled tool executable target - artifacts_tools: &artifacts_tools @@ -904,9 +903,6 @@ jobs: - run: name: "Building solidity" command: .circleci/build_win.ps1 - - run: - name: "Package solidity" - command: Compress-Archive -Path .\upload\bin\* -DestinationPath .\upload\solidity-windows.zip - store_artifacts: *artifact_solc_windows - persist_to_workspace: *artifacts_build_dir