xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("woff2")
  2. set_homepage("https://github.com/google/woff2")
  3. set_description("Font compression reference code.")
  4. set_license("MIT")
  5. add_urls("https://github.com/google/woff2/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/google/woff2.git", {submodules = false})
  7. add_versions("v1.0.2", "add272bb09e6384a4833ffca4896350fdb16e0ca22df68c0384773c67a175594")
  8. add_patches("v1.0.2", path.join(os.scriptdir(), "patches", "missing-gcc15-header.diff"), "357213b88875a61af3f83d1082129a59e6caa1ea6c25e272543d2875a1abadf4")
  9. if is_plat("windows") then
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. end
  12. add_deps("cmake")
  13. if is_plat("cross", "linux", "mingw") then
  14. add_deps("brotli", {configs = {shared = true}})
  15. else
  16. add_deps("brotli")
  17. end
  18. on_check("mingw", function (package)
  19. if is_subhost("macosx") then
  20. raise("package(woff2) is unsupported on Mac OS X subhost.")
  21. end
  22. end)
  23. on_install(function (package)
  24. local configs = {"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  27. import("package.tools.cmake").install(package, configs, {packagedeps = {"brotli", "brotlienc", "brotlidec"}})
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. #include <woff2/output.h>
  32. void test() {
  33. uint8_t *ttf = new uint8_t[1024];
  34. woff2::WOFF2MemoryOut out(ttf, 1024);
  35. }
  36. ]]}, {configs = {languages = "c++11"}}))
  37. end)