xmake.lua 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package("openh264")
  2. set_homepage("http://www.openh264.org/")
  3. set_description("OpenH264 is a codec library which supports H.264 encoding and decoding.")
  4. set_license("BSD-2-Clause")
  5. set_urls("https://github.com/cisco/openh264/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/cisco/openh264.git")
  7. add_versions("v2.6.0", "558544ad358283a7ab2930d69a9ceddf913f4a51ee9bf1bfb9e377322af81a69")
  8. add_versions("v2.5.0", "94c8ca364db990047ec4ec3481b04ce0d791e62561ef5601443011bdc00825e3")
  9. add_versions("v2.4.1", "8ffbe944e74043d0d3fb53d4a2a14c94de71f58dbea6a06d0dc92369542958ea")
  10. add_versions("v2.1.1", "af173e90fce65f80722fa894e1af0d6b07572292e76de7b65273df4c0a8be678")
  11. if is_plat("linux", "bsd") then
  12. add_syslinks("pthread", "rt")
  13. end
  14. add_deps("meson", "ninja", "nasm")
  15. if on_check then
  16. on_check("android", function (package)
  17. local ndk = package:toolchain("ndk"):config("ndkver")
  18. assert(ndk and tonumber(ndk) > 22, "package(openh264) require ndk version > 22")
  19. end)
  20. end
  21. on_load("windows", function (package)
  22. if package:is_arch("arm.*") and (not package:is_precompiled()) then
  23. package:add("deps", "strawberry-perl")
  24. end
  25. end)
  26. on_install("!bsd and !wasm", function (package)
  27. io.replace("meson.build", "-Werror", "", {plain = true})
  28. if package:gitref() or package:version():ge("2.4.1") then
  29. import("package.tools.meson")
  30. local opt = {}
  31. opt.envs = meson.buildenvs(package)
  32. -- add gas-preprocessor to PATH
  33. if package:is_plat("windows") and package:is_arch("arm.*") then
  34. opt.envs.PATH = path.join(os.programdir(), "scripts") .. path.envsep() .. opt.envs.PATH
  35. end
  36. local configs = {"-Dtests=disabled"}
  37. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  38. meson.install(package, configs, opt)
  39. else
  40. import("package.tools.meson").build(package, {"-Dtests=disabled"}, {buildir = "out"})
  41. import("package.tools.ninja").install(package, {}, {buildir = "out"})
  42. if package:config("shared") then
  43. os.tryrm(path.join(package:installdir("lib"), "libopenh264.a"))
  44. else
  45. os.tryrm(path.join(package:installdir("lib"), "libopenh264.so*"))
  46. os.tryrm(path.join(package:installdir("lib"), "libopenh264.dylib"))
  47. os.tryrm(path.join(package:installdir("lib"), "openh264.lib"))
  48. os.tryrm(path.join(package:installdir("bin"), "openh264-*.dll"))
  49. end
  50. if package:is_plat("windows") then
  51. os.trymv(path.join(package:installdir("lib"), "libopenh264.a"), path.join(package:installdir("lib"), "openh264.lib"))
  52. end
  53. end
  54. end)
  55. on_test(function (package)
  56. assert(package:has_cxxfuncs("WelsGetCodecVersion", {includes = "wels/codec_api.h"}))
  57. end)