1#!/bin/sh 2set -o igncr # Ignore CR in this script 3set -o xtrace # Write all commands first to stderr 4set -o errexit # Exit the script with error if any of the commands fail 5 6# Supported/used environment variables: 7# CC Which compiler to use 8# SSL Which SSL Library to use 9# SASL Enable or disable SASL 10# RELEASE Enable release-build MSVC flags (default: debug flags) 11 12 13INSTALL_DIR="C:/mongoc" 14CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DENABLE_AUTOMATIC_INIT_AND_CLEANUP:BOOL=OFF -DENABLE_MAINTAINER_FLAGS=ON" 15BUILD_FLAGS="/m" # Number of concurrent processes. No value=# of cpus 16CMAKE="/cygdrive/c/cmake/bin/cmake" 17CC=${CC:-"Visual Studio 14 2015 Win64"} 18 19echo "CC: $CC" 20echo "RELEASE: $RELEASE" 21 22if [ "$RELEASE" ]; then 23 # Build from the release tarball. 24 mkdir build-dir 25 tar xf ../mongoc.tar.gz -C build-dir --strip-components=1 26 cd build-dir 27else 28 git submodule update --init 29fi 30 31case "$SASL" in 32 no) 33 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SASL:BOOL=OFF" 34 ;; 35 sasl) 36 case "$CC" in 37 *Win64) 38 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SASL=CYRUS" 39 ;; 40 *) 41 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SASL:BOOL=OFF" 42 ;; 43 esac 44 ;; 45 sspi) 46 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SASL=SSPI" 47 ;; 48 *) 49 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SASL:BOOL=OFF" 50 ;; 51esac 52 53case "$SSL" in 54 openssl) 55 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SSL=OPENSSL" 56 ;; 57 winssl) 58 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SSL=WINDOWS" 59 ;; 60 no) 61 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SSL:BOOL=OFF" 62 ;; 63 *) 64 case "$CC" in 65 *Win64) 66 CONFIGURE_FLAGS="$CONFIGURE_FLAGS" 67 ;; 68 *) 69 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SSL:BOOL=OFF" 70 ;; 71 esac 72esac 73if [ ! -z "$ZLIB" ]; then 74 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_ZLIB=${ZLIB}" 75fi 76if [ ! -z "$SNAPPY" ]; then 77 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DENABLE_SNAPPY=${SNAPPY}" 78fi 79 80export CONFIGURE_FLAGS 81export INSTALL_DIR 82 83case "$CC" in 84 mingw*) 85 if [ "$RELEASE" ]; then 86 cmd.exe /c ..\\.evergreen\\compile-windows-mingw.bat 87 else 88 cmd.exe /c .evergreen\\compile-windows-mingw.bat 89 fi 90 exit 0 91 ;; 92 # Resolve the compiler name to correct MSBuild location 93 "Visual Studio 10 2010") 94 BUILD="/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe" 95 ;; 96 "Visual Studio 10 2010 Win64") 97 BUILD="/cygdrive/c/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe" 98 ;; 99 "Visual Studio 12 2013") 100 BUILD="/cygdrive/c/Program Files (x86)/MSBuild/12.0/Bin/MSBuild.exe" 101 ;; 102 "Visual Studio 12 2013 Win64") 103 BUILD="/cygdrive/c/Program Files (x86)/MSBuild/12.0/Bin/MSBuild.exe" 104 ;; 105 "Visual Studio 14 2015") 106 BUILD="/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin/MSBuild.exe" 107 ;; 108 "Visual Studio 14 2015 Win64") 109 BUILD="/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin/MSBuild.exe" 110 ;; 111esac 112 113if [ "$RELEASE" ]; then 114 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DCMAKE_BUILD_TYPE=Release" 115 BUILD_FLAGS="$BUILD_FLAGS /p:Configuration=Release" 116 TEST_PATH="./Release/test-libmongoc.exe" 117 export PATH=$PATH:`pwd`/tests:`pwd`/Release:`pwd`/src/libbson/Release 118else 119 CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DCMAKE_BUILD_TYPE=Debug" 120 BUILD_FLAGS="$BUILD_FLAGS /p:Configuration=Debug" 121 TEST_PATH="./Debug/test-libmongoc.exe" 122 export PATH=$PATH:`pwd`/tests:`pwd`/Debug:`pwd`/src/libbson/Debug 123fi 124 125# CMake can't compile against bundled libbson, so we have to 126# compile it and install it separately, and then configure mongoc 127# to build against the installed libbson 128cd src/libbson 129"$CMAKE" -G "$CC" $CONFIGURE_FLAGS 130"$BUILD" $BUILD_FLAGS ALL_BUILD.vcxproj 131"$BUILD" $BUILD_FLAGS INSTALL.vcxproj 132cd ../.. 133 134"$CMAKE" -G "$CC" "-DCMAKE_PREFIX_PATH=${INSTALL_DIR}/lib/cmake" $CONFIGURE_FLAGS 135"$BUILD" $BUILD_FLAGS ALL_BUILD.vcxproj 136"$BUILD" $BUILD_FLAGS INSTALL.vcxproj 137 138export MONGOC_TEST_FUTURE_TIMEOUT_MS=30000 139export MONGOC_TEST_SKIP_LIVE=on 140export MONGOC_TEST_SKIP_SLOW=on 141"$TEST_PATH" --no-fork -d -F test-results.json 142