appveyor.sh 5.7 KB

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