Skip to content

Commit ea07dbe

Browse files
authored
Fix GitHub Actions (#1)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 0e09e03 commit ea07dbe

File tree

14 files changed

+90
-10
lines changed

14 files changed

+90
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
steps:
5858
- name: Install dependencies (GNU/Linux)
5959
if: runner.os == 'linux'
60-
run: sudo apt-get install --yes clang-format
60+
run: sudo apt-get install --yes clang-format libcurl4-openssl-dev
6161

6262
# See https://github.com/actions/runner-images/issues/8659
6363
- name: Workaround Clang issue (GNU/Linux)

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
cmake_minimum_required(VERSION 3.24)
2+
3+
# Needs to happen before the first call to "project()".
4+
if(WIN32)
5+
include(cmake/VCPKG.cmake)
6+
endif()
7+
28
project(hydra VERSION 0.0.1 LANGUAGES CXX
39
DESCRIPTION "A convenience networking library for modern C++")
410
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

cmake/Doxygen.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# TODO: Move this to Noa and also pull from JSON Toolkit
12
find_package(Doxygen)
23
if(DOXYGEN_FOUND)
34
set(DOXYGEN_IN "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in")

cmake/VCPKG.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# TODO: Move this to Noa
2+
if(DEFINED ENV{VCPKG_ROOT})
3+
set(VCPKG_CMAKE_TOOLCHAIN $ENV{VCPKG_ROOT})
4+
cmake_path(APPEND VCPKG_CMAKE_TOOLCHAIN scripts buildsystems vcpkg.cmake)
5+
else()
6+
# Attempt to find vcpkg from standard locations
7+
# Useful for GitHub Actions, which does not set VCPKG_ROOT
8+
find_file(VCPKG_CMAKE_TOOLCHAIN
9+
NAMES scripts/buildsystems/vcpkg.cmake
10+
PATHS C:/src/vcpkg C:/dev/vcpkg C:/vcpkg
11+
NO_DEFAULT_PATH)
12+
endif()
13+
if(EXISTS "${VCPKG_CMAKE_TOOLCHAIN}")
14+
message(STATUS "Using VCPKG toolchain: ${VCPKG_CMAKE_TOOLCHAIN}")
15+
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_CMAKE_TOOLCHAIN}" CACHE STRING "VCPKG toolchain file")
16+
else()
17+
message(FATAL_ERROR "Could NOT find VCPKG")
18+
endif()

config.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
88
find_package(Threads REQUIRED)
99
endif()
1010

11+
find_package(CURL REQUIRED)
1112
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_hydra_http.cmake")
1213
check_required_components("@PROJECT_NAME@")

