appveyor.sh 5.6 KB

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