xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("oboe")
  2. set_homepage("https://github.com/google/oboe")
  3. set_description("Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/google/oboe/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/google/oboe.git")
  7. add_versions("1.9.3", "9d2486b74bd396d9d9112625077d5eb656fd6942392dc25ebf222b184ff4eb61")
  8. add_configs("cmake", {description = "Use cmake build system", default = false, type = "boolean"})
  9. on_load(function (package)
  10. if package:config("cmake") then
  11. package:add("deps", "cmake")
  12. end
  13. end)
  14. on_install("android", function (package)
  15. if package:config("cmake") then
  16. io.replace("CMakeLists.txt", "LIBRARY DESTINATION lib/${ANDROID_ABI}", "LIBRARY DESTINATION lib", {plain = true})
  17. io.replace("CMakeLists.txt", "ARCHIVE DESTINATION lib/${ANDROID_ABI}", "ARCHIVE DESTINATION lib", {plain = true})
  18. local configs = {}
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  21. import("package.tools.cmake").install(package, configs)
  22. else
  23. io.writefile("xmake.lua", [[
  24. add_rules("mode.release", "mode.debug")
  25. add_rules("utils.install.cmake_importfiles")
  26. option("version", {description = "Set the version"})
  27. set_version(get_config("version"))
  28. target("oboe")
  29. set_kind("$(kind)")
  30. set_languages("c++17")
  31. add_files("src/**.cpp")
  32. add_includedirs("include", "src")
  33. add_headerfiles("include/(oboe/*.h)")
  34. if is_mode("debug") then
  35. set_optimize("fastest")
  36. add_defines("OBOE_ENABLE_LOGGING=1")
  37. else
  38. set_optimize("aggressive")
  39. end
  40. add_defines("DO_NOT_DEFINE_OPENSL_ES_CONSTANTS=0")
  41. add_syslinks("log", "OpenSLES")
  42. add_ldflags("-Wl,-z,max-page-size=16384")
  43. ]])
  44. import("package.tools.xmake").install(package, {version = package:version()})
  45. end
  46. end)
  47. on_test(function (package)
  48. assert(package:check_cxxsnippets({test = [[
  49. void test() {
  50. oboe::FifoBuffer * buf = new oboe::FifoBuffer(4, 10240);
  51. auto bytes = buf->convertFramesToBytes(32);
  52. }
  53. ]]}, {configs = {languages = "c++17"}, includes = "oboe/Oboe.h"}))
  54. end)