xmake.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 package:is_plat("wasm", "cross") then
  15. io.replace("src/CMakeLists.txt", [[find_library(MATH m)]], [[set(MATH "")]], {plain = true})
  16. end
  17. if is_host("windows") and package:is_plat("wasm") then
  18. io.replace("src/hrtf/portable_endian.h", [[elif defined(__WINDOWS__)]], [[elif 1]], {plain = true})
  19. end
  20. if is_host("linux") and package:is_plat("wasm") then
  21. io.replace("src/hrtf/portable_endian.h", [[if defined(__linux__)]], [[if 1]], {plain = true})
  22. end
  23. if is_host("bsd") and package:is_plat("wasm") then
  24. io.replace("src/hrtf/portable_endian.h", [[defined(__FreeBSD__)]], [[1]], {plain = true})
  25. end
  26. if is_host("macosx") and package:is_plat("wasm") then
  27. io.replace("src/hrtf/portable_endian.h", [[elif defined(__APPLE__)]], [[elif 1]], {plain = true})
  28. end
  29. os.rm("windows/third-party/zlib-1.2.11")
  30. os.rm("share/default.sofa")
  31. os.cp("share/MIT_KEMAR_normal_pinna.sofa", "share/default.sofa")
  32. local configs = {"-DBUILD_TESTS=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
  33. table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  36. import("package.tools.cmake").install(package, configs)
  37. end)
  38. on_test(function (package)
  39. assert(package:has_cfuncs("mysofa_open", {includes = "mysofa.h"}))
  40. end)