xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. if is_plat("windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. add_deps("cmake")
  12. if is_plat("cross", "linux", "mingw") then
  13. add_deps("brotli", {configs = {shared = true}})
  14. else
  15. add_deps("brotli")
  16. end
  17. on_check("mingw", function (package)
  18. if is_subhost("macosx") then
  19. raise("package(woff2) is unsupported on Mac OS X subhost.")
  20. end
  21. end)
  22. on_install(function (package)
  23. local configs = {"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  25. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  26. import("package.tools.cmake").install(package, configs, {packagedeps = {"brotli", "brotlienc", "brotlidec"}})
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. #include <woff2/output.h>
  31. void test() {
  32. uint8_t *ttf = new uint8_t[1024];
  33. woff2::WOFF2MemoryOut out(ttf, 1024);
  34. }
  35. ]]}, {configs = {languages = "c++11"}}))
  36. end)