xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("freexl")
  2. set_homepage("https://www.gaia-gis.it/fossil/freexl/index")
  3. set_description("FreeXL is an open source library to extract valid data from within an Excel (.xls) spreadsheet.")
  4. set_license("MPL-1.0")
  5. add_urls("https://www.gaia-gis.it/gaia-sins/freexl-sources/freexl-$(version).tar.gz")
  6. add_versions("2.0.0", "176705f1de58ab7c1eebbf5c6de46ab76fcd8b856508dbd28f5648f7c6e1a7f0")
  7. add_deps("libiconv", "expat", "minizip")
  8. if is_plat("mingw") and is_subhost("msys") then
  9. add_extsources("pacman::libfreexl")
  10. elseif is_plat("linux") then
  11. add_extsources("pacman::libfreexl", "apt::libfreexl-dev")
  12. elseif is_plat("macosx") then
  13. add_extsources("brew::freexl")
  14. end
  15. if is_plat("linux", "bsd") then
  16. add_syslinks("m")
  17. end
  18. if on_check then
  19. on_check("android", function (package)
  20. local ndk = package:toolchain("ndk")
  21. local ndk_sdkver = ndk:config("ndk_sdkver")
  22. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 23, "package(freexl) dep(minizip) require ndk api level >= 23")
  23. end)
  24. end
  25. on_install(function (package)
  26. if package:is_plat("windows") and package:config("shared") then
  27. io.replace("headers/freexl.h", "#define FREEXL_DECLARE extern", "#define FREEXL_DECLARE __declspec(dllimport)", {plain = true})
  28. end
  29. if not package:is_plat("windows") then
  30. os.touch("src/config.h")
  31. end
  32. io.writefile("xmake.lua", string.format([[
  33. option("ver", {default = "%s"})
  34. add_rules("mode.debug", "mode.release")
  35. add_requires("libiconv", "expat", "minizip")
  36. target("freexl")
  37. set_kind("$(kind)")
  38. add_files("src/*.c")
  39. add_includedirs(".", "headers")
  40. add_headerfiles("headers/freexl.h")
  41. if is_kind("shared") and is_plat("windows") then
  42. add_defines("DLL_EXPORT")
  43. end
  44. if is_plat("linux", "bsd") then
  45. add_syslinks("m")
  46. end
  47. add_packages("libiconv", "expat", "minizip")
  48. if has_config("ver") then
  49. add_defines("VERSION=\"" .. get_config("ver") .. "\"")
  50. set_version(get_config("ver"), {soname = true})
  51. end
  52. ]], package:version_str()))
  53. import("package.tools.xmake").install(package)
  54. end)
  55. on_test(function (package)
  56. assert(package:has_cfuncs("freexl_open", {includes = "freexl.h"}))
  57. end)