Revert "build(deps): migrate from curl to curl-winssl on Windows (#3246)"

This reverts commit 9cc8bc8f62, should resolve #91
This commit is contained in:
Yukino Song
2024-10-31 17:43:41 +08:00
parent dcbed39f30
commit d91b86b4e1
3 changed files with 36 additions and 32 deletions

View File

@@ -2,35 +2,43 @@
set -e set -e
# update pacman # update pacman
pacman --noconfirm -Syu pacman --noconfirm -Suy
# install wget
pacman --noconfirm -S \
wget
# download working curl
wget https://repo.msys2.org/mingw/ucrt64/mingw-w64-ucrt-x86_64-curl-8.8.0-1-any.pkg.tar.zst
# install dependencies # install dependencies
dependencies=( pacman -U --noconfirm mingw-w64-ucrt-x86_64-curl-8.8.0-1-any.pkg.tar.zst
"git" pacman -Syu --noconfirm --ignore=mingw-w64-ucrt-x86_64-curl \
"mingw-w64-ucrt-x86_64-boost" base-devel \
"mingw-w64-ucrt-x86_64-cmake" diffutils \
"mingw-w64-ucrt-x86_64-cppwinrt" gcc \
"mingw-w64-ucrt-x86_64-curl-winssl" git \
"mingw-w64-ucrt-x86_64-miniupnpc" make \
"mingw-w64-ucrt-x86_64-nlohmann-json" mingw-w64-ucrt-x86_64-cmake \
"mingw-w64-ucrt-x86_64-nodejs" mingw-w64-ucrt-x86_64-cppwinrt \
"mingw-w64-ucrt-x86_64-nsis" mingw-w64-ucrt-x86_64-graphviz \
"mingw-w64-ucrt-x86_64-onevpl" mingw-w64-ucrt-x86_64-miniupnpc \
"mingw-w64-ucrt-x86_64-openssl" mingw-w64-ucrt-x86_64-nlohmann-json \
"mingw-w64-ucrt-x86_64-opus" mingw-w64-ucrt-x86_64-nodejs \
"mingw-w64-ucrt-x86_64-toolchain" mingw-w64-ucrt-x86_64-nsis \
) mingw-w64-ucrt-x86_64-onevpl \
pacman -S --noconfirm "${dependencies[@]}" mingw-w64-ucrt-x86_64-openssl \
mingw-w64-ucrt-x86_64-opus \
mingw-w64-ucrt-x86_64-rust \
mingw-w64-ucrt-x86_64-toolchain
# build # build
mkdir -p build mkdir -p build
cd build || exit 1
cmake \ cmake \
-B build \
-G Ninja \
-S . \
-DBUILD_DOCS=OFF \ -DBUILD_DOCS=OFF \
-DBUILD_WERROR=ON -G "MinGW Makefiles" ..
ninja -C build mingw32-make -j"$(nproc)"
# skip autobuild # skip autobuild
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"

View File

@@ -88,7 +88,7 @@ dependencies=(
"mingw-w64-ucrt-x86_64-boost" # Optional "mingw-w64-ucrt-x86_64-boost" # Optional
"mingw-w64-ucrt-x86_64-cmake" "mingw-w64-ucrt-x86_64-cmake"
"mingw-w64-ucrt-x86_64-cppwinrt" "mingw-w64-ucrt-x86_64-cppwinrt"
"mingw-w64-ucrt-x86_64-curl-winssl" "mingw-w64-ucrt-x86_64-curl"
"mingw-w64-ucrt-x86_64-graphviz" # Optional, for docs "mingw-w64-ucrt-x86_64-graphviz" # Optional, for docs
"mingw-w64-ucrt-x86_64-miniupnpc" "mingw-w64-ucrt-x86_64-miniupnpc"
"mingw-w64-ucrt-x86_64-nlohmann-json" "mingw-w64-ucrt-x86_64-nlohmann-json"

View File

@@ -197,12 +197,7 @@ namespace http {
bool bool
download_file(const std::string &url, const std::string &file) { download_file(const std::string &url, const std::string &file) {
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
if (curl) { if (!curl) {
// sonar complains about weak ssl and tls versions
// ideally, the setopts should go after the early returns; however sonar cannot detect the fix
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
}
else {
BOOST_LOG(error) << "Couldn't create CURL instance"; BOOST_LOG(error) << "Couldn't create CURL instance";
return false; return false;
} }
@@ -220,16 +215,17 @@ namespace http {
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
return false; return false;
} }
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
#ifdef _WIN32
curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
#endif
CURLcode result = curl_easy_perform(curl); CURLcode result = curl_easy_perform(curl);
if (result != CURLE_OK) { if (result != CURLE_OK) {
BOOST_LOG(error) << "Couldn't download ["sv << url << ", code:" << result << ']'; BOOST_LOG(error) << "Couldn't download ["sv << url << ", code:" << result << ']';
} }
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
fclose(fp); fclose(fp);
return result == CURLE_OK; return result == CURLE_OK;