xmake.lua 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package("arrow")
  2. -- For how to enable various features and build PyArrow python packages,
  3. -- refer to this discussion https://github.com/xmake-io/xmake-repo/discussions/1106
  4. set_homepage("https://arrow.apache.org/")
  5. set_description("Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing")
  6. set_license("Apache-2.0")
  7. add_urls("https://github.com/apache/arrow/archive/refs/tags/apache-arrow-$(version).tar.gz",
  8. "https://github.com/apache/arrow.git")
  9. add_versions('7.0.0', '57e13c62f27b710e1de54fd30faed612aefa22aa41fa2c0c3bacd204dd18a8f3')
  10. add_configs("csv", {description = "CSV reader module", default = true, type = "boolean"})
  11. add_configs("json", {description = "JSON reader module", default = false, type = "boolean"})
  12. add_configs("engine", {description = "Build the Arrow Execution Engine", default = true, type = "boolean"})
  13. add_configs("dataset", {description = "Dataset API, implies the Filesystem API", default = true, type = "boolean"})
  14. add_configs("orc", {description = "Arrow integration with Apache ORC", default = false, type = "boolean"})
  15. add_configs("parquet", {description = "Apache Parquet libraries and Arrow integration", default = false, type = "boolean"})
  16. add_configs("plasma", {description = "Plasma Shared Memory Object Store", default = false, type = "boolean"})
  17. add_configs("python", {description = "Enable Python C++ integration library. Requires python and numpy (not managed by xmake/xrepo).", default = false, type = "boolean"})
  18. -- Arrow uses vendored mimalloc and jemalloc. Do not add these two libraries to configdeps.
  19. add_configs("mimalloc", {description = "Build the Arrow mimalloc-based allocator", default = true, type = "boolean"})
  20. add_configs("jemalloc", {description = "Build the Arrow jemalloc-based allocator", default = false, type = "boolean"})
  21. -- If true, arrow will look for shared libraries for third party dependency.
  22. -- The pyarrow python package creates shared library that links in all necessary thirdparty static libraries.
  23. add_configs("shared_dep", {description = "Use shared library for dependency", default = false, type = "boolean"})
  24. -- Some libraries are required for build with our default config settings.
  25. local configdeps = {
  26. re2 = "re2", utf8proc = "utf8proc",
  27. -- compression libraries
  28. brotli = "brotli", bz2 = "bzip2", snappy = "snappy", lz4 = "lz4", zlib = "zlib", zstd = "zstd",
  29. }
  30. for config, dep in pairs(configdeps) do
  31. add_configs(config, {description = "Enable " .. dep .. " support.", default = false, type = "boolean"})
  32. end
  33. add_deps("cmake", "boost")
  34. if is_plat("bsd") then
  35. add_syslinks("pthread", "execinfo")
  36. elseif is_plat("linux") then
  37. add_syslinks("pthread")
  38. end
  39. on_load(function (package)
  40. if package:config("plasma") then
  41. package:add("links", "plasma")
  42. package:add("deps", "gflags")
  43. end
  44. if package:config("parquet") then
  45. package:add("links", "parquet")
  46. end
  47. if package:config("dataset") then
  48. package:add("links", "arrow_dataset")
  49. end
  50. package:add("links", "arrow", "arrow_bundled_dependencies")
  51. for name, dep in pairs(configdeps) do
  52. if package:config(name) then
  53. package:add("deps", dep)
  54. end
  55. end
  56. if package:config("python") then
  57. package:add("deps", "rapidjson")
  58. end
  59. if package:config("json") then
  60. package:add("deps", "rapidjson")
  61. end
  62. if package:config("orc") then
  63. package:add("deps", "protobuf-cpp")
  64. package:add("deps", "lz4")
  65. package:add("deps", "snappy")
  66. package:add("deps", "zlib")
  67. package:add("deps", "zstd")
  68. end
  69. if package:config("parquet") then
  70. package:add("deps", "thrift")
  71. end
  72. end)
  73. on_install("linux", "macosx", "bsd", function (package)
  74. local configs = {
  75. "-DARROW_BUILD_TESTS=OFF",
  76. "-DARROW_DEPENDENCY_SOURCE=SYSTEM",
  77. }
  78. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  79. local shared = package:config("shared")
  80. table.insert(configs, "-DARROW_BUILD_STATIC=" .. (shared and "OFF" or "ON"))
  81. table.insert(configs, "-DARROW_BUILD_SHARED=" .. (shared and "ON" or "OFF"))
  82. table.insert(configs, "-DARROW_DEPENDENCY_USE_SHARED=" .. (package:config("shared_dep") and "ON" or "OFF"))
  83. for config, enabled in pairs(package:configs()) do
  84. if not package:extraconf("configs", config, "builtin") and configdeps[config] == nil then
  85. table.insert(configs, "-DARROW_" .. string.upper(config) .. "=" .. (enabled and "ON" or "OFF"))
  86. end
  87. end
  88. for config, dep in pairs(configdeps) do
  89. table.insert(configs, "-DARROW_WITH_" .. string.upper(config) .. "=" .. (package:config(config) and "ON" or "OFF"))
  90. end
  91. -- To fix arrow src/arrow/CMakeLists.txt:538, when CMAKE_SYSTEM_NAME set but CMAKE_SYSTEM_PROCESSOR is not causing error.
  92. table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_arch("x86_64") and "x86_64" or "x86"))
  93. os.cd("cpp")
  94. import("package.tools.cmake").install(package, configs)
  95. end)
  96. on_test(function (package)
  97. if package:config("python") then
  98. -- test links to all libs, including python binding, which causes link error.
  99. return
  100. end
  101. assert(package:check_cxxsnippets({test = [[
  102. void test() {
  103. arrow::MemoryPool* pool = arrow::default_memory_pool();
  104. arrow::Int64Builder id_builder(pool);
  105. (void)id_builder;
  106. }
  107. ]]}, {configs = {languages = "c++11"}, includes = "arrow/api.h"}))
  108. end)