1#!/usr/bin/env bash 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 10# 11# This software is licensed as described in the file COPYING, which 12# you should have received as part of this distribution. The terms 13# are also available at https://curl.se/docs/copyright.html. 14# 15# You may opt to use, copy, modify, merge, publish, distribute and/or sell 16# copies of the Software, and permit persons to whom the Software is 17# furnished to do so, under the terms of the COPYING file. 18# 19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20# KIND, either express or implied. 21# 22# SPDX-License-Identifier: curl 23# 24########################################################################### 25 26# shellcheck disable=SC3040,SC2039 27set -eux; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail 28 29# build 30 31if [ "${APPVEYOR_BUILD_WORKER_IMAGE}" = 'Visual Studio 2022' ]; then 32 openssl_root_win='C:/OpenSSL-v32-Win64' 33else 34 openssl_root_win='C:/OpenSSL-v111-Win64' 35fi 36openssl_root="$(cygpath -u "${openssl_root_win}")" 37 38if [ "${BUILD_SYSTEM}" = 'CMake' ]; then 39 options='' 40 [[ "${TARGET:-}" = *'ARM64'* ]] && SKIP_RUN='ARM64 architecture' 41 [ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}" 42 [ "${PRJ_CFG}" = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=' 43 [ "${PRJ_CFG}" = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=' 44 [[ "${PRJ_GEN}" = *'Visual Studio'* ]] && options+=' -DCMAKE_VS_GLOBALS=TrackFileAccess=false' 45 if [ "${PRJ_GEN}" = 'Visual Studio 9 2008' ]; then 46 [ "${PRJ_CFG}" = 'Debug' ] && [ "${DEBUG}" = 'ON' ] && [ "${SHARED}" = 'ON' ] && SKIP_RUN='Crash on startup in -DDEBUGBUILD shared builds' 47 # Fails to run without this due to missing MSVCR90.dll / MSVCR90D.dll 48 options+=' -DCURL_STATIC_CRT=ON' 49 fi 50 # shellcheck disable=SC2086 51 cmake -B _bld "-G${PRJ_GEN}" ${TARGET:-} ${options} \ 52 "-DCURL_USE_OPENSSL=${OPENSSL}" \ 53 "-DCURL_USE_SCHANNEL=${SCHANNEL}" \ 54 "-DHTTP_ONLY=${HTTP_ONLY}" \ 55 "-DBUILD_SHARED_LIBS=${SHARED}" \ 56 "-DBUILD_TESTING=${TESTING}" \ 57 "-DENABLE_WEBSOCKETS=${WEBSOCKETS:-}" \ 58 "-DCMAKE_UNITY_BUILD=${UNITY}" \ 59 '-DCURL_WERROR=ON' \ 60 "-DENABLE_DEBUG=${DEBUG}" \ 61 "-DENABLE_UNICODE=${ENABLE_UNICODE}" \ 62 '-DCMAKE_INSTALL_PREFIX=C:/curl' \ 63 "-DCMAKE_BUILD_TYPE=${PRJ_CFG}" 64 # shellcheck disable=SC2086 65 cmake --build _bld --config "${PRJ_CFG}" --parallel 2 -- ${BUILD_OPT:-} 66 if [ "${SHARED}" = 'ON' ]; then 67 cp -f -p _bld/lib/*.dll _bld/src/ 68 fi 69 if [ "${OPENSSL}" = 'ON' ]; then 70 cp -f -p "${openssl_root}"/*.dll _bld/src/ 71 fi 72 curl='_bld/src/curl.exe' 73elif [ "${BUILD_SYSTEM}" = 'VisualStudioSolution' ]; then 74 ( 75 cd projects 76 ./generate.bat "${VC_VERSION}" 77 msbuild.exe -maxcpucount "-property:Configuration=${PRJ_CFG}" "Windows/${VC_VERSION}/curl-all.sln" 78 ) 79 curl="build/Win32/${VC_VERSION}/${PRJ_CFG}/curld.exe" 80elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2015' ]; then 81 ./buildconf.bat 82 ( 83 cd winbuild 84 cat << EOF > _make.bat 85 call "C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin/SetEnv.cmd" /x64 86 call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" x86_amd64 87 nmake -f Makefile.vc mode=dll VC=14 "SSL_PATH=${openssl_root_win}" WITH_SSL=dll MACHINE=x64 DEBUG=${DEBUG} ENABLE_UNICODE=${ENABLE_UNICODE} 88EOF 89 ./_make.bat 90 rm _make.bat 91 ) 92 curl="builds/libcurl-vc14-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe" 93elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2017' ]; then 94 ./buildconf.bat 95 ( 96 cd winbuild 97 cat << EOF > _make.bat 98 call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat" 99 nmake -f Makefile.vc mode=dll VC=14.10 "SSL_PATH=${openssl_root_win}" WITH_SSL=dll MACHINE=x64 DEBUG=${DEBUG} ENABLE_UNICODE=${ENABLE_UNICODE} ENABLE_WEBSOCKETS=yes 100EOF 101 ./_make.bat 102 rm _make.bat 103 ) 104 curl="builds/libcurl-vc14.10-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe" 105fi 106 107find . -name '*.exe' -o -name '*.dll' 108if [ -z "${SKIP_RUN:-}" ]; then 109 "${curl}" --disable --version 110else 111 echo "Skip running curl.exe. Reason: ${SKIP_RUN}" 112fi 113 114if false; then 115 for log in CMakeFiles/CMakeConfigureLog.yaml CMakeFiles/CMakeOutput.log CMakeFiles/CMakeError.log; do 116 [ -r "_bld/${log}" ] && cat "_bld/${log}" 117 done 118fi 119 120# test 121 122if [ "${TESTING}" = 'ON' ]; then 123 export TFLAGS='' 124 if [ -x "$(cygpath -u "${WINDIR}/System32/curl.exe")" ]; then 125 TFLAGS+=" -ac $(cygpath -u "${WINDIR}/System32/curl.exe")" 126 elif [ -x "$(cygpath -u 'C:/msys64/usr/bin/curl.exe')" ]; then 127 TFLAGS+=" -ac $(cygpath -u 'C:/msys64/usr/bin/curl.exe')" 128 fi 129 TFLAGS+=" ${DISABLED_TESTS:-}" 130 if [ "${BUILD_SYSTEM}" = 'CMake' ]; then 131 cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --target testdeps 132 ls _bld/lib/*.dll >/dev/null 2>&1 && cp -f -p _bld/lib/*.dll _bld/tests/libtest/ 133 cmake --build _bld --config "${PRJ_CFG}" --target test-ci 134 else 135 ( 136 TFLAGS="-a -p !flaky -r -rm ${TFLAGS}" 137 cd _bld/tests 138 ./runtests.pl 139 ) 140 fi 141fi 142