xmake.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("zbar")
  2. set_homepage("https://github.com/mchehab/zbar")
  3. set_description("Library for reading bar codes from various sources")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/mchehab/zbar/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/mchehab/zbar.git")
  7. add_versions("0.23.93", "212dfab527894b8bcbcc7cd1d43d63f5604a07473d31a5f02889e372614ebe28")
  8. if is_plat("mingw") and is_subhost("msys") then
  9. add_extsources("pacman::zbar")
  10. elseif is_plat("linux") then
  11. add_extsources("pacman::zbar", "apt::libzbar-dev")
  12. elseif is_plat("macosx") then
  13. add_extsources("brew::zbar")
  14. end
  15. add_configs("symbologies", {description = "Select symbologies to compile", default = {"ean", "databar", "code128", "code93", "code39", "codabar", "i25", "qrcode", "sqcode"}, type = "table"})
  16. if is_plat("linux", "bsd") then
  17. add_syslinks("pthread")
  18. elseif is_plat("windows") then
  19. add_syslinks("winmm")
  20. end
  21. add_deps("libiconv")
  22. on_install(function (package)
  23. os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "include/config.h.in")
  24. io.gsub("include/config.h.in", "# ?undef (.-)\n", "${define %1}\n")
  25. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  26. io.replace("zbar/processor.h", "#include <unistd.h>", "", {plain = true})
  27. local configs = { vers = package:version_str(),
  28. symbologies = table.concat(package:config("symbologies"), ",")}
  29. -- get LIB_VERSION from configure.ac
  30. -- format: AC_SUBST([LIB_VERSION], [3:0:3])
  31. local configure_ac = io.readfile("configure.ac")
  32. for _, key in ipairs({"LIB_VERSION"}) do
  33. local value = configure_ac:match("AC_SUBST%(%[" .. key .. "%]%s*,%s*%[(.-)%]%)")
  34. if value then
  35. configs[key] = value
  36. end
  37. end
  38. import("package.tools.xmake").install(package, configs)
  39. end)
  40. on_test(function (package)
  41. assert(package:check_csnippets({test = [[
  42. void test() {
  43. zbar_image_scanner_t *scanner ;
  44. scanner = zbar_image_scanner_create();
  45. zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_ENABLE, 1);
  46. zbar_image_scanner_destroy(scanner);
  47. }
  48. ]]}, {includes = "zbar.h"}))
  49. end)