|
| 1 | +package("cinatra") |
| 2 | + set_kind("library", {headeronly = true}) |
| 3 | + set_homepage("https://github.com/qicosmos/cinatra") |
| 4 | + set_description("modern c++(c++20), cross-platform, header-only, easy to use http framework") |
| 5 | + set_license("MIT") |
| 6 | + |
| 7 | + add_urls("https://github.com/std-microblock/cinatra.git") |
| 8 | + |
| 9 | + add_configs("ssl", {description = "Enable SSL", default = false, type = "boolean"}) |
| 10 | + add_configs("gzip", {description = "Enable GZIP", default = false, type = "boolean"}) |
| 11 | + add_configs("sse42", {description = "Enable sse4.2 instruction set", default = false, type = "boolean"}) |
| 12 | + add_configs("avx2", {description = "Enable avx2 instruction set", default = false, type = "boolean"}) |
| 13 | + add_configs("aarch64", {description = "Enable aarch64 instruction set (only arm)", default = false, type = "boolean"}) |
| 14 | + |
| 15 | + add_deps("asio") |
| 16 | + add_deps("async_simple 18f3882be354d407af0f0674121dcddaeff36e26", {configs = {aio = false}}) |
| 17 | + |
| 18 | + on_check("windows", function (package) |
| 19 | + local vs_toolset = package:toolchain("msvc"):config("vs_toolset") |
| 20 | + if vs_toolset then |
| 21 | + local vs_toolset_ver = import("core.base.semver").new(vs_toolset) |
| 22 | + local minor = vs_toolset_ver:minor() |
| 23 | + assert(minor and minor >= 30, "package(cinatra) require vs_toolset >= 14.3") |
| 24 | + end |
| 25 | + end) |
| 26 | + |
| 27 | + on_load(function (package) |
| 28 | + package:add("defines", "ASIO_STANDALONE") |
| 29 | + if package:config("ssl") then |
| 30 | + package:add("deps", "openssl") |
| 31 | + package:add("defines", "CINATRA_ENABLE_SSL") |
| 32 | + end |
| 33 | + if package:config("gzip") then |
| 34 | + package:add("deps", "zlib") |
| 35 | + package:add("defines", "CINATRA_ENABLE_GZIP") |
| 36 | + end |
| 37 | + |
| 38 | + local configdeps = { |
| 39 | + sse42 = "CINATRA_SSE", |
| 40 | + avx2 = "CINATRA_AVX2", |
| 41 | + aarch64 = "CINATRA_ARM_OPT" |
| 42 | + } |
| 43 | + |
| 44 | + for name, item in pairs(configdeps) do |
| 45 | + if package:config(name) then |
| 46 | + package:add("defines", item) |
| 47 | + end |
| 48 | + end |
| 49 | + end) |
| 50 | + |
| 51 | + on_install("windows", "linux", "macosx", "android", function (package) |
| 52 | + os.cp("include", package:installdir()) |
| 53 | + end) |
| 54 | + |
| 55 | + on_test(function (package) |
| 56 | + assert(package:has_cxxincludes("cinatra.hpp", {configs = {languages = "c++20"}})) |
| 57 | + end) |
| 58 | + |
| 59 | +package("yalantinglibs") |
| 60 | + set_kind("library", {headeronly = true}) |
| 61 | + set_homepage("https://github.com/alibaba/yalantinglibs") |
| 62 | + set_description("A collection of modern C++ libraries") |
| 63 | + set_license("Apache-2.0") |
| 64 | + |
| 65 | + set_urls("https://github.com/alibaba/yalantinglibs/archive/refs/tags/$(version).tar.gz", |
| 66 | + "https://github.com/alibaba/yalantinglibs.git") |
| 67 | + |
| 68 | + add_versions("2026.03.30", "0c98464dd202aaa6275a8da3297719a436b8a51a") |
| 69 | + |
| 70 | + add_configs("ssl", {description = "Enable ssl support", default = false, type = "boolean"}) |
| 71 | + add_configs("pmr", {description = "Enable pmr support", default = false, type = "boolean"}) |
| 72 | + add_configs("io_uring", {description = "Enable io_uring", default = false, type = "boolean"}) |
| 73 | + add_configs("file_io_uring", {description = "Enable file io_uring", default = false, type = "boolean"}) |
| 74 | + add_configs("struct_pack_unportable_type", {description = "enable struct_pack unportable type(like wchar_t)", default = false, type = "boolean"}) |
| 75 | + add_configs("struct_pack_unportable_optimize", {description = "enable struct_pack optimize(but cost more compile time)", default = false, type = "boolean"}) |
| 76 | + |
| 77 | + add_deps("cmake") |
| 78 | + add_deps("cinatra d9485603c89d1fbb286f459f4d3dfdf4b44a04df", "iguana", { |
| 79 | + configs = { |
| 80 | + ssl = true |
| 81 | + } |
| 82 | + }) |
| 83 | + |
| 84 | + on_check("windows", function (package) |
| 85 | + local vs_toolset = package:toolchain("msvc"):config("vs_toolset") |
| 86 | + if vs_toolset then |
| 87 | + local vs_toolset_ver = import("core.base.semver").new(vs_toolset) |
| 88 | + local minor = vs_toolset_ver:minor() |
| 89 | + assert(minor and minor >= 30, "package(yalantinglibs) dep(cinatra) require vs_toolset >= 14.3") |
| 90 | + end |
| 91 | + end) |
| 92 | + |
| 93 | + on_load(function (package) |
| 94 | + if package:config("ssl") then |
| 95 | + package:add("deps", "openssl") |
| 96 | + package:add("defines", "YLT_ENABLE_SSL") |
| 97 | + end |
| 98 | + if package:config("pmr") then |
| 99 | + package:add("defines", "YLT_ENABLE_PMR") |
| 100 | + end |
| 101 | + if package:config("io_uring") then |
| 102 | + package:add("deps", "liburing") |
| 103 | + package:add("defines", "ASIO_HAS_IO_URING", "ASIO_DISABLE_EPOLL", "ASIO_HAS_FILE", "YLT_ENABLE_FILE_IO_URING") |
| 104 | + end |
| 105 | + if package:config("file_io_uring") then |
| 106 | + package:add("deps", "liburing") |
| 107 | + package:add("defines", "ASIO_HAS_IO_URING", "ASIO_HAS_FILE", "YLT_ENABLE_FILE_IO_URING") |
| 108 | + end |
| 109 | + if package:config("struct_pack_unportable_type") then |
| 110 | + package:add("defines", "STRUCT_PACK_ENABLE_UNPORTABLE_TYPE") |
| 111 | + end |
| 112 | + if package:config("struct_pack_unportable_optimize") then |
| 113 | + package:add("defines", "YLT_ENABLE_STRUCT_PACK_OPTIMIZE") |
| 114 | + end |
| 115 | + end) |
| 116 | + |
| 117 | + on_install("windows", "linux", "macosx", "android", function (package) |
| 118 | + local configs = { |
| 119 | + "-DINSTALL_THIRDPARTY=OFF", |
| 120 | + "-DINSTALL_STANDALONE=OFF", |
| 121 | + "-DINSTALL_INDEPENDENT_THIRDPARTY=OFF", |
| 122 | + "-DINSTALL_INDEPENDENT_STANDALONE=OFF", |
| 123 | + "-DCMAKE_PROJECT_NAME=xmake", |
| 124 | + } |
| 125 | + for name, enabled in table.orderpairs(package:configs()) do |
| 126 | + if not package:extraconf("configs", name, "builtin") then |
| 127 | + table.insert(configs, "-DYLT_ENABLE_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF")) |
| 128 | + end |
| 129 | + end |
| 130 | + import("package.tools.cmake").install(package, configs) |
| 131 | + end) |
| 132 | + |
| 133 | + on_test(function (package) |
| 134 | + assert(package:check_cxxsnippets({test = [[ |
| 135 | + #include "ylt/struct_pack.hpp" |
| 136 | + struct person { |
| 137 | + int64_t id; |
| 138 | + std::string name; |
| 139 | + int age; |
| 140 | + double salary; |
| 141 | + }; |
| 142 | + void test() { |
| 143 | + person person1{.id = 1, .name = "hello struct pack", .age = 20, .salary = 1024.42}; |
| 144 | + std::vector<char> buffer = struct_pack::serialize(person1); |
| 145 | + } |
| 146 | + ]]}, {configs = {languages = "c++20"}})) |
| 147 | + end) |
0 commit comments