xref: /curl/appveyor.sh (revision fb711b50)
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-v33-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  if [ "${PRJ_GEN}" = 'Visual Studio 9 2008' ]; then
48    [ "${DEBUG}" = 'ON' ] && [ "${SHARED}" = 'ON' ] && SKIP_RUN='Crash on startup in ENABLE_DEBUG=ON shared builds'
49    # Fails to run without this due to missing MSVCR90.dll / MSVCR90D.dll
50    options+=' -DCURL_STATIC_CRT=ON'
51  fi
52  # shellcheck disable=SC2086
53  cmake -B _bld "-G${PRJ_GEN}" ${TARGET:-} ${options} \
54    "-DCURL_USE_OPENSSL=${OPENSSL}" \
55    "-DCURL_USE_SCHANNEL=${SCHANNEL}" \
56    "-DHTTP_ONLY=${HTTP_ONLY}" \
57    "-DBUILD_SHARED_LIBS=${SHARED}" \
58    "-DCMAKE_UNITY_BUILD=${UNITY}" \
59    '-DCURL_TEST_BUNDLES=ON' \
60    '-DCURL_WERROR=ON' \
61    "-DENABLE_DEBUG=${DEBUG}" \
62    "-DENABLE_UNICODE=${ENABLE_UNICODE}" \
63    '-DCMAKE_INSTALL_PREFIX=C:/curl' \
64    "-DCMAKE_BUILD_TYPE=${PRJ_CFG}" \
65    '-DCURL_USE_LIBPSL=OFF'
66  if false; then
67    cat _bld/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
68  fi
69  echo 'curl_config.h'; grep -F '#define' _bld/lib/curl_config.h | sort || true
70  # shellcheck disable=SC2086
71  if ! cmake --build _bld --config "${PRJ_CFG}" --parallel 2 -- ${BUILD_OPT:-}; then
72    if [ "${PRJ_GEN}" = 'Visual Studio 9 2008' ]; then
73      find . -name BuildLog.htm -exec dos2unix '{}' +
74      find . -name BuildLog.htm -exec cat '{}' +
75    fi
76    false
77  fi
78  if [ "${SHARED}" = 'ON' ]; then
79    PATH="$PWD/_bld/lib:$PATH"
80  fi
81  if [ "${OPENSSL}" = 'ON' ]; then
82    PATH="$PWD/_bld/lib:${openssl_root}:$PATH"
83  fi
84  curl='_bld/src/curl.exe'
85elif [ "${BUILD_SYSTEM}" = 'VisualStudioSolution' ]; then
86  (
87    cd projects
88    ./generate.bat "${VC_VERSION}"
89    msbuild.exe -maxcpucount "-property:Configuration=${PRJ_CFG}" "Windows/${VC_VERSION}/curl-all.sln"
90  )
91  curl="build/Win32/${VC_VERSION}/${PRJ_CFG}/curld.exe"
92elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2015' ]; then
93  ./buildconf.bat
94  (
95    cd winbuild
96    cat << EOF > _make.bat
97      call "C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin/SetEnv.cmd" /x64
98      call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" x86_amd64
99      nmake -f Makefile.vc mode=dll VC=14 "SSL_PATH=${openssl_root_win}" WITH_SSL=dll MACHINE=x64 DEBUG=${DEBUG} ENABLE_UNICODE=${ENABLE_UNICODE}
100EOF
101    ./_make.bat
102    rm _make.bat
103  )
104  curl="builds/libcurl-vc14-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe"
105elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2017' ]; then
106  ./buildconf.bat
107  (
108    cd winbuild
109    cat << EOF > _make.bat
110      call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat"
111      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}
112EOF
113    ./_make.bat
114    rm _make.bat
115  )
116  curl="builds/libcurl-vc14.10-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe"
117fi
118
119find . -name '*.exe' -o -name '*.dll'
120if [ -z "${SKIP_RUN:-}" ]; then
121  "${curl}" --disable --version
122else
123  echo "Skip running curl.exe. Reason: ${SKIP_RUN}"
124fi
125
126# build tests
127
128if [[ "${TFLAGS}" != 'skipall' ]] && \
129   [ "${BUILD_SYSTEM}" = 'CMake' ]; then
130  cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --target testdeps
131fi
132
133# run tests
134
135if [[ "${TFLAGS}" != 'skipall' ]] && \
136   [[ "${TFLAGS}" != 'skiprun' ]]; then
137  if [ -x "$(cygpath "${SYSTEMROOT}/System32/curl.exe")" ]; then
138    TFLAGS+=" -ac $(cygpath "${SYSTEMROOT}/System32/curl.exe")"
139  elif [ -x "$(cygpath 'C:/msys64/usr/bin/curl.exe')" ]; then
140    TFLAGS+=" -ac $(cygpath 'C:/msys64/usr/bin/curl.exe')"
141  fi
142  TFLAGS+=' -j0'
143  if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
144    cmake --build _bld --config "${PRJ_CFG}" --target test-ci
145  else
146    (
147      TFLAGS="-a -p !flaky -r -rm ${TFLAGS}"
148      cd _bld/tests
149      ./runtests.pl
150    )
151  fi
152fi
153
154# build examples
155
156if [[ "${EXAMPLES}" = 'ON' ]] && \
157   [ "${BUILD_SYSTEM}" = 'CMake' ]; then
158  cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --target curl-examples
159fi
160