xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.4.1", "8ffbe944e74043d0d3fb53d4a2a14c94de71f58dbea6a06d0dc92369542958ea")
  8. add_versions("v2.1.1", "af173e90fce65f80722fa894e1af0d6b07572292e76de7b65273df4c0a8be678")
  9. if is_plat("linux") then
  10. add_syslinks("pthread", "rt")
  11. end
  12. add_deps("meson", "ninja", "nasm")
  13. on_load("windows", function (package)
  14. if package:is_plat("windows") and package:is_arch("arm.*") and (not package:is_precompiled()) then
  15. package:add("deps", "strawberry-perl")
  16. end
  17. end)
  18. on_install("windows", "linux", function (package)
  19. if package:version():ge("2.4.1") then
  20. import("package.tools.meson")
  21. local opt = {}
  22. opt.envs = meson.buildenvs(package)
  23. -- add gas-preprocessor to PATH
  24. if package:is_plat("windows") and package:is_arch("arm.*") then
  25. opt.envs.PATH = path.join(os.programdir(), "scripts") .. path.envsep() .. opt.envs.PATH
  26. end
  27. if package:is_plat("linux") and package:has_tool("cc", "clang", "clangxx") then
  28. opt.ldflags = "-lstdc++"
  29. opt.shflags = "-lstdc++"
  30. end
  31. local configs = {"-Dtests=disabled"}
  32. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  33. meson.install(package, configs, opt)
  34. else
  35. import("package.tools.meson").build(package, {"-Dtests=disabled"}, {buildir = "out"})
  36. import("package.tools.ninja").install(package, {}, {buildir = "out"})
  37. if package:config("shared") then
  38. os.tryrm(path.join(package:installdir("lib"), "libopenh264.a"))
  39. else
  40. os.tryrm(path.join(package:installdir("lib"), "libopenh264.so*"))
  41. os.tryrm(path.join(package:installdir("lib"), "openh264.lib"))
  42. os.tryrm(path.join(package:installdir("bin"), "openh264-*.dll"))
  43. end
  44. if package:is_plat("windows") then
  45. os.trymv(path.join(package:installdir("lib"), "libopenh264.a"), path.join(package:installdir("lib"), "openh264.lib"))
  46. end
  47. end
  48. end)
  49. on_test(function (package)
  50. assert(package:has_cxxfuncs("WelsGetCodecVersion", {includes = "wels/codec_api.h"}))
  51. end)