Skip to content

Commit ef07606

Browse files
authored
Merge pull request #9811 from ethereum/windowsStaticCircleCI
Completely static Windows build on CircleCI
2 parents 19dccf4 + b97ce76 commit ef07606

7 files changed

+71
-2
lines changed

.circleci/build_win.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cd "$PSScriptRoot\.."
2+
mkdir build
3+
cd build
4+
$boost_dir=(Resolve-Path $PSScriptRoot\..\deps\boost\lib\cmake\Boost-*)
5+
..\deps\cmake\bin\cmake -G "Visual Studio 16 2019" -DBoost_DIR="$boost_dir\" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_INSTALL_PREFIX="$PSScriptRoot\..\upload" ..
6+
msbuild solidity.sln /p:Configuration=Release /m:5 /v:minimal
7+
..\deps\cmake\bin\cmake --build . -j 5 --target install --config Release

.circleci/config.yml

+33
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ parameters:
2727
type: string
2828
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:23dad3b34deae8107c8551804ef299f6a89c23ed506e8118fac151e2bdc9018c"
2929

30+
orbs:
31+
win: circleci/windows@2.2.0
32+
3033
defaults:
3134

3235
# --------------------------------------------------------------------------
@@ -64,6 +67,10 @@ defaults:
6467
path: build/solc/solc
6568
destination: solc
6669

70+
# windows artifacts
71+
- artifact_solc_windows: &artifact_solc_windows
72+
path: upload/
73+
6774
# compiled tool executable target
6875
- artifacts_tools: &artifacts_tools
6976
path: build/tools/solidity-upgrade
@@ -876,6 +883,29 @@ jobs:
876883
- run: *gitter_notify_failure
877884
- run: *gitter_notify_success
878885

886+
b_win:
887+
executor:
888+
name: win/default
889+
shell: powershell.exe
890+
steps:
891+
- checkout
892+
- restore_cache:
893+
keys:
894+
- dependencies-win-{{ checksum "scripts/install_deps.ps1" }}
895+
- run:
896+
name: "Installing dependencies"
897+
command: if ( -not (Test-Path .\deps\boost) ) { .\scripts\install_deps.ps1 }
898+
- save_cache:
899+
key: dependencies-win-{{ checksum "scripts/install_deps.ps1" }}
900+
paths:
901+
- .\deps\boost
902+
- .\deps\cmake
903+
- run:
904+
name: "Building solidity"
905+
command: .circleci/build_win.ps1
906+
- store_artifacts: *artifact_solc_windows
907+
- persist_to_workspace: *artifacts_build_dir
908+
879909
workflows:
880910
version: 2
881911

@@ -927,6 +957,9 @@ workflows:
927957
- t_ems_compile_ext_gnosis: *workflow_emscripten
928958
- t_ems_compile_ext_zeppelin: *workflow_emscripten
929959

960+
# Windows build and tests
961+
- b_win: *workflow_trigger_on_tags
962+
930963
nightly:
931964

932965
triggers:

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ install:
5959
before_build:
6060
- if not exist build mkdir build
6161
- cd build
62-
- cmake -G "Visual Studio 15 2017 Win64" .. -DTESTS=On
62+
- cmake -G "Visual Studio 15 2017 Win64" .. -DTESTS=On -DBoost_USE_STATIC_RUNTIME=OFF
6363
build_script:
6464
- msbuild solidity.sln /p:Configuration=%CONFIGURATION% /m:%NUMBER_OF_PROCESSORS% /v:minimal
6565
- cd %APPVEYOR_BUILD_FOLDER%

cmake/EthDependencies.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ set(ETH_SCRIPTS_DIR ${ETH_CMAKE_DIR}/scripts)
2525
## use multithreaded boost libraries, with -mt suffix
2626
set(Boost_USE_MULTITHREADED ON)
2727
option(Boost_USE_STATIC_LIBS "Link Boost statically" ON)
28+
if(WIN32)
29+
option(Boost_USE_STATIC_RUNTIME "Link Boost against static C++ runtime libraries" ON)
30+
endif()
2831

2932
set(BOOST_COMPONENTS "filesystem;unit_test_framework;program_options;system")
3033

cmake/EthPolicy.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ macro (eth_policy)
1515
# do not interpret if() arguments as variables!
1616
cmake_policy(SET CMP0054 NEW)
1717
endif()
18-
endmacro()
1918

19+
if (POLICY CMP0091)
20+
# Allow selecting MSVC runtime library using CMAKE_MSVC_RUNTIME_LIBRARY.
21+
cmake_policy(SET CMP0091 NEW)
22+
endif()
23+
endmacro()

cmake/jsoncpp.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ if(CMAKE_VERSION VERSION_GREATER 3.1)
3434
set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}")
3535
endif()
3636

37+
# Propagate CMAKE_MSVC_RUNTIME_LIBRARY on Windows builds, if set.
38+
if (WIN32 AND POLICY CMP0091 AND CMAKE_MSVC_RUNTIME_LIBRARY)
39+
list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW")
40+
list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
41+
endif()
42+
3743
ExternalProject_Add(jsoncpp-project
3844
PREFIX "${prefix}"
3945
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
@@ -51,6 +57,7 @@ ExternalProject_Add(jsoncpp-project
5157
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
5258
-DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS}
5359
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
60+
${JSONCPP_CMAKE_ARGS}
5461
${byproducts}
5562
)
5663

scripts/install_deps.ps1

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Needed for Invoke-WebRequest to work via CI.
2+
$progressPreference = "silentlyContinue"
3+
4+
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\..\deps"
5+
6+
Invoke-WebRequest -URI "https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-win64-x64.zip" -OutFile cmake.zip
7+
tar -xf cmake.zip
8+
mv cmake-3.18.2-win64-x64 "$PSScriptRoot\..\deps\cmake"
9+
10+
Invoke-WebRequest -URI "https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.zip" -OutFile boost.zip
11+
tar -xf boost.zip
12+
cd boost_1_74_0
13+
.\bootstrap.bat
14+
.\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
15+
cd ..

0 commit comments

Comments
 (0)