Skip to content

Commit 22e8132

Browse files
committed
Patch minio-cpp and curlpp in vcpkg
1 parent c9d60b3 commit 22e8132

12 files changed

Lines changed: 269 additions & 3 deletions

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ if (NOT CMAKE_TOOLCHAIN_FILE)
2323
endif ()
2424
endif ()
2525

26+
set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_SOURCE_DIR}/custom_ports"
27+
CACHE STRING "Custom vcpkg ports")
28+
2629
project(infinity VERSION 0.6.11)
2730

2831
set(CMAKE_CXX_STANDARD 23)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- a/include/curlpp/Multi.hpp
2+
+++ b/include/curlpp/Multi.hpp
3+
@@ -62,6 +62,10 @@
4+
fd_set * exc_fd_set,
5+
int * max_fd);
6+
7+
+ void timeout(long * curl_timeo){
8+
+ curl_multi_timeout(mMultiHandle, curl_timeo);
9+
+ }
10+
+
11+
typedef std::list<std::pair<const curlpp::Easy *, Multi::Info> >
12+
Msgs;
13+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 8b183a0..a801ae8 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -85,11 +85,12 @@ endif()
6+
7+
file(GLOB_RECURSE HeaderFileList "${CMAKE_CURRENT_SOURCE_DIR}/include/*")
8+
file(GLOB_RECURSE SourceFileList "${CMAKE_CURRENT_SOURCE_DIR}/src/*")
9+
+if(BUILD_SHARED_LIBS)
10+
add_library(${PROJECT_NAME} SHARED ${HeaderFileList} ${SourceFileList})
11+
target_link_libraries(${PROJECT_NAME} ${CURL_LIBRARIES} ${CONAN_LIBS})
12+
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 1 VERSION 1.0.0)
13+
-
14+
-add_library(${PROJECT_NAME}_static STATIC ${HeaderFileList} ${SourceFileList})
15+
+else()
16+
+add_library(${PROJECT_NAME} STATIC ${HeaderFileList} ${SourceFileList})
17+
18+
# Make sure that on unix-platforms shared and static libraries have
19+
# the same root name, but different suffixes.
20+
@@ -97,19 +98,28 @@ add_library(${PROJECT_NAME}_static STATIC ${HeaderFileList} ${SourceFileList})
21+
# (solution taken from https://cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F)
22+
#
23+
# Making shared and static libraries have the same root name, but different suffixes
24+
-SET_TARGET_PROPERTIES(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
25+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
26+
# Now the library target "curlpp_static" will be named "curlpp.lib" with MS tools.
27+
# This conflicts with the "curlpp.lib" import library corresponding to "curlpp.dll",
28+
# so we add a "lib" prefix (which is default on other platforms anyway):
29+
-SET_TARGET_PROPERTIES(${PROJECT_NAME}_static PROPERTIES PREFIX "lib")
30+
-target_link_libraries(${PROJECT_NAME}_static ${CURL_LIBRARIES} ${CONAN_LIBS})
31+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "lib")
32+
+target_link_libraries(${PROJECT_NAME} CURL::libcurl)
33+
+endif()
34+
+
35+
+target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
36+
37+
# install headers
38+
install(DIRECTORY include/utilspp/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/utilspp")
39+
install(DIRECTORY include/curlpp/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/curlpp")
40+
41+
-install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_static
42+
+install(TARGETS ${PROJECT_NAME}
43+
+ EXPORT ${PROJECT_NAME}-config
44+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
45+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
46+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
47+
48+
+install(EXPORT ${PROJECT_NAME}-config
49+
+ FILE unofficial-${PROJECT_NAME}-config.cmake
50+
+ NAMESPACE unofficial::${PROJECT_NAME}::
51+
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
52+
+)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index c42943c..12d402c 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -1,3 +1,4 @@
6+
+cmake_minimum_required(VERSION 2.8)
7+
project(curlpp)
8+
9+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/include/curlpp/Options.hpp b/include/curlpp/Options.hpp
2+
index c705c9d..a658752 100644
3+
--- a/include/curlpp/Options.hpp
4+
+++ b/include/curlpp/Options.hpp
5+
@@ -278,7 +278,9 @@ namespace options
6+
typedef curlpp::OptionTrait<long, CURLOPT_LOW_SPEED_LIMIT> LowSpeedLimit;
7+
typedef curlpp::OptionTrait<long, CURLOPT_LOW_SPEED_TIME> LowSpeedTime;
8+
typedef curlpp::OptionTrait<long, CURLOPT_MAXCONNECTS> MaxConnects;
9+
+#if LIBCURL_VERSION_NUM < 0x080a00
10+
typedef curlpp::OptionTrait<curl_closepolicy, CURLOPT_CLOSEPOLICY> ClosePolicy;
11+
+#endif
12+
typedef curlpp::OptionTrait<bool, CURLOPT_FRESH_CONNECT> FreshConnect;
13+
typedef curlpp::OptionTrait<bool, CURLOPT_FORBID_REUSE> ForbidReuse;
14+
typedef curlpp::OptionTrait<long, CURLOPT_CONNECTTIMEOUT> ConnectTimeout;

custom_ports/curlpp/portfile.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
vcpkg_from_github(
2+
OUT_SOURCE_PATH SOURCE_PATH
3+
REPO jpbarrette/curlpp
4+
REF 8810334c830faa3b38bcd94f5b1ab695a4f05eb9
5+
SHA512 47eb0738d7cd2d4262c455f9472a21535343bcf08bda6de19771dab9204e068272b41782c87057d50e3781683a29e79d6387577be68d175a7fa890367f15d0d2
6+
HEAD_REF master
7+
PATCHES
8+
fix-cmake.patch
9+
fix-findzliberror.patch
10+
obsolete-curlopt.diff
11+
fix-Multi_hpp.patch
12+
)
13+
14+
vcpkg_cmake_configure(
15+
SOURCE_PATH "${SOURCE_PATH}"
16+
)
17+
18+
vcpkg_cmake_install()
19+
20+
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT} PACKAGE_NAME unofficial-${PORT})
21+
22+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
23+
24+
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
25+
file(REMOVE_RECURSE
26+
"${CURRENT_PACKAGES_DIR}/bin"
27+
"${CURRENT_PACKAGES_DIR}/debug/bin"
28+
)
29+
endif()
30+
31+
if(VCPKG_TARGET_IS_WINDOWS AND NOT (VCPKG_LIBRARY_LINKAGE STREQUAL static))
32+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/bin/curlpp-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/..")
33+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/bin/curlpp-config" "${CURRENT_INSTALLED_DIR}" "$(prefix)" IGNORE_UNCHANGED)
34+
if(NOT VCPKG_BUILD_TYPE)
35+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/bin/curlpp-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/../..")
36+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/bin/curlpp-config" "${CURRENT_INSTALLED_DIR}" "$(prefix)" IGNORE_UNCHANGED)
37+
endif()
38+
endif()
39+
40+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/unofficial-curlpp/unofficial-curlpp-config.cmake"
41+
"# Generated by CMake"
42+
[[# Generated by CMake
43+
include(CMakeFindDependencyMacro)
44+
find_dependency(CURL)]])
45+
46+
vcpkg_copy_pdbs()
47+
vcpkg_fixup_pkgconfig()
48+
49+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/doc/LICENSE")

