Skip to content

Commit

Permalink
Add windows ci. (#18)
Browse files Browse the repository at this point in the history
* Add windows ci.

* Don't build shared libraries.

* Use dynamic gtest.

* Change target.

* Run cmake tests on windows.

* Invoke tests.
  • Loading branch information
rnburn authored Jan 3, 2020
1 parent 9b0925b commit b61d5fb
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: 2.1

orbs:
win: circleci/windows@1.0.0

jobs:
cmake_test:
resource_class: xlarge
Expand All @@ -24,10 +27,18 @@ 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
build_and_test:
jobs:
- cmake_test
- bazel_test
- windows
36 changes: 36 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
9 changes: 9 additions & 0 deletions ci/setup_windows_ci_environment.ps1
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions ci/setup_windows_cmake.ps1
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b61d5fb

Please sign in to comment.