llhttp: add v9.2.1 version (#5415)
* llhttp: add v9.2.1 version * http_parser: improve xmake.luapull/5231/merge
parent
5f4b081353
commit
dd6c45ee9e
3 changed files with 67 additions and 45 deletions
@ -0,0 +1,34 @@ |
|||||||
|
option("export_symbol", {default = false}) |
||||||
|
|
||||||
|
add_rules("mode.debug", "mode.release") |
||||||
|
|
||||||
|
target("llhttp") |
||||||
|
set_kind("$(kind)") |
||||||
|
add_files("src/*.c") |
||||||
|
add_includedirs("include") |
||||||
|
add_headerfiles("include/llhttp.h") |
||||||
|
|
||||||
|
if has_config("export_symbol") and is_kind("shared") and is_plat("windows") then |
||||||
|
local funcs = { |
||||||
|
"llhttp_init", |
||||||
|
"llhttp_settings_init", |
||||||
|
"llhttp_execute", |
||||||
|
"llhttp_finish", |
||||||
|
"llhttp_message_needs_eof", |
||||||
|
"llhttp_should_keep_alive", |
||||||
|
"llhttp_pause", |
||||||
|
"llhttp_resume", |
||||||
|
"llhttp_resume_after_upgrade", |
||||||
|
"llhttp_get_errno", |
||||||
|
"llhttp_get_error_reason", |
||||||
|
"llhttp_set_error_reason", |
||||||
|
"llhttp_get_error_pos", |
||||||
|
"llhttp_errno_name", |
||||||
|
"llhttp_method_name", |
||||||
|
"llhttp_set_lenient_headers", |
||||||
|
"llhttp_set_lenient_chunked_length" |
||||||
|
} |
||||||
|
for _, func in ipairs(funcs) do |
||||||
|
add_shflags("/export:" .. func) |
||||||
|
end |
||||||
|
end |
@ -1,51 +1,42 @@ |
|||||||
package("llhttp") |
package("llhttp") |
||||||
|
|
||||||
set_homepage("https://github.com/nodejs/llhttp") |
set_homepage("https://github.com/nodejs/llhttp") |
||||||
set_description("Port of http_parser to llparse") |
set_description("Port of http_parser to llparse") |
||||||
set_license("MIT") |
set_license("MIT") |
||||||
|
|
||||||
add_urls("https://github.com/nodejs/llhttp/archive/release/$(version).tar.gz") |
add_urls("https://github.com/nodejs/llhttp/archive/refs/tags/release/$(version).tar.gz") |
||||||
add_versions("v3.0.0", "02931556e69f8d075edb5896127099e70a093c104a994a57b4d72c85b48d25b0") |
|
||||||
|
add_versions("v9.2.1", "3c163891446e529604b590f9ad097b2e98b5ef7e4d3ddcf1cf98b62ca668f23e") |
||||||
add_versions("v8.1.0", "9da0d23453e8e242cf3b2bc5d6fb70b1517b8a70520065fcbad6be787e86638e") |
add_versions("v8.1.0", "9da0d23453e8e242cf3b2bc5d6fb70b1517b8a70520065fcbad6be787e86638e") |
||||||
|
add_versions("v3.0.0", "02931556e69f8d075edb5896127099e70a093c104a994a57b4d72c85b48d25b0") |
||||||
|
|
||||||
|
on_load(function (package) |
||||||
|
if package:version():ge("9.2.1") then |
||||||
|
package:add("deps", "cmake") |
||||||
|
end |
||||||
|
end) |
||||||
|
|
||||||
on_install(function (package) |
on_install(function (package) |
||||||
io.writefile("xmake.lua", [[ |
local xmake_configs = {} |
||||||
add_rules("mode.debug", "mode.release") |
if package:version():ge("9.2.1") then |
||||||
target("llhttp") |
-- Get cmake config file |
||||||
set_kind("$(kind)") |
local configs = {} |
||||||
if is_kind("shared") and is_plat("windows") then |
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) |
||||||
local funcs = {"llhttp_init", |
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) |
||||||
"llhttp_settings_init", |
table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON")) |
||||||
"llhttp_execute", |
import("package.tools.cmake").install(package, configs) |
||||||
"llhttp_finish", |
else |
||||||
"llhttp_message_needs_eof", |
xmake_configs.export_symbol = true |
||||||
"llhttp_should_keep_alive", |
end |
||||||
"llhttp_pause", |
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") |
||||||
"llhttp_resume", |
import("package.tools.xmake").install(package, xmake_configs) |
||||||
"llhttp_resume_after_upgrade", |
|
||||||
"llhttp_get_errno", |
|
||||||
"llhttp_get_error_reason", |
|
||||||
"llhttp_set_error_reason", |
|
||||||
"llhttp_get_error_pos", |
|
||||||
"llhttp_errno_name", |
|
||||||
"llhttp_method_name", |
|
||||||
"llhttp_set_lenient_headers", |
|
||||||
"llhttp_set_lenient_chunked_length"} |
|
||||||
for _, func in ipairs(funcs) do |
|
||||||
add_shflags("/export:" .. func) |
|
||||||
end |
|
||||||
end |
|
||||||
add_files("src/*.c") |
|
||||||
add_includedirs("include") |
|
||||||
add_headerfiles("include/llhttp.h") |
|
||||||
]]) |
|
||||||
local configs = {} |
|
||||||
if package:config("shared") then |
if package:config("shared") then |
||||||
configs.kind = "shared" |
io.replace(package:installdir("include/llhttp.h"), "__declspec(dllexport)", "__declspec(dllimport)", {plain = true}) |
||||||
|
else |
||||||
|
io.replace(package:installdir("include/llhttp.h"), "__declspec(dllexport)", "", {plain = true}) |
||||||
end |
end |
||||||
import("package.tools.xmake").install(package, configs) |
|
||||||
end) |
end) |
||||||
|
|
||||||
on_test(function (package) |
on_test(function (package) |
||||||
assert(package:has_cfuncs("llhttp_init", {includes = "llhttp.h"})) |
assert(package:has_cfuncs("llhttp_init", {includes = "llhttp.h"})) |
||||||
end) |
end) |
||||||
|
Loading…
Reference in new issue