xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("neco")
  2. set_homepage("https://github.com/tidwall/neco")
  3. set_description("Concurrency library for C (coroutines)")
  4. set_license("MIT")
  5. add_urls("https://github.com/tidwall/neco/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/tidwall/neco.git")
  7. add_versions("v0.3.2", "ae3cefa6217428e992da0b30f254502b9974079dd9973eee9c482ea89df3fcef")
  8. if is_plat("linux", "bsd") then
  9. add_syslinks("pthread", "dl")
  10. elseif is_plat("mingw") then
  11. add_syslinks("ws2_32", "wsock32")
  12. end
  13. if on_check then
  14. on_check("windows", function (package)
  15. assert(package:has_cincludes("stdatomic.h", {configs = {languages = "c11"}}),
  16. "package(neco) Require at least C11 and stdatomic.h")
  17. end)
  18. end
  19. on_install("linux", "mingw|x86_64", "windows", "bsd", "android", "iphoneos", function (package)
  20. io.replace("neco.c", "#if defined(__linux__) && !defined(_GNU_SOURCE)",
  21. "#if defined(__linux__) && !defined(_GNU_SOURCE) && !defined(__ANDROID__)", {plain = true})
  22. io.replace("neco.c", "&(int){1}", "(const char*)&(int){1}", {plain = true})
  23. if package:is_plat("linux") then
  24. io.replace("neco.c", "#include <stdlib.h>", "#include <stdlib.h>\n#include <time.h>\n#include <sys/mman.h>", {plain = true})
  25. end
  26. io.writefile("xmake.lua", [[
  27. add_rules("mode.release", "mode.debug")
  28. set_warnings("none")
  29. set_languages("c11")
  30. target("neco")
  31. set_kind("$(kind)")
  32. add_files("neco.c")
  33. add_headerfiles("neco.h")
  34. if is_plat("windows") and is_kind("shared") then
  35. add_rules("utils.symbols.export_all")
  36. end
  37. if is_plat("linux", "bsd") then
  38. add_syslinks("pthread", "dl")
  39. add_defines("_BSD_SOURCE")
  40. elseif is_plat("windows", "mingw") then
  41. add_syslinks("ws2_32", "wsock32")
  42. end
  43. ]])
  44. import("package.tools.xmake").install(package)
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("neco_start", {includes = "neco.h"}))
  48. end)