xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("libgpiod")
  2. set_homepage("https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about/")
  3. set_description("libgpiod - C library and tools for interacting with the linux GPIO character device (gpiod stands for GPIO device)")
  4. add_urls("https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-$(version).tar.gz",
  5. "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git")
  6. add_versions("v2.0.1", "cf0d4db1d94cc99281de142063d0e28f42760c4d918d6b8854e1b27811517c34")
  7. add_versions("v2.0", "a0f835c4ca4a2a3ca021090b574235ba58bb9fd612d8a6051fb1350054e04fdd")
  8. add_versions("v1.6.4", "9f920260c46b155f65cba8796dcf159e4ba56950b85742af357d75a1af709e68")
  9. add_configs("enable_bindings_cxx", {description = "Enable C++ bindings", default = true, type = "boolean"})
  10. add_configs("enable_tools", {description = "Enable tools", default = true, type = "boolean"})
  11. on_install("linux", function (package)
  12. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  13. local configs = {}
  14. if package:config("enable_bindings_cxx") then
  15. configs.enable_bindings_cxx = true
  16. end
  17. if package:config("enable_tools") then
  18. configs.enable_tools = true
  19. end
  20. import("package.tools.xmake").install(package)
  21. package:addenv("PATH", "bin")
  22. end)
  23. on_test(function (package)
  24. assert(package:check_cxxsnippets({test = [[
  25. #include <gpiod.h>
  26. void test() {
  27. struct gpiod_chip *chip;
  28. chip = gpiod_chip_open("/dev/null");
  29. }
  30. ]]}, {configs = {languages = "c++11"}}))
  31. if package:config("enable_bindings_cxx") then
  32. assert(package:check_cxxsnippets({test = [[
  33. #include <gpiod.hpp>
  34. void test() {
  35. gpiod::chip chip("/dev/null");
  36. }
  37. ]]}, {configs = {languages = "c++17"}}))
  38. end
  39. if package:config("enable_tools") then
  40. os.runv("gpiodetect")
  41. end
  42. end)