diff --git a/.circleci/config.yml b/.circleci/config.yml index 0891134a47..5cd0fd0c0e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,8 @@ version: 2.1 +orbs: + win: circleci/windows@1.0.0 + jobs: cmake_test: resource_class: xlarge @@ -24,6 +27,13 @@ jobs: - run: ./ci/install_bazelisk.sh - run: ./ci/do_ci.sh bazel.test + windows: + executor: win/vs2019 + steps: + - checkout + - run: ./ci/setup_windows_cmake.ps1 + - run: ./ci/setup_windows_ci_environment.ps1 + - run: ./ci/do_ci.ps1 cmake.test workflows: version: 2 @@ -31,3 +41,4 @@ workflows: jobs: - cmake_test - bazel_test + - windows diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 new file mode 100644 index 0000000000..585176c8fc --- /dev/null +++ b/ci/do_ci.ps1 @@ -0,0 +1,36 @@ +$ErrorActionPreference = "Stop"; +trap { $host.SetShouldExit(1) } + +$action = $args[0] + +$SRC_DIR=(Get-Item -Path ".\").FullName +mkdir build +$BUILD_DIR="$SRC_DIR\build" +$VCPKG_DIR="$SRC_DIR\vcpkg" + +switch ($action) { + "cmake.test" { + cd "$BUILD_DIR" + cmake $SRC_DIR ` + -DVCPKG_TARGET_TRIPLET=x64-windows ` + "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake" + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + cmake --build . + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + ctest -C Debug + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + } + default { + echo "unknown action: $action" + exit 1 + } +} diff --git a/ci/setup_windows_ci_environment.ps1 b/ci/setup_windows_ci_environment.ps1 new file mode 100755 index 0000000000..e9c2c51b09 --- /dev/null +++ b/ci/setup_windows_ci_environment.ps1 @@ -0,0 +1,9 @@ +$ErrorActionPreference = "Stop" +trap { $host.SetShouldExit(1) } + +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +$VCPKG_DIR=(Get-Item -Path ".\").FullName +./bootstrap-vcpkg.bat +./vcpkg integrate install +./vcpkg install gtest:x64-windows diff --git a/ci/setup_windows_cmake.ps1 b/ci/setup_windows_cmake.ps1 new file mode 100755 index 0000000000..3248b4c722 --- /dev/null +++ b/ci/setup_windows_cmake.ps1 @@ -0,0 +1,17 @@ +$ErrorActionPreference = "Stop" +trap { $host.SetShouldExit(1) } + +$CMAKE_VERSION="3.15.2" +$CWD=(Get-Item -Path ".\").FullName +(new-object System.Net.WebClient). ` + DownloadFile("https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-win64-x64.zip", ` + "$CWD\cmake-$CMAKE_VERSION-win64-x64.zip") + +unzip cmake-$CMAKE_VERSION-win64-x64.zip + +$ENV:PATH="$ENV:PATH;$CWD\cmake-$CMAKE_VERSION-win64-x64\bin" +cmake --help +[Environment]::SetEnvironmentVariable( + "Path", + [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";$CWD\cmake-$CMAKE_VERSION-win64-x64\bin", + [EnvironmentVariableTarget]::Machine)