2
0

xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package("libsndfile")
  2. set_homepage("https://libsndfile.github.io/libsndfile/")
  3. set_description("A C library for reading and writing sound files containing sampled audio data.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/libsndfile/libsndfile/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libsndfile/libsndfile.git")
  7. add_versions("1.2.2", "ffe12ef8add3eaca876f04087734e6e8e029350082f3251f565fa9da55b52121")
  8. add_versions("1.0.31", "8cdee0acb06bb0a3c1a6ca524575643df8b1f3a55a0893b4dd9f829d08263785")
  9. add_deps("cmake", "libflac", "libopus", "libvorbis", "libogg")
  10. on_load("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  11. if package:config("shared") then
  12. package:add("deps", "python 3.x", {kind = "binary"})
  13. end
  14. end)
  15. on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  16. local configs = {}
  17. table.insert(configs, "-DBUILD_PROGRAMS=OFF")
  18. table.insert(configs, "-DBUILD_EXAMPLES=OFF")
  19. table.insert(configs, "-DBUILD_TESTING=OFF")
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. table.insert(configs, "-DENABLE_MPEG=OFF")
  23. if package:is_plat("windows", "mingw") then
  24. -- libsndfile doesn't build well with a static libFLAC, this fixes it
  25. if not package:dep("libflac"):config("shared") then
  26. local cmake = io.open("CMakeLists.txt", "a")
  27. cmake:write("add_definitions(-DFLAC__NO_DLL)\n")
  28. cmake:close()
  29. end
  30. end
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:has_cfuncs("sf_version_string", {includes = "sndfile.h"}))
  35. end)