xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("http_parser")
  2. set_homepage("https://github.com/nodejs/http-parser")
  3. set_description("Parser for HTTP messages written in C.")
  4. add_urls("https://github.com/nodejs/http-parser/archive/$(version).tar.gz",
  5. "https://github.com/nodejs/http-parser.git")
  6. add_versions("v2.9.4", "467b9e30fd0979ee301065e70f637d525c28193449e1b13fbcb1b1fab3ad224f")
  7. on_install(function (package)
  8. io.writefile("xmake.lua", [[
  9. add_rules("mode.debug", "mode.release")
  10. target("http_parser")
  11. set_kind("$(kind)")
  12. if is_kind("shared") and is_plat("windows") then
  13. local funcs = {"http_body_is_final",
  14. "http_errno_description",
  15. "http_errno_name",
  16. "http_method_str",
  17. "http_parser_execute",
  18. "http_parser_init",
  19. "http_parser_parse_url",
  20. "http_parser_pause",
  21. "http_parser_set_max_header_size",
  22. "http_parser_settings_init",
  23. "http_parser_url_init",
  24. "http_parser_version",
  25. "http_should_keep_alive",
  26. "http_status_str"}
  27. for _, func in ipairs(funcs) do
  28. add_shflags("/export:" .. func)
  29. end
  30. end
  31. add_files("http_parser.c")
  32. add_headerfiles("http_parser.h")
  33. ]])
  34. local configs = {}
  35. if package:config("shared") then
  36. configs.kind = "shared"
  37. end
  38. import("package.tools.xmake").install(package, configs)
  39. end)
  40. on_test(function (package)
  41. assert(package:has_cfuncs("http_parser_version", {includes = "http_parser.h"}))
  42. end)