doxygen/index.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ abstracts the gory details of making HTTP requests using
88
[`libcurl`](https://curl.se/libcurl/), including streaming.
99

1010
It targets C++20 and supports the Clang, GCC, and MSVC compilers on macOS,
11-
GNU/Linux, FreeBSD, Windows, and Unikraft, and it is designed to integrate well
12-
with other Sourcemeta libraries like [JSON
11+
GNU/Linux, Windows, and Unikraft, and it is designed to integrate well with
12+
other Sourcemeta libraries like [JSON
1313
Toolkit](https://jsontoolkit.sourcemeta.com).
1414

1515
Installation

src/http/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set_target_properties(sourcemeta_hydra_http PROPERTIES
2525
EXPORT_NAME hydra::http
2626
FOLDER "Hydra/HTTP")
2727

28-
target_link_libraries(sourcemeta_hydra_http PRIVATE curl)
28+
target_link_libraries(sourcemeta_hydra_http PRIVATE CURL::libcurl)
2929

3030
include(GenerateExportHeader)
3131
generate_export_header(sourcemeta_hydra_http

src/http/include/sourcemeta/hydra/http_error.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
namespace sourcemeta::hydra::http {
1515

16+
// Exporting symbols that depends on the standard C++ library is considered
17+
// safe.
18+
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
19+
#if defined(_MSC_VER)
20+
#pragma warning(disable : 4251 4275)
21+
#endif
22+
1623
class SOURCEMETA_HYDRA_HTTP_EXPORT Error : public std::exception {
1724
public:
1825
Error(std::string message) : message_{std::move(message)} {}
@@ -24,6 +31,10 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Error : public std::exception {
2431
std::string message_;
2532
};
2633

34+
#if defined(_MSC_VER)
35+
#pragma warning(default : 4251 4275)
36+
#endif
37+
2738
} // namespace sourcemeta::hydra::http
2839

2940
#endif

src/http/include/sourcemeta/hydra/http_request.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Request {
3030

3131
private:
3232
Stream stream;
33+
// Exporting symbols that depends on the standard C++ library is considered
34+
// safe.
35+
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
36+
#if defined(_MSC_VER)
37+
#pragma warning(disable : 4251)
38+
#endif
3339
std::set<std::string> capture_;
40+
#if defined(_MSC_VER)
41+
#pragma warning(default : 4251)
42+
#endif
3443
};
3544

3645
} // namespace sourcemeta::hydra::http

src/http/include/sourcemeta/hydra/http_response.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Response {
2828

2929
private:
3030
Status status_;
31+
// Exporting symbols that depends on the standard C++ library is considered
32+
// safe.
33+
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
34+
#if defined(_MSC_VER)
35+
#pragma warning(disable : 4251)
36+
#endif
3137
std::map<std::string, std::string> headers_;
3238
std::istringstream stream_;
39+
#if defined(_MSC_VER)
40+
#pragma warning(default : 4251)
41+
#endif
3342
};
3443

3544
} // namespace sourcemeta::hydra::http

src/http/include/sourcemeta/hydra/http_status.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#ifndef SOURCEMETA_HYDRA_HTTP_STATUS_H
22
#define SOURCEMETA_HYDRA_HTTP_STATUS_H
33

4+
#if defined(__EMSCRIPTEN__) || defined(__Unikraft__)
5+
#define SOURCEMETA_HYDRA_HTTP_EXPORT
6+
#else
7+
#include "http_export.h"
8+
#endif
9+
410
#include <cstdint> // std::uint16_t
511
#include <ostream> // std::ostream
612

@@ -81,7 +87,9 @@ enum class Status : std::uint16_t {
8187
NETWORK_AUTHENTICATION_REQUIRED = 511
8288
};
8389

84-
auto operator<<(std::ostream &stream, const Status value) -> std::ostream &;
90+
auto SOURCEMETA_HYDRA_HTTP_EXPORT operator<<(std::ostream &stream,
91+
const Status value)
92+
-> std::ostream &;
8593

8694
} // namespace sourcemeta::hydra::http
8795

src/http/include/sourcemeta/hydra/http_stream.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,16 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Stream {
5050
// No need to make this private, as the contents of `Internal`
5151
// are already hidden with the PIMPL idiom.
5252
public:
53+
// Exporting symbols that depends on the standard C++ library is considered
54+
// safe.
55+
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
56+
#if defined(_MSC_VER)
57+
#pragma warning(disable : 4251)
58+
#endif
5359
std::unique_ptr<Internal> internal;
60+
#if defined(_MSC_VER)
61+
#pragma warning(default : 4251)
62+
#endif
5463
};
5564

5665
} // namespace sourcemeta::hydra::http

src/http/stream_curl.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,17 @@ auto Stream::send() -> std::future<Status> {
223223
handle_curl(curl_easy_setopt(this->internal->handle,
224224
CURLOPT_CUSTOMREQUEST, "PUT"));
225225
break;
226+
227+
// Can't find it in the docs, but seems like MSVC defines
228+
// a DELETE macro that confuses this clause.
229+
#ifdef WIN32
230+
#pragma push_macro("DELETE")
231+
#undef DELETE
232+
#endif
226233
case Method::DELETE:
234+
#ifdef WIN32
235+
#pragma pop_macro("DELETE")
236+
#endif
227237
handle_curl(curl_easy_setopt(this->internal->handle,
228238
CURLOPT_CUSTOMREQUEST, "DELETE"));
229239
break;
@@ -254,11 +264,6 @@ auto Stream::send() -> std::future<Status> {
254264
handle_curl(curl_easy_setopt(this->internal->handle, CURLOPT_HTTPHEADER,
255265
this->internal->headers));
256266

257-
// This tells libcurl the maximum time any cached certificate store it has in
258-
// memory may be kept and reused for new connections.
259-
handle_curl(curl_easy_setopt(this->internal->handle, CURLOPT_CA_CACHE_TIMEOUT,
260-
604800L));
261-
262267
handle_curl(curl_easy_setopt(this->internal->handle, CURLOPT_WRITEFUNCTION,
263268
callback_on_body));
264269
handle_curl(

vcpkg.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dependencies": [ "curl" ]
3+
}

0 commit comments

Comments
 (0)