浏览代码

minio-cpp: add package (#5019)

* minio-cpp: add package

* remove pkgconf

* use pkgconfig to fix link order

* pkgconf: add msys & cygwin

* patch macosx

* add missing pacth

* remove msys patch

* openssl -> openssl3

* pixman: add 0.43.4 version & remove limit plat

* Revert "pixman: add 0.43.4 version & remove limit plat"

This reverts commit 3ef315df3ecc2e3b727e57dcda0f6322bb4b9b79.

* fix different openssl versison includedirs

* Revert "pkgconf: add msys & cygwin"

This reverts commit 44f35000c2e122b79765a41fecd8af8d15b4f393.

* pkgconf: add msys & cygwin

* use pkgconfig to find openssl3

* Revert "use pkgconfig to find openssl3"

This reverts commit b6f2ed815b7f7fbef8e5db9679cc4319438c4be1.

* add deps pkg-config

* fix openssl version
star9029 1 年之前
父节点
当前提交
df3a58c388

+ 42 - 0
packages/m/minio-cpp/patches/0.3.0/cmake-pkgconfig-find-deps.patch

@@ -0,0 +1,42 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c2610db..abee1c8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -57,15 +57,16 @@ endif()
+ # ------------
+ 
+ find_package(OpenSSL REQUIRED)
+-find_package(unofficial-curlpp CONFIG REQUIRED)
+-find_package(unofficial-inih CONFIG REQUIRED)
++find_package(CURL REQUIRED)
++include(FindPkgConfig)
++pkg_search_module(curlpp REQUIRED IMPORTED_TARGET curlpp)
++pkg_search_module(inih REQUIRED IMPORTED_TARGET inih)
+ find_package(nlohmann_json CONFIG REQUIRED)
+ find_package(pugixml CONFIG REQUIRED)
+ find_package(ZLIB REQUIRED)
+ 
+ list(APPEND MINIO_CPP_LIBS
+-  unofficial::curlpp::curlpp
+-  unofficial::inih::inireader
++  PkgConfig::curlpp CURL::libcurl PkgConfig::inih
+   nlohmann_json::nlohmann_json
+   pugixml
+   OpenSSL::SSL OpenSSL::Crypto
+@@ -115,7 +116,7 @@ set(MINIO_CPP_HEADERS
+   include/miniocpp/utils.h
+ )
+ 
+-add_library(miniocpp STATIC ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS})
++add_library(miniocpp  ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS})
+ target_compile_options(miniocpp PRIVATE ${MINIO_CPP_CFLAGS})
+ target_compile_features(miniocpp PUBLIC cxx_std_${MINIO_CPP_STD})
+ target_include_directories(miniocpp PUBLIC
+@@ -124,7 +125,6 @@ target_include_directories(miniocpp PUBLIC
+ )
+ target_link_libraries(miniocpp PUBLIC ${MINIO_CPP_LIBS})
+ set_target_properties(miniocpp PROPERTIES VERSION "${MINIO_CPP_VERSION_STRING}")
+-set_target_properties(miniocpp PROPERTIES POSITION_INDEPENDENT_CODE ON)
+ 
+ # Add a cmake alias - this is how users should use minio-cpp in their cmake projects.
+ add_library(miniocpp::miniocpp ALIAS miniocpp)

+ 15 - 0
packages/m/minio-cpp/patches/0.3.0/macos-unistd.patch

@@ -0,0 +1,15 @@
+diff --git a/src/utils.cc b/src/utils.cc
+index 05cb8e2..6f16a66 100644
+--- a/src/utils.cc
++++ b/src/utils.cc
+@@ -24,6 +24,10 @@
+ #include <corecrt.h>
+ #endif
+ 
++#ifndef _MSC_VER
++#include <unistd.h>
++#endif
++
+ #include <openssl/bio.h>
+ #include <openssl/buffer.h>
+ #include <openssl/crypto.h>

+ 56 - 0
packages/m/minio-cpp/xmake.lua

@@ -0,0 +1,56 @@
+package("minio-cpp")
+    set_homepage("https://minio-cpp.min.io/")
+    set_description("MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/minio/minio-cpp/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/minio/minio-cpp.git")
+
+    add_versions("v0.3.0", "da0f2f54bf169ad9e5e9368cc9143df4db056fc5c05bb55d8c1d9065e7211f7c")
+
+    add_patches("0.3.0", "patches/0.3.0/cmake-pkgconfig-find-deps.patch", "53a0a5a300c896ad92dbaf3b96fa25556a2f555e84ce07deb7b7b1562ddac9e5")
+    add_patches("0.3.0", "patches/0.3.0/macos-unistd.patch", "cd50e5d3cb5ceda7d606dc15f90ab4764b34a61a96a3be83f02688329843ef1f")
+
+    add_deps("cmake")
+    if is_host("windows") then
+        add_deps("pkgconf")
+    else
+        add_deps("pkg-config")
+    end
+
+    add_deps("nlohmann_json", {configs = {cmake = true}})
+    add_deps("inih", {configs = {ini_parser = true}})
+    add_deps("curlpp", "pugixml", "zlib")
+
+    on_load(function (package)
+        -- xrepo package: curlpp -> libcurl -> openssl
+        if package:is_plat("linux") then
+            package:add("deps", "openssl")
+        else
+            package:add("deps", "openssl3")
+        end
+    end)
+
+    on_install("windows", "linux", "macosx", "mingw", function (package)
+        if package:is_plat("linux") then
+            io.replace("src/utils.cc", "#include <openssl/types.h>", "", {plain = true})
+        end
+
+        local configs = {}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        if package:is_plat("windows") and package:config("shared") then
+            table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            void test() {
+                minio::s3::BaseUrl base_url("play.min.io");
+                minio::creds::StaticProvider provider("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
+                minio::s3::Client client(base_url, &provider);
+            }
+        ]]}, {configs = {languages = "c++17"}, includes = "miniocpp/client.h"}))
+    end)