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