From 951bf416f403bff550102b4f16dc17c4432d391c Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sat, 23 Aug 2025 13:02:08 +0200 Subject: [PATCH] build: fix build failure with cpp-httplib >= 0.23 References: https://github.com/DescentDevelopers/Descent3/pull/721 --- BUILD.md | 2 +- Descent3/mission_download.cpp | 2 +- netcon/inetfile/httpclient.cpp | 4 ++-- netcon/inetfile/httpclient.h | 10 ++++++++-- vcpkg.json | 5 ++++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/BUILD.md b/BUILD.md index 0ed8b771..7782e0fe 100644 --- a/BUILD.md +++ b/BUILD.md @@ -4,7 +4,7 @@ ## Dependencies The build process uses [**CMake**](https://cmake.org/) and, by default, [**Ninja**](https://ninja-build.org/). You must install these; the project cannot locate them for you. The source code also depends on third-party libraries that are not provided as part of the repository: - [**SDL3**](https://wiki.libsdl.org/SDL3/FrontPage) which is used as the base to handle video, audio and input. -- [**cpp-httplib**](https://github.com/yhirose/cpp-httplib) as a HTTP client to download levels. +- [**cpp-httplib**](https://github.com/yhirose/cpp-httplib) >= 0.23 as a HTTP client to download levels. - [**glm**](https://github.com/g-truc/glm) providing useful additions to OpenGL. - [**plog**](https://github.com/SergiusTheBest/plog) for logging - [**zlib**](https://www.zlib.net/) as a compression utility diff --git a/Descent3/mission_download.cpp b/Descent3/mission_download.cpp index f494abe9..00263779 100644 --- a/Descent3/mission_download.cpp +++ b/Descent3/mission_download.cpp @@ -399,7 +399,7 @@ bool msn_DownloadWithStatus(const char *url, const std::filesystem::path &filena } httplib::Result (D3::HttpClient::*hcg)(const std::string &, const httplib::ContentReceiver &, - const httplib::Progress &) = &D3::HttpClient::Get; + const D3::HttpClient::Progress &) = &D3::HttpClient::Get; std::fstream in(qualfile, std::ios::binary | std::ios::trunc | std::ios::out); auto async_task = std::async( std::launch::async, hcg, &http_client, download_uri, diff --git a/netcon/inetfile/httpclient.cpp b/netcon/inetfile/httpclient.cpp index d15bc906..33c1e314 100644 --- a/netcon/inetfile/httpclient.cpp +++ b/netcon/inetfile/httpclient.cpp @@ -30,7 +30,7 @@ httplib::Result HttpClient::Get(const std::string &URIPath) { return m_client->Get(URIPath); } -httplib::Result HttpClient::Get(const std::string &URIPath, const httplib::Progress &progress) { +httplib::Result HttpClient::Get(const std::string &URIPath, const D3::HttpClient::Progress &progress) { return m_client->Get(URIPath, progress); } @@ -39,7 +39,7 @@ httplib::Result HttpClient::Get(const std::string &URIPath, const httplib::Conte } httplib::Result HttpClient::Get(const std::string &URIPath, const httplib::ContentReceiver &content_receiver, - const httplib::Progress &progress) { + const D3::HttpClient::Progress &progress) { return m_client->Get(URIPath, content_receiver, progress); } diff --git a/netcon/inetfile/httpclient.h b/netcon/inetfile/httpclient.h index d3e2499c..a373405e 100644 --- a/netcon/inetfile/httpclient.h +++ b/netcon/inetfile/httpclient.h @@ -32,6 +32,12 @@ namespace D3 { class HttpClient { public: + using Progress = httplib::DownloadProgress; + // no way to test with macro; would have to do a cmake-level compile check + //#if httplib < 0.23 + //using Progress = httplib::Progress; + //#endif + /** * Constructor for HttpClient * @param URL request URL, should be in form of http://example.com. Don't add "/" on the end as it's part of URIPath. @@ -46,12 +52,12 @@ public: * @param URIPath requested path (for example, "/some_dir/my_file.txt") * @return standard HTTP code. 200 means is OK. */ - httplib::Result Get(const std::string &URIPath, const httplib::Progress &progress); + httplib::Result Get(const std::string &URIPath, const Progress &progress); httplib::Result Get(const std::string &URIPath, const httplib::ContentReceiver &content_receiver); httplib::Result Get(const std::string &URIPath, const httplib::ContentReceiver &content_receiver, - const httplib::Progress &progress); + const Progress &progress); void SetProxy(const std::string &proxy_host, uint16_t port); diff --git a/vcpkg.json b/vcpkg.json index c383313e..b5e7f64c 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,10 @@ { "builtin-baseline": "8f90c294883ccf67d2f4953383718aeae981575f", "dependencies": [ - "cpp-httplib", + { + "name": "cpp-httplib", + "version>=": "0.23" + }, "glm", "gtest", "plog", -- 2.51.0