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-v34-Win64' 33else 34 openssl_root_win='C:/OpenSSL-v111-Win64' 35fi 36openssl_root="$(cygpath "${openssl_root_win}")" 37 38if [ "${BUILD_SYSTEM}" = 'CMake' ]; then 39 options='' 40 [[ "${TARGET:-}" = *'ARM64'* ]] && SKIP_RUN='ARM64 architecture' 41 [ -n "${TOOLSET:-}" ] && options+=" -T ${TOOLSET}" 42 [ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}" 43 [ -n "${CURLDEBUG:-}" ] && options+=" -DENABLE_CURLDEBUG=${CURLDEBUG}" 44 [ "${PRJ_CFG}" = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=' 45 [ "${PRJ_CFG}" = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=' 46 [[ "${PRJ_GEN}" = *'Visual Studio'* ]] && options+=' -DCMAKE_VS_GLOBALS=TrackFileAccess=false' 47 # shellcheck disable=SC2086 48 cmake -B _bld "-G${PRJ_GEN}" ${TARGET:-} ${options} \ 49 "-DCURL_USE_OPENSSL=${OPENSSL}" \ 50 "-DCURL_USE_SCHANNEL=${SCHANNEL}" \ 51 "-DHTTP_ONLY=${HTTP_ONLY}" \ 52 "-DBUILD_SHARED_LIBS=${SHARED}" \ 53 "-DCMAKE_UNITY_BUILD=${UNITY}" \ 54 '-DCURL_TEST_BUNDLES=ON' \ 55 '-DCURL_WERROR=ON' \ 56 "-DENABLE_DEBUG=${DEBUG}" \ 57 "-DENABLE_UNICODE=${ENABLE_UNICODE}" \ 58 '-DCMAKE_INSTALL_PREFIX=C:/curl' \ 59 "-DCMAKE_BUILD_TYPE=${PRJ_CFG}" \ 60 '-DCURL_USE_LIBPSL=OFF' 61 if false; then 62 cat _bld/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true 63 fi 64 echo 'curl_config.h'; grep -F '#define' _bld/lib/curl_config.h | sort || true 65 # shellcheck disable=SC2086 66 cmake --build _bld --config "${PRJ_CFG}" --parallel 2 -- ${BUILD_OPT:-} 67 [ "${SHARED}" = 'ON' ] && PATH="$PWD/_bld/lib:$PATH" 68 [ "${OPENSSL}" = 'ON' ] && PATH="${openssl_root}:$PATH" 69 curl='_bld/src/curl.exe' 70elif [ "${BUILD_SYSTEM}" = 'VisualStudioSolution' ]; then 71 ( 72 cd projects 73 ./generate.bat "${VC_VERSION}" 74 msbuild.exe -maxcpucount "-property:Configuration=${PRJ_CFG}" "Windows/${VC_VERSION}/curl-all.sln" 75 ) 76 curl="build/Win32/${VC_VERSION}/${PRJ_CFG}/curld.exe" 77elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2015' ]; then 78 ( 79 cd winbuild 80 cat << EOF > _make.bat 81 call "C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin/SetEnv.cmd" /x64 82 call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" x86_amd64 83 nmake -f Makefile.vc mode=dll VC=14 "SSL_PATH=${openssl_root_win}" WITH_SSL=dll MACHINE=x64 DEBUG=${DEBUG} ENABLE_UNICODE=${ENABLE_UNICODE} WINBUILD_ACKNOWLEDGE_DEPRECATED=yes 84EOF 85 ./_make.bat 86 rm _make.bat 87 ) 88 curl="builds/libcurl-vc14-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe" 89elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2017' ]; then 90 ( 91 cd winbuild 92 cat << EOF > _make.bat 93 call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat" 94 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} WINBUILD_ACKNOWLEDGE_DEPRECATED=yes 95EOF 96 ./_make.bat 97 rm _make.bat 98 ) 99 curl="builds/libcurl-vc14.10-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe" 100fi 101 102find . \( -name '*.exe' -o -name '*.dll' -o -name '*.lib' \) -exec file '{}' \; 103if [ -z "${SKIP_RUN:-}" ]; then 104 "${curl}" --disable --version 105else 106 echo "Skip running curl.exe. Reason: ${SKIP_RUN}" 107fi 108 109# build tests 110 111if [ "${TFLAGS}" != 'skipall' ] && \ 112 [ "${BUILD_SYSTEM}" = 'CMake' ]; then 113 cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --target testdeps 114fi 115 116# run tests 117 118if [ "${TFLAGS}" != 'skipall' ] && \ 119 [ "${TFLAGS}" != 'skiprun' ]; then 120 if [ -x "$(cygpath "${SYSTEMROOT}/System32/curl.exe")" ]; then 121 TFLAGS+=" -ac $(cygpath "${SYSTEMROOT}/System32/curl.exe")" 122 elif [ -x "$(cygpath 'C:/msys64/usr/bin/curl.exe')" ]; then 123 TFLAGS+=" -ac $(cygpath 'C:/msys64/usr/bin/curl.exe')" 124 fi 125 TFLAGS+=' -j0' 126 if [ "${BUILD_SYSTEM}" = 'CMake' ]; then 127 cmake --build _bld --config "${PRJ_CFG}" --target test-ci 128 else 129 ( 130 TFLAGS="-a -p !flaky -r -rm ${TFLAGS}" 131 cd _bld/tests 132 ./runtests.pl 133 ) 134 fi 135fi 136 137# build examples 138 139if [ "${EXAMPLES}" = 'ON' ] && \ 140 [ "${BUILD_SYSTEM}" = 'CMake' ]; then 141 cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --target curl-examples 142fi 143