xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("serial")
  2. set_homepage("http://wjwwood.github.io/serial")
  3. set_description("Cross-platform, Serial Port library written in C++")
  4. set_license("MIT")
  5. add_urls("https://github.com/wjwwood/serial.git")
  6. add_versions("2022.3.9", "69e0372cf0d3796e84ce9a09aff1d74496f68720")
  7. if is_plat("windows", "mingw") then
  8. add_syslinks("advapi32", "setupapi")
  9. elseif is_plat("linux") then
  10. add_syslinks("rt", "pthread")
  11. elseif is_plat("macosx") then
  12. add_frameworks("IOKit", "Foundation")
  13. end
  14. on_install("windows", "linux", "macosx", "mingw", "cross", "wasm", function (package)
  15. local configs = {}
  16. io.writefile("xmake.lua", [[
  17. add_rules("mode.debug", "mode.release")
  18. target("serial")
  19. set_kind("$(kind)")
  20. add_files("src/serial.cc")
  21. add_includedirs("include")
  22. add_headerfiles("include/(serial/*.h)")
  23. if is_plat("windows", "mingw") then
  24. add_files("src/impl/win.cc")
  25. add_files("src/impl/list_ports/list_ports_win.cc")
  26. add_syslinks("advapi32", "setupapi")
  27. if is_plat("windows") and is_kind("shared") then
  28. add_rules("utils.symbols.export_all", {export_classes = true})
  29. end
  30. else
  31. add_files("src/impl/unix.cc")
  32. if is_plat("macosx") then
  33. add_files("src/impl/list_ports/list_ports_osx.cc")
  34. add_frameworks("IOKit", "Foundation")
  35. else
  36. add_files("src/impl/list_ports/list_ports_linux.cc")
  37. if is_plat("linux") then
  38. add_syslinks("rt", "pthread")
  39. end
  40. end
  41. end
  42. ]])
  43. if package:config("shared") then
  44. configs.kind = "shared"
  45. end
  46. import("package.tools.xmake").install(package, configs)
  47. end)
  48. on_test(function (package)
  49. assert(package:check_cxxsnippets({test = [[
  50. #include <serial/serial.h>
  51. void test() {
  52. serial::list_ports();
  53. }
  54. ]]}))
  55. end)