xmake.lua 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package("pango")
  2. set_homepage("https://www.pango.org/")
  3. set_description("Framework for layout and rendering of i18n text")
  4. set_license("LGPL-2.0")
  5. add_urls("https://gitlab.gnome.org/GNOME/pango/-/archive/$(version)/pango-$(version).tar.gz",
  6. "https://gitlab.gnome.org/GNOME/pango.git")
  7. add_versions("1.51.1", "ea92cd570cdba62ca52cc0a7c9ea3cd311b6da3f0328a5aa8a4a81b0a74944a5")
  8. add_versions("1.50.3", "4a8b0cf33d5f9ecaa9cd99dd72703d5c4c53bc58df64dd9538493bb4356ab691")
  9. add_configs("fontconfig", {description = "Build with FontConfig support", default = true, type = "boolean"})
  10. add_configs("cairo", {description = "Build with cairo support", default = true, type = "boolean"})
  11. add_configs("freetype", {description = "Build with freetype support", default = true, type = "boolean"})
  12. if is_plat("linux") then
  13. add_configs("libthai", {description = "Build with libthai support", default = true, type = "boolean"})
  14. end
  15. if is_plat("mingw") and is_subhost("msys") then
  16. add_extsources("pacman::pango")
  17. elseif is_plat("linux") then
  18. add_extsources("apt::libpango-1.0-0", "pacman::pango")
  19. elseif is_plat("macosx") then
  20. add_extsources("brew::pango")
  21. end
  22. add_deps("meson", "ninja")
  23. add_deps("fribidi", "glib")
  24. add_deps("harfbuzz", {configs = {glib = true}})
  25. add_includedirs("include", "include/pango-1.0")
  26. on_load(function (package)
  27. for _, name in ipairs({"fontconfig", "cairo", "freetype", "libthai"}) do
  28. if package:config(name) then
  29. package:add("deps", name)
  30. end
  31. end
  32. if package:config("fontconfig") then
  33. if package:is_plat("windows", "mingw", "msys", "cygwin") then
  34. -- fontconfig symbols are absorbed into pango.dll and re-exported by Meson.
  35. -- Linking both pango and fontconfig downstream will cause symbol duplication.
  36. package:add("deps", "fontconfig", {configs = {shared = package:config("shared")}})
  37. else
  38. package:add("deps", "fontconfig")
  39. end
  40. end
  41. end)
  42. on_install("windows|!arm*", "macosx", "linux", "cross", "mingw", function (package)
  43. import("package.tools.meson")
  44. io.gsub("meson.build", "subdir%('tests'%)", "")
  45. io.gsub("meson.build", "subdir%('fuzzing'%)", "")
  46. io.gsub("meson.build", "subdir%('docs'%)", "")
  47. io.gsub("meson.build", "subdir%('examples'%)", "")
  48. io.gsub("meson.build", "subdir%('utils'%)", "")
  49. io.gsub("meson.build", "subdir%('tools'%)", "")
  50. io.replace("meson.build", "[ 'CoreFoundation', 'ApplicationServices' ]", "[ 'CoreFoundation', 'ApplicationServices', 'Foundation' ]", {plain = true})
  51. io.replace("meson.build", "dependency('gi-docgen'", "dependency(''", {plain = true})
  52. io.replace("meson.build", "fallback: ['gi-docgen', 'dummy_dep']", "fallback: ['dummy_dep']", {plain = true})
  53. -- fix unexpected -Werror=unused-but-set-variable errors, see https://gitlab.gnome.org/GNOME/pango/-/issues/693
  54. io.replace("meson.build", "'-Werror=unused-but-set-variable',", "", {plain = true})
  55. -- fix unexpected -Werror=array-bounds errors, see https://gitlab.gnome.org/GNOME/pango/-/issues/740
  56. io.replace("meson.build", "'-Werror=array-bounds',", "", {plain = true})
  57. if not package:is_plat("linux") and package:dep("libintl") and package:dep("libintl"):is_system() then
  58. io.replace("meson.build", "subdir('pango')", "pango_deps += cc.find_library('intl')\nsubdir('pango')", {plain = true})
  59. end
  60. local configs = {"-Dintrospection=disabled", "-Dgtk_doc=false"}
  61. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  62. for _, name in ipairs({"fontconfig", "cairo", "freetype", "libthai"}) do
  63. table.insert(configs, "-D" .. name .. "=" .. (package:config(name) and "enabled" or "disabled"))
  64. end
  65. local envs = meson.buildenvs(package)
  66. if envs.LDFLAGS then
  67. -- workaround for https://github.com/xmake-io/xmake/issues/4412
  68. envs.LDFLAGS = string.gsub(envs.LDFLAGS, "%-libpath:", "/libpath:")
  69. end
  70. local cxflags
  71. if package:is_plat("windows", "mingw") and not package:dep("cairo"):config("shared") then
  72. cxflags = "-DCAIRO_WIN32_STATIC_BUILD=1"
  73. end
  74. meson.install(package, configs, {envs = envs, cxflags = cxflags})
  75. end)
  76. on_test(function (package)
  77. assert(package:has_cfuncs("pango_layout_set_text", {includes = "pango/pangocairo.h"}))
  78. end)