custom_ports/curlpp/vcpkg.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "curlpp",
3+
"version-date": "2018-06-15",
4+
"port-version": 11,
5+
"description": "C++ wrapper around libcURL",
6+
"homepage": "https://github.com/jpbarrette/curlpp",
7+
"license": "MIT",
8+
"dependencies": [
9+
{
10+
"name": "curl",
11+
"default-features": false
12+
},
13+
{
14+
"name": "vcpkg-cmake",
15+
"host": true
16+
},
17+
{
18+
"name": "vcpkg-cmake-config",
19+
"host": true
20+
}
21+
]
22+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--- a/src/http.cc
2+
+++ b/src/http.cc
3+
@@ -428,20 +428,44 @@
4+
while (!requests.perform(&left)) {
5+
}
6+
while (left) {
7+
+ struct timeval timeout;
8+
fd_set fdread{};
9+
fd_set fdwrite{};
10+
fd_set fdexcep{};
11+
int maxfd = 0;
12+
+ long curl_timeo = -1;
13+
14+
FD_ZERO(&fdread);
15+
FD_ZERO(&fdwrite);
16+
FD_ZERO(&fdexcep);
17+
18+
+ /* set a suitable timeout to play around with */
19+
+ timeout.tv_sec = 1;
20+
+ timeout.tv_usec = 0;
21+
+ requests.timeout(&curl_timeo);
22+
+ if(curl_timeo >= 0) {
23+
+ timeout.tv_sec = curl_timeo / 1000;
24+
+ if(timeout.tv_sec > 1)
25+
+ timeout.tv_sec = 1;
26+
+ else
27+
+ timeout.tv_usec = (int)(curl_timeo % 1000) * 1000;
28+
+ }
29+
+
30+
requests.fdset(&fdread, &fdwrite, &fdexcep, &maxfd);
31+
32+
- if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, nullptr) < 0) {
33+
- std::cerr << "select() failed; this should not happen" << std::endl;
34+
- std::terminate();
35+
+ if(maxfd == -1) {
36+
+#ifdef _WIN32
37+
+ Sleep(100);
38+
+#else
39+
+ /* Portable sleep for platforms other than Windows. */
40+
+ struct timeval wait = { 0, 100 * 1000 }; /* 100ms */
41+
+ select(0, NULL, NULL, NULL, &wait);
42+
+#endif
43+
+ } else {
44+
+ if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) < 0) {
45+
+ std::cerr << "select() failed; this should not happen" << std::endl;
46+
+ std::terminate();
47+
+ }
48+
}
49+
while (!requests.perform(&left)) {
50+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
vcpkg_from_github(
2+
OUT_SOURCE_PATH SOURCE_PATH
3+
REPO minio/minio-cpp
4+
REF "v${VERSION}"
5+
SHA512 c0748e757513aea394f76a0286294e668421096bfa64892d66aef69d611bcbda7c4ccf9d4df2502a9a92206b613c7d27011f4c9948e25b286feff8b64c952b1e
6+
HEAD_REF main
7+
PATCHES
8+
fix-http_cc.patch
9+
)
10+
11+
vcpkg_cmake_configure(
12+
SOURCE_PATH "${SOURCE_PATH}"
13+
DISABLE_PARALLEL_CONFIGURE
14+
)
15+
16+
vcpkg_cmake_install()
17+
vcpkg_cmake_config_fixup(PACKAGE_NAME miniocpp CONFIG_PATH "lib/cmake/miniocpp")
18+
19+
vcpkg_copy_pdbs()
20+
vcpkg_fixup_pkgconfig()
21+
22+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
23+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

custom_ports/minio-cpp/vcpkg.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "minio-cpp",
3+
"version": "0.3.0",
4+
"description": "The MinIO C++ Client SDK provides simple APIs to access any Amazon S3 compatible object storage",
5+
"homepage": "https://github.com/minio/minio-cpp",
6+
"license": "Apache-2.0",
7+
"supports": "!uwp",
8+
"dependencies": [
9+
"curlpp",
10+
{
11+
"name": "inih",
12+
"features": [
13+
"cpp"
14+
]
15+
},
16+
"nlohmann-json",
17+
"openssl",
18+
"pugixml",
19+
{
20+
"name": "vcpkg-cmake",
21+
"host": true
22+
},
23+
{
24+
"name": "vcpkg-cmake-config",
25+
"host": true
26+
},
27+
"zlib"
28+
]
29+
}

0 commit comments

Comments
 (0)