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/qicosmos/cinatra/archive/refs/tags/$(version).tar.gz" ,
8+ " https://github.com/qicosmos/cinatra.git" )
9+
10+ add_versions (" 0.9.5" , " f21448332f56484af76347a3da30099dcd155d31ac9d3098faf7e9d6cb1e0c34" )
11+ add_versions (" 0.9.4" , " 2b8b4e264f8083674554db55ca137998f02c528730cf9565697234fec9de3378" )
12+ add_versions (" 0.9.1" , " d1a8018e41caabbda2c380175b632e3c9c10b519727f6b998eda4e3f4ede84bd" )
13+ add_versions (" v0.8.9" , " 007dc38aceedf42d03a9c05dc9aa6d2f303456ae7ce1100800df7a565b83b510" )
14+ add_versions (" v0.8.0" , " 4e14d5206408eccb43b3e810d3a1fe228fbc7496ded8a16b041ed12cbcce4479" )
15+
16+ add_patches (" >=0.8.9 <=0.9.2" , " patches/0.8.9/windows-move.patch" , " c913ed0e9044ffc0ced40516245ec0d55262f8eabd30244d9911c3f0427a60f5" )
17+
18+ add_configs (" ssl" , {description = " Enable SSL" , default = false , type = " boolean" })
19+ add_configs (" gzip" , {description = " Enable GZIP" , default = false , type = " boolean" })
20+ add_configs (" sse42" , {description = " Enable sse4.2 instruction set" , default = false , type = " boolean" })
21+ add_configs (" avx2" , {description = " Enable avx2 instruction set" , default = false , type = " boolean" })
22+ add_configs (" aarch64" , {description = " Enable aarch64 instruction set (only arm)" , default = false , type = " boolean" })
23+
24+ add_deps (" asio" )
25+ add_deps (" async_simple" , {configs = {aio = false }})
26+
27+ on_check (" windows" , function (package )
28+ local vs_toolset = package :toolchain (" msvc" ):config (" vs_toolset" )
29+ if vs_toolset then
30+ local vs_toolset_ver = import (" core.base.semver" ).new (vs_toolset )
31+ local minor = vs_toolset_ver :minor ()
32+ assert (minor and minor >= 30 , " package(cinatra) require vs_toolset >= 14.3" )
33+ end
34+ end )
35+
36+ on_load (function (package )
37+ package :add (" defines" , " ASIO_STANDALONE" )
38+ if package :config (" ssl" ) then
39+ package :add (" deps" , " openssl" )
40+ package :add (" defines" , " CINATRA_ENABLE_SSL" )
41+ end
42+ if package :config (" gzip" ) then
43+ package :add (" deps" , " zlib" )
44+ package :add (" defines" , " CINATRA_ENABLE_GZIP" )
45+ end
46+
47+ local configdeps = {
48+ sse42 = " CINATRA_SSE" ,
49+ avx2 = " CINATRA_AVX2" ,
50+ aarch64 = " CINATRA_ARM_OPT"
51+ }
52+
53+ for name , item in pairs (configdeps ) do
54+ if package :config (name ) then
55+ package :add (" defines" , item )
56+ end
57+ end
58+ end )
59+
60+ on_install (" windows" , " linux" , " macosx" , " android" , function (package )
61+ os .cp (" include" , package :installdir ())
62+ end )
63+
64+ on_test (function (package )
65+ assert (package :has_cxxincludes (" cinatra.hpp" , {configs = {languages = " c++20" }}))
66+ end )
67+
68+ package (" yalantinglibs" )
69+ set_kind (" library" , {headeronly = true })
70+ set_homepage (" https://github.com/alibaba/yalantinglibs" )
71+ set_description (" A collection of modern C++ libraries" )
72+ set_license (" Apache-2.0" )
73+
74+ set_urls (" https://github.com/alibaba/yalantinglibs/archive/refs/tags/$(version).tar.gz" ,
75+ " https://github.com/alibaba/yalantinglibs.git" )
76+
77+ add_versions (" 0.6.0" , " 798c32a0d25c6306d6ff3d9dbd1c561a41e16cc11bd30b8993c737f6ac0517d9" )
78+ add_versions (" 0.5.8" , " 49b631c191f139ff465b489663a620f3ae24af6baa236cc1e3d96f3ac7506d73" )
79+ add_versions (" 0.5.7" , " 1c1057289e5488f90dd326fd2bb9d3173bad11eb5b06bc0a8bf0fa80857e1cfa" )
80+ add_versions (" 0.5.6" , " b2656f794af30c5b83952b7c73c2dabf949061ddb6284d18d7f0c0560244b35a" )
81+ add_versions (" 0.5.5" , " 7962579c1414d1ade4fd22316476723d54112c919514bf1e6015a1870e5e68f7" )
82+ add_versions (" 0.5.3" , " 9d24612975d38fa4b4a05bd9f8f5cb65d447365e5eb3661d0eba9701d383523a" )
83+ add_versions (" 0.5.2" , " e63500b9b84b6efd76bfc375d0972c0376d98067f7a6118bfd9a3048d557f46a" )
84+ add_versions (" 0.4.0" , " 35d88b5e329f88edb702c1c40a67dedb4438898774c96bb6f3f1704ab828257f" )
85+ add_versions (" 0.3.11" , " 1766ca1ec977e2dd56dabdcad3172dc1b79c3bd1acd26ea2de019299fa7e888a" )
86+ add_versions (" 0.3.9" , " aea6c5c99297f9b875eac8cabdf846b8f8e792bf7ccb3da8e0afda90ea62f00b" )
87+ add_versions (" 0.3.8" , " a9966687a2ac1ed0b1a001a69e144db4cff4cdf77a5a80c00364e6ea687d3c52" )
88+ add_versions (" 0.3.7" , " b4258806173f63034aa529913601bc3d90da8a598725c0edf0be1a8c5c6f32b8" )
89+ add_versions (" 0.3.6" , " 92f694ad42537f95535efc648fc5e73e82f840dae4f54524a096050db398214b" )
90+ add_versions (" 0.3.4" , " dd5edd3f43f23cd4b0614896e6587b61bb38c981dc21c85a54bcc54800d0dfe8" )
91+ add_versions (" 0.3.5" , " 8d382573da01449c4f83fccbbc3bdc08d221651f3fc8b9137eb4fbdb703677c2" )
92+
93+ add_configs (" ssl" , {description = " Enable ssl support" , default = false , type = " boolean" })
94+ add_configs (" pmr" , {description = " Enable pmr support" , default = false , type = " boolean" })
95+ add_configs (" io_uring" , {description = " Enable io_uring" , default = false , type = " boolean" })
96+ add_configs (" file_io_uring" , {description = " Enable file io_uring" , default = false , type = " boolean" })
97+ add_configs (" struct_pack_unportable_type" , {description = " enable struct_pack unportable type(like wchar_t)" , default = false , type = " boolean" })
98+ add_configs (" struct_pack_unportable_optimize" , {description = " enable struct_pack optimize(but cost more compile time)" , default = false , type = " boolean" })
99+
100+ add_deps (" cmake" )
101+ add_deps (" cinatra" , " iguana" )
102+
103+ on_check (" windows" , function (package )
104+ local vs_toolset = package :toolchain (" msvc" ):config (" vs_toolset" )
105+ if vs_toolset then
106+ local vs_toolset_ver = import (" core.base.semver" ).new (vs_toolset )
107+ local minor = vs_toolset_ver :minor ()
108+ assert (minor and minor >= 30 , " package(yalantinglibs) dep(cinatra) require vs_toolset >= 14.3" )
109+ end
110+ end )
111+
112+ on_load (function (package )
113+ if package :config (" ssl" ) then
114+ package :add (" deps" , " openssl" )
115+ package :add (" defines" , " YLT_ENABLE_SSL" )
116+ end
117+ if package :config (" pmr" ) then
118+ package :add (" defines" , " YLT_ENABLE_PMR" )
119+ end
120+ if package :config (" io_uring" ) then
121+ package :add (" deps" , " liburing" )
122+ package :add (" defines" , " ASIO_HAS_IO_URING" , " ASIO_DISABLE_EPOLL" , " ASIO_HAS_FILE" , " YLT_ENABLE_FILE_IO_URING" )
123+ end
124+ if package :config (" file_io_uring" ) then
125+ package :add (" deps" , " liburing" )
126+ package :add (" defines" , " ASIO_HAS_IO_URING" , " ASIO_HAS_FILE" , " YLT_ENABLE_FILE_IO_URING" )
127+ end
128+ if package :config (" struct_pack_unportable_type" ) then
129+ package :add (" defines" , " STRUCT_PACK_ENABLE_UNPORTABLE_TYPE" )
130+ end
131+ if package :config (" struct_pack_unportable_optimize" ) then
132+ package :add (" defines" , " YLT_ENABLE_STRUCT_PACK_OPTIMIZE" )
133+ end
134+ end )
135+
136+ on_install (" windows" , " linux" , " macosx" , " android" , function (package )
137+ local configs = {
138+ " -DINSTALL_THIRDPARTY=OFF" ,
139+ " -DINSTALL_STANDALONE=OFF" ,
140+ " -DINSTALL_INDEPENDENT_THIRDPARTY=OFF" ,
141+ " -DINSTALL_INDEPENDENT_STANDALONE=OFF" ,
142+ " -DCMAKE_PROJECT_NAME=xmake" ,
143+ }
144+ for name , enabled in table .orderpairs (package :configs ()) do
145+ if not package :extraconf (" configs" , name , " builtin" ) then
146+ table.insert (configs , " -DYLT_ENABLE_" .. name :upper () .. " =" .. (enabled and " ON" or " OFF" ))
147+ end
148+ end
149+ import (" package.tools.cmake" ).install (package , configs )
150+ end )
151+
152+ on_test (function (package )
153+ assert (package :check_cxxsnippets ({test = [[
154+ #include "ylt/struct_pack.hpp"
155+ struct person {
156+ int64_t id;
157+ std::string name;
158+ int age;
159+ double salary;
160+ };
161+ void test() {
162+ person person1{.id = 1, .name = "hello struct pack", .age = 20, .salary = 1024.42};
163+ std::vector<char> buffer = struct_pack::serialize(person1);
164+ }
165+ ]] }, {configs = {languages = " c++20" }}))
166+ end )
0 commit comments