From c96b36fa4b63a415e160aa384b55519affd7247b Mon Sep 17 00:00:00 2001 From: star9029 Date: Wed, 16 Aug 2023 21:10:51 +0800 Subject: [PATCH] cpp20-http-client: add package (#2445) * cpp20-http-client: add package * fix deps --- packages/c/cpp20-http-client/xmake.lua | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 packages/c/cpp20-http-client/xmake.lua diff --git a/packages/c/cpp20-http-client/xmake.lua b/packages/c/cpp20-http-client/xmake.lua new file mode 100644 index 000000000..a623f78bf --- /dev/null +++ b/packages/c/cpp20-http-client/xmake.lua @@ -0,0 +1,50 @@ +package("cpp20-http-client") + set_homepage("https://github.com/avocadoboi/cpp20-http-client") + set_description("An HTTP(S) client library for C++20.") + set_license("MIT") + + add_urls("https://github.com/avocadoboi/cpp20-http-client.git") + + add_versions("2023.08.11", "bb011a055a1813a4fb2a0b67db0ffa455221aaf8") + + if is_plat("windows") then + add_syslinks("ws2_32", "crypt32") + else + add_deps("openssl") + end + + on_install("windows", "linux", "macosx", "bsd", "android", "cross", function (package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + if not is_plat("windows") then + add_requires("openssl") + end + set_languages("c++20") + target("cpp20-http-client") + set_kind("$(kind)") + add_files("source/**.cpp") + add_includedirs("include") + add_headerfiles("include/**.hpp") + if is_plat("windows") then + add_cxxflags("/utf-8") + add_syslinks("ws2_32", "crypt32") + if is_kind("shared") then + add_rules("utils.symbols.export_all", {export_classes = true}) + end + else + add_packages("openssl") + end + ]]) + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + void test() { + auto const response = http_client::get("https://www.google.com") + .add_header({.name="HeaderName", .value="header value"}) + .send(); + } + ]]}, {configs = {languages = "c++20"}})) + end)