xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("libmysofa")
  2. set_homepage("https://github.com/hoene/libmysofa")
  3. set_description("Reader for AES SOFA files to get better HRTFs")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/hoene/libmysofa/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/hoene/libmysofa.git")
  7. add_versions("v1.3.2", "6c5224562895977e87698a64cb7031361803d136057bba35ed4979b69ab4ba76")
  8. add_patches("v1.3.2", "patches/v1.3.2/fix-build.patch", "a28aed4c5e766081ff90a7aed74c58b77927432a80385f6aad9f3278cde6bb59")
  9. add_deps("cmake", "zlib")
  10. if is_plat("linux", "bsd") then
  11. add_syslinks("pthread")
  12. end
  13. on_install(function (package)
  14. if not package:config("shared") then
  15. package:add("defines", "MYSOFA_STATIC_DEFINE")
  16. end
  17. if package:version() and package:version():le("1.3.2") then
  18. io.replace("src/CMakeLists.txt", "${BUILD_SHARED_LIBS}", package:config("pic") and "ON" or "OFF", {plain = true})
  19. end
  20. if package:is_plat("wasm", "cross") then
  21. io.replace("src/CMakeLists.txt", [[find_library(MATH m)]], [[set(MATH "")]], {plain = true})
  22. end
  23. if is_host("windows") and package:is_plat("wasm") then
  24. io.replace("src/hrtf/portable_endian.h", [[elif defined(__WINDOWS__)]], [[elif 1]], {plain = true})
  25. end
  26. if is_host("linux") and package:is_plat("wasm") then
  27. io.replace("src/hrtf/portable_endian.h", [[if defined(__linux__)]], [[if 1]], {plain = true})
  28. end
  29. if is_host("bsd") and package:is_plat("wasm") then
  30. io.replace("src/hrtf/portable_endian.h", [[defined(__FreeBSD__)]], [[1]], {plain = true})
  31. end
  32. if is_host("macosx") and package:is_plat("wasm") then
  33. io.replace("src/hrtf/portable_endian.h", [[elif defined(__APPLE__)]], [[elif 1]], {plain = true})
  34. end
  35. os.rm("windows/third-party/zlib-1.2.11")
  36. os.rm("share/default.sofa")
  37. os.cp("share/MIT_KEMAR_normal_pinna.sofa", "share/default.sofa")
  38. local configs = {"-DBUILD_TESTS=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
  39. table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
  40. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  41. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  42. table.insert(configs, "-DADDRESS_SANITIZE=" .. (package:config("asan") and "ON" or "OFF"))
  43. import("package.tools.cmake").install(package, configs)
  44. end)
  45. on_test(function (package)
  46. assert(package:has_cfuncs("mysofa_open", {includes = "mysofa.h"}))
  47. end)