From 010625bef1c7367a3b0a5ed336f34c61ca601298 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 13:52:19 +0300 Subject: [PATCH] (#25092) pango: add v1.54.0, enable libxft, freetype and fontconfig by default, add introspection support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pango: Fix some component requires * Bump fontconfig to fix dependency conflict in libxft * Add missing comma * pango: add v1.54.0 * pango: use version ranges for meson and pkgconf * pango: improve with_xft handling * pango: enable freetype and fontconfig by default * pango: add introspection support * pango: revert propagation of option values to cairo * Fix some issues in the recipe after inspecting meson.build --------- Co-authored-by: ErniGH * Try to solve Windows compilation issues * pango: add URLs to meson.build references in comments * Add missing freetype requirement on pango, this might be overlinking but ok --------- Co-authored-by: Jordan Williams Co-authored-by: Ernesto de Gracia Herranz Co-authored-by: Abril Rincón Blanco --- recipes/pango/all/conandata.yml | 3 + recipes/pango/all/conanfile.py | 129 +++++++++++++++++++++----------- recipes/pango/config.yml | 2 + 3 files changed, 90 insertions(+), 44 deletions(-) diff --git a/recipes/pango/all/conandata.yml b/recipes/pango/all/conandata.yml index c28a2cc9181bb..c6a58de488d3e 100644 --- a/recipes/pango/all/conandata.yml +++ b/recipes/pango/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.54.0": + url: "https://download.gnome.org/sources/pango/1.54/pango-1.54.0.tar.xz" + sha256: "8a9eed75021ee734d7fc0fdf3a65c3bba51dfefe4ae51a9b414a60c70b2d1ed8" "1.51.0": url: "https://download.gnome.org/sources/pango/1.51/pango-1.51.0.tar.xz" sha256: "74efc109ae6f903bbe6af77eaa2ac6094b8ee245a2e23f132a7a8f0862d1a9f5" diff --git a/recipes/pango/all/conanfile.py b/recipes/pango/all/conanfile.py index 927f6200bed62..b822fb21641da 100644 --- a/recipes/pango/all/conanfile.py +++ b/recipes/pango/all/conanfile.py @@ -3,6 +3,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os from conan.tools.env import VirtualBuildEnv from conan.tools.files import chdir, copy, get, rename, replace_in_file, rm, rmdir from conan.tools.gnu import PkgConfigDeps @@ -31,26 +32,32 @@ class PangoConan(ConanFile): "with_xft": [True, False], "with_freetype": [True, False], "with_fontconfig": [True, False], + "with_introspection": [True, False], } default_options = { "shared": False, "fPIC": True, "with_libthai": False, "with_cairo": True, - "with_xft": False, - "with_freetype": False, - "with_fontconfig": False, + "with_xft": True, + # TODO: Currently can't actually disable this in Macos at least, + # it always shows up as detected in meson + "with_freetype": True, + "with_fontconfig": True, + "with_introspection": False, } def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os not in ["FreeBSD", "Linux"]: + del self.options.with_xft - if self.settings.os in ["FreeBSD", "Linux"]: - self.options.with_xft = True - if not self.settings.os in ["Macos", "Windows"]: - self.options.with_freetype = True - self.options.with_fontconfig = True + # Optional in Windows/Macos but false by default + # https://gitlab.gnome.org/GNOME/pango/-/blob/1.54.0/meson.build#L242 + if self.settings.os in ["Macos", "Windows"]: + self.options.with_fontconfig = False + self.options.with_freetype = False def configure(self): if self.options.shared: @@ -64,16 +71,10 @@ def layout(self): def requirements(self): if self.options.with_freetype: self.requires("freetype/2.13.2") - if self.options.with_fontconfig: self.requires("fontconfig/2.15.0") - if self.options.with_xft: + if self.options.get_safe("with_xft"): self.requires("libxft/2.3.8") - if ( - self.options.with_xft - and self.options.with_fontconfig - and self.options.with_freetype - ): self.requires("xorg/system") # for xorg::xrender if self.options.with_cairo: # "pango/pangocairo.h" includes "cairo.h" @@ -89,19 +90,25 @@ def validate(self): and Version(self.settings.compiler.version) < "5" ): raise ConanInvalidConfiguration(f"{self.name} does not support GCC before version 5. Contributions are welcome.") - if self.options.with_xft and not self.settings.os in ["Linux", "FreeBSD"]: - raise ConanInvalidConfiguration("Xft can only be used on Linux and FreeBSD") - if self.options.with_xft and ( - not self.options.with_freetype or not self.options.with_fontconfig - ): - raise ConanInvalidConfiguration("Xft requires freetype and fontconfig") + if self.options.get_safe("with_xft"): + if not self.options.with_freetype or not self.options.with_fontconfig: + raise ConanInvalidConfiguration(f"-o=&:with_xft=True requires -o=&:with_freetype=True and -o=&:with_fontconfig=True") if self.dependencies["glib"].options.shared and is_msvc_static_runtime(self): raise ConanInvalidConfiguration( "Linking shared glib with the MSVC static runtime is not supported" ) + # Can't be turned off outside Macos/Windows + # https://gitlab.gnome.org/GNOME/pango/-/blob/1.54.0/meson.build#L240 + if self.settings.os not in ["Macos", "Windows"] and not self.options.with_fontconfig: + raise ConanInvalidConfiguration(f"{self.ref} requires -o=&:with_fontconfig=True for {self.settings.os}") + + if (self.options.with_fontconfig and self.options.with_freetype + and not self.dependencies["cairo"].options.with_fontconfig): + raise ConanInvalidConfiguration(f"{self.ref} with -o=&:with_fontconfig=True and -o=&:with_freetype=True requires -o=cairo/*:with_fontconfig=True") + if self.options.shared: if not self.dependencies["glib"].options.shared: raise ConanInvalidConfiguration( @@ -118,33 +125,43 @@ def validate(self): def build_requirements(self): self.tool_requires("glib/") - self.tool_requires("meson/1.4.0") + self.tool_requires("meson/[>=1.2.3 <2]") if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): - self.tool_requires("pkgconf/2.1.0") + self.tool_requires("pkgconf/[>=2.2 <3]") + if self.options.with_introspection: + self.tool_requires("gobject-introspection/1.78.1") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): - virtual_build_env = VirtualBuildEnv(self) - virtual_build_env.generate() - pkg_config_deps = PkgConfigDeps(self) - pkg_config_deps.generate() + VirtualBuildEnv(self).generate() + + deps = PkgConfigDeps(self) + if self.options.with_introspection: + # gnome.generate_gir() in Meson looks for gobject-introspection-1.0.pc + deps.build_context_activated = ["gobject-introspection"] + deps.generate() + + enabled_disabled = lambda opt: "enabled" if opt else "disabled" tc = MesonToolchain(self) - tc.project_options["introspection"] = "disabled" - tc.project_options["libthai"] = "enabled" if self.options.with_libthai else "disabled" - tc.project_options["cairo"] = "enabled" if self.options.with_cairo else "disabled" - tc.project_options["xft"] = "enabled" if self.options.with_xft else "disabled" - tc.project_options["fontconfig"] = "enabled" if self.options.with_fontconfig else "disabled" - tc.project_options["freetype"] = "enabled" if self.options.with_freetype else "disabled" + tc.project_options["introspection"] = enabled_disabled(self.options.with_introspection) + tc.project_options["libthai"] = enabled_disabled(self.options.with_libthai) + tc.project_options["cairo"] = enabled_disabled(self.options.with_cairo) + tc.project_options["xft"] = enabled_disabled(self.options.get_safe("with_xft")) + tc.project_options["fontconfig"] = enabled_disabled(self.options.with_fontconfig) + tc.project_options["freetype"] = enabled_disabled(self.options.with_freetype) tc.generate() - def build(self): + def _patch_sources(self): meson_build = os.path.join(self.source_folder, "meson.build") replace_in_file(self, meson_build, "subdir('tests')", "") replace_in_file(self, meson_build, "subdir('tools')", "") replace_in_file(self, meson_build, "subdir('utils')", "") replace_in_file(self, meson_build, "subdir('examples')", "") + + def build(self): + self._patch_sources() meson = Meson(self) meson.configure() meson.build() @@ -164,6 +181,9 @@ def package(self): self._fix_library_names(os.path.join(self.package_folder, "lib")) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rm(self, "*.pdb", self.package_folder, recursive=True) + if self.options.with_introspection: + os.rename(os.path.join(self.package_folder, "share"), + os.path.join(self.package_folder, "res")) def package_info(self): self.cpp_info.components["pango_"].libs = ["pango-1.0"] @@ -178,41 +198,57 @@ def package_info(self): if self.options.with_fontconfig: self.cpp_info.components["pango_"].requires.append("fontconfig::fontconfig") - if self.options.with_xft: - self.cpp_info.components["pango_"].requires.append("libxft::libxft") - # Pango only uses xrender when Xft, fontconfig and freetype are enabled - if self.options.with_fontconfig and self.options.with_freetype: - self.cpp_info.components["pango_"].requires.append("xorg::xrender") + if self.options.get_safe("with_xft"): + # Pango only uses xrender when Xft, fontconfig and freetype are enabled, which if with_xft is true, + # means that the other options are true because they are checked in the validate() method + self.cpp_info.components["pango_"].requires.extend(["libxft::libxft", "xorg::xrender"]) if self.options.with_cairo: self.cpp_info.components["pango_"].requires.append("cairo::cairo_") self.cpp_info.components["pango_"].includedirs = [ os.path.join(self.package_folder, "include", "pango-1.0") ] - if self.options.with_freetype: + if self.options.with_introspection: + self.cpp_info.components["pango_"].resdirs = ["res"] + self.buildenv_info.append_path("GI_GIR_PATH", os.path.join(self.package_folder, "res", "gir-1.0")) + self.buildenv_info.append_path("GI_TYPELIB_PATH", os.path.join(self.package_folder, "lib", "girepository-1.0")) + self.env_info.GI_GIR_PATH.append(os.path.join(self.package_folder, "res", "gir-1.0")) + self.env_info.GI_TYPELIB_PATH.append(os.path.join(self.package_folder, "lib", "girepository-1.0")) + + # From meson.build: "To build pangoft2, we need HarfBuzz, FontConfig and FreeType" + if self.options.with_freetype and self.options.with_fontconfig: self.cpp_info.components["pangoft2"].libs = ["pangoft2-1.0"] self.cpp_info.components["pangoft2"].set_property("pkg_config_name", "pangoft2") self.cpp_info.components["pangoft2"].requires = [ "pango_", "freetype::freetype", + "fontconfig::fontconfig", ] self.cpp_info.components["pangoft2"].includedirs = [ os.path.join(self.package_folder, "include", "pango-1.0") ] + # https://gitlab.gnome.org/GNOME/pango/-/blob/1.54.0/meson.build#L320 + self.cpp_info.components["pango_"].requires.append("freetype::freetype") + if self.options.with_fontconfig: self.cpp_info.components["pangofc"].set_property("pkg_config_name", "pangofc") if self.options.with_freetype: - self.cpp_info.components["pangofc"].requires = ["pangoft2"] + # pangoft2 is always built if pango has fontconfig and freetype support + self.cpp_info.components["pangofc"].requires = ["freetype::freetype", "harfbuzz::harfbuzz", "pangoft2"] + elif self.options.with_freetype: + self.cpp_info.components["pango_"].requires.append("freetype::freetype") if self.settings.os != "Windows": self.cpp_info.components["pangoroot"].set_property("pkg_config_name", "pangoroot") if self.options.with_freetype: self.cpp_info.components["pangoroot"].requires = ["pangoft2"] - if self.options.with_xft: + if self.options.get_safe("with_xft"): self.cpp_info.components["pangoxft"].libs = ["pangoxft-1.0"] self.cpp_info.components["pangoxft"].set_property("pkg_config_name", "pangoxft") + # pangoft2 is always built if pango has fontconfig and freetype support, + # which is always true if pango has xft support enabled self.cpp_info.components["pangoxft"].requires = ["pango_", "pangoft2"] self.cpp_info.components["pangoxft"].includedirs = [ os.path.join(self.package_folder, "include", "pango-1.0") @@ -226,11 +262,16 @@ def package_info(self): if Version(self.version) >= "1.50.12": self.cpp_info.components["pangowin32"].system_libs.append("dwrite") + if is_apple_os(self): + # https://gitlab.gnome.org/GNOME/pango/-/blob/1.54.0/meson.build#L333-346 + self.cpp_info.components["pango_"].frameworks.extend(["CoreText", "CoreFoundation", "ApplicationServices"]) + if self.options.with_cairo: self.cpp_info.components["pangocairo"].libs = ["pangocairo-1.0"] self.cpp_info.components["pangocairo"].set_property("pkg_config_name", "pangocairo") - self.cpp_info.components["pangocairo"].requires = ["pango_"] - if self.options.with_freetype: + self.cpp_info.components["pangocairo"].requires = ["pango_", "cairo::cairo_"] + if self.options.with_freetype and self.options.with_fontconfig: + # https://gitlab.gnome.org/GNOME/pango/-/blob/1.54.0/meson.build#L506 self.cpp_info.components["pangocairo"].requires.append("pangoft2") if self.settings.os == "Windows": self.cpp_info.components["pangocairo"].requires.append("pangowin32") diff --git a/recipes/pango/config.yml b/recipes/pango/config.yml index 9086309110a6b..2d198a63c6b11 100644 --- a/recipes/pango/config.yml +++ b/recipes/pango/config.yml @@ -1,4 +1,6 @@ versions: + "1.54.0": + folder: all "1.51.0": folder: all "1.50.14":