xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("faad2")
  2. set_homepage("https://sourceforge.net/projects/faac")
  3. set_description("FAAD2 is a HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder.")
  4. set_license("GPL-2.0")
  5. add_urls("https://github.com/knik0/faad2/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. return version:gsub("%.", "_")
  7. end})
  8. add_versions("2.10.0", "0c6d9636c96f95c7d736f097d418829ced8ec6dbd899cc6cc82b728480a84bfb")
  9. if not is_plat("windows") then
  10. add_deps("autoconf", "automake", "libtool")
  11. end
  12. on_install("windows", function (package)
  13. if package:is_plat("windows") then
  14. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  15. if tonumber(vs) < 2019 then
  16. raise("Your compiler is too old to use this library.")
  17. end
  18. end
  19. os.cd("project/msvc")
  20. local configs = {"faad2.sln"}
  21. table.insert(configs, "/p:Configuration=" .. (package:debug() and "Debug" or "Release"))
  22. table.insert(configs, "/p:Platform=" .. (package:is_arch("x64") and "x64" or "Win32"))
  23. import("package.tools.msbuild").build(package, configs)
  24. os.cp("../../include/*.h", package:installdir("include"))
  25. os.cd(path.join("bin", package:debug() and "Debug" or "Release"))
  26. os.cp("faad.exe", package:installdir("bin"))
  27. if package:config("shared") then
  28. os.cp("libfaad2_dll.dll", package:installdir("bin"))
  29. os.cp("libfaad2_dll.lib", package:installdir("lib"))
  30. else
  31. os.cp("libfaad.lib", package:installdir("lib"))
  32. end
  33. package:addenv("PATH", "bin")
  34. end)
  35. on_install("macosx", "linux", function (package)
  36. local configs = {}
  37. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  38. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  39. if package:config("pic") ~= false then
  40. table.insert(configs, "--with-pic")
  41. end
  42. local libtool = package:dep("libtool")
  43. if libtool then
  44. os.vrun("autoreconf --force --install -I" .. libtool:installdir("share", "aclocal"))
  45. else
  46. os.vrun("autoreconf --force --install")
  47. end
  48. import("package.tools.autoconf").install(package, configs)
  49. package:addenv("PATH", "bin")
  50. end)
  51. on_test(function (package)
  52. assert(package:has_cfuncs("NeAACDecInit", {includes = "neaacdec.h"}))
  53. end)