From 5b0d226d67009a855000050dcf256e167164853f Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 15 Aug 2022 18:36:23 +0100 Subject: [PATCH 01/16] [cairo] do not rename the parent pkg-config package --- recipes/cairo/meson/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 3e6bf31ce3bda..055731f4bd841 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -228,7 +228,6 @@ def package(self): tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") def package_info(self): - self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) if self.settings.os == "Linux": From 85e8ff59a7727f18d4f720a27662ef20b6eaa497 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 15 Aug 2022 19:37:56 +0100 Subject: [PATCH 02/16] [cairo] refactor and simplify package_info method --- recipes/cairo/all/conanfile.py | 11 --- recipes/cairo/meson/conanfile.py | 159 +++++++++---------------------- 2 files changed, 47 insertions(+), 123 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 458b1f67cd794..b37cd3021266e 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -224,9 +224,7 @@ def package(self): self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - def package_info(self): - self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) self.cpp_info.components["cairo_"].requires = ["pixman::pixman", "libpng::libpng", "zlib::zlib"] @@ -255,33 +253,24 @@ def package_info(self): if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": - self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_", "pixman::pixman", "libpng::libpng"] if self.options.get_safe("with_glib", True): - self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] if self.settings.os != "Windows": if self.options.with_fontconfig: - self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] if self.options.get_safe("with_freetype", True): - self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] - self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] if self.settings.os == "Linux": if self.options.with_xlib: - self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics"]) - self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 055731f4bd841..312e12c5bbd40 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -228,6 +228,16 @@ def package(self): tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") def package_info(self): + base_requirements = {"pixman::pixman"} + base_system_libs = {} + + def add_component_and_base_requirements(component, requirements, system_libs=None): + self.cpp_info.components[component].requires += ["cairo_"] + requirements + base_requirements.update(set(requirements)) + if system_libs is not None: + self.cpp_info.components[component].system_libs += system_libs + base_system_libs.update(set(system_libs)) + self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) if self.settings.os == "Linux": @@ -241,148 +251,73 @@ def package_info(self): if self.options.with_zlib: self.cpp_info.components["cairo_"].requires.append("zlib::zlib") if self.options.with_png: - self.cpp_info.components["cairo_"].requires.append("libpng::libpng") - if self.options.with_fontconfig: - self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") - if self.options.with_freetype: - self.cpp_info.components["cairo_"].requires.append("freetype::freetype") - if self.options.get_safe("with_xlib"): - self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if self.options.get_safe("with_xlib_xrender"): - self.cpp_info.components["cairo_"].requires.append("xorg::xrender") - if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb", "xorg::xcb-render", "xorg::xcb-shm"]) - if self.options.get_safe("with_xlib") and self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo_"].requires.append("xorg::x11-xcb") - if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) - if not self.options.shared: - self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") - if self.options.get_safe("with_opengl") == "desktop": - self.cpp_info.components["cairo_"].requires.append("opengl::opengl") - if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].requires.extend(["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) - if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["cairo_"].requires.append("egl::egl") - if self.options.get_safe("with_opengl") == "gles2" or self.options.get_safe("with_opengl") == "gles3": - self.cpp_info.components["cairo_"].system_libs.append("GLESv2") - self.cpp_info.components["cairo_"].requires.append("pixman::pixman") - - # built-features - if self.options.with_png: - self.cpp_info.components["cairo-png"].names["pkg_config"] = "cairo-png" - self.cpp_info.components["cairo-png"].requires = ["cairo_", "libpng::libpng"] - - if self.options.with_png: - self.cpp_info.components["cairo-svg"].names["pkg_config"] = "cairo-svg" - self.cpp_info.components["cairo-svg"].requires = ["cairo_", "libpng::libpng"] - + add_component_and_base_requirements("cairo-png", ["libpng::libpng"]) + add_component_and_base_requirements("cairo-svg", ["libpng::libpng"]) if self.options.with_fontconfig: - self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" - self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] - + add_component_and_base_requirements("cairo-fc", ["fontconfig::fontconfig"]) if self.options.with_freetype: - self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" - self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] - + add_component_and_base_requirements("cairo-ft", ["freetype::freetype"]) if self.options.get_safe("with_xlib"): - self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" - self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] - + add_component_and_base_requirements("cairo-xlib", ["xorg::x11", "xorg::xext"]) if self.options.get_safe("with_xlib_xrender"): - self.cpp_info.components["cairo-xlib-xrender"].names["pkg_config"] = "cairo-xlib-xrender" - self.cpp_info.components["cairo-xlib-xrender"].requires = ["cairo_", "xorg::xrender"] - - if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xcb"].names["pkg_config"] = "cairo-xcb" - self.cpp_info.components["cairo-xcb"].requires = ["cairo_", "xorg::xcb", "xorg::xcb-render"] - - if self.options.get_safe("with_xlib") and self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xlib-xcb"].names["pkg_config"] = "cairo-xlib-xcb" - self.cpp_info.components["cairo-xlib-xcb"].requires = ["cairo_", "xorg::x11-xcb"] - + add_component_and_base_requirements("cairo-xlib-xrender", ["xorg::xrender"]) if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xcb-shm"].names["pkg_config"] = "cairo-xcb-shm" - self.cpp_info.components["cairo-xcb-shm"].requires = ["cairo_", "xorg::xcb-shm"] + add_component_and_base_requirements("cairo-xcb", ["xorg::xcb", "xorg::xcb-render"]) + add_component_and_base_requirements("cairo-xcb-shm", ["xorg::xcb", "xorg::xcb-shm"]) + if self.options.get_safe("with_xlib"): + add_component_and_base_requirements("cairo-xlib-xcb", ["xorg::x11-xcb"]) if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" + self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] - - self.cpp_info.components["cairo-quartz-image"].names["pkg_config"] = "cairo-quartz-image" self.cpp_info.components["cairo-quartz-image"].requires = ["cairo_"] - - self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] if self.settings.os == "Windows": - self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) self.cpp_info.components["cairo-win32"].requires = ["cairo_"] - - self.cpp_info.components["cairo-win32-font"].names["pkg_config"] = "cairo-win32-font" self.cpp_info.components["cairo-win32-font"].requires = ["cairo_"] + if not self.options.shared: + self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") - if self.options.get_safe("with_opengl") == "desktop": - self.cpp_info.components["cairo-gl"].names["pkg_config"] = "cairo-gl" - self.cpp_info.components["cairo-gl"].requires = ["cairo_", "opengl::opengl"] - - if self.settings.os == "Linux": - self.cpp_info.components["cairo-glx"].names["pkg_config"] = "cairo-glx" - self.cpp_info.components["cairo-glx"].requires = ["cairo_", "opengl::opengl"] - - if self.settings.os == "Windows": - self.cpp_info.components["cairo-wgl"].names["pkg_config"] = "cairo-wgl" - self.cpp_info.components["cairo-wgl"].requires = ["cairo_", "glext::glext", "wglext::wglext"] - - if self.options.get_safe("with_opengl") == "gles2": - self.cpp_info.components["cairo-glesv2"].names["pkg_config"] = "cairo-glesv2" - self.cpp_info.components["cairo-glesv2"].requires = ["cairo_"] - self.cpp_info.components["cairo-glesv2"].system_libs = ["GLESv2"] - - if self.options.get_safe("with_opengl") == "gles3": - self.cpp_info.components["cairo-glesv3"].names["pkg_config"] = "cairo-glesv3" - self.cpp_info.components["cairo-glesv3"].requires = ["cairo_"] - self.cpp_info.components["cairo-glesv3"].system_libs = ["GLESv2"] + if self.options.get_safe("with_opengl"): + if self.options.with_opengl == "desktop": + add_component_and_base_requirements("cairo-gl", ["opengl::opengl"]) - if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["cairo-egl"].names["pkg_config"] = "cairo-egl" - self.cpp_info.components["cairo-egl"].requires = ["cairo_", "egl::egl"] + if self.settings.os == "Linux": + add_component_and_base_requirements("cairo-glx", ["opengl::opengl"]) - if self.options.with_zlib: - self.cpp_info.components["cairo-script"].names["pkg_config"] = "cairo-script" - self.cpp_info.components["cairo-script"].requires = ["cairo_", "zlib::zlib"] + if self.settings.os == "Windows": + add_component_and_base_requirements("cairo-wgl", ["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) - if self.options.with_zlib: - self.cpp_info.components["cairo-ps"].names["pkg_config"] = "cairo-ps" - self.cpp_info.components["cairo-ps"].requires = ["cairo_", "zlib::zlib"] + elif self.options.with_opengl == "gles3": + add_component_and_base_requirements("cairo-glesv3", [], ["GLESv2"]) + elif self.options.with_opengl == "gles2": + add_component_and_base_requirements("cairo-glesv2", [], ["GLESv2"]) + if self.settings.os in ["Linux", "FreeBSD"]: + add_component_and_base_requirements("cairo-egl", ["egl::egl"]) if self.options.with_zlib: - self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" - self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] + add_component_and_base_requirements("cairo-script", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-ps", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-pdf", ["zlib::zlib"]) + self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] + self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] - if self.options.with_zlib and self.options.with_png: - self.cpp_info.components["cairo-xml"].names["pkg_config"] = "cairo-xml" - self.cpp_info.components["cairo-xml"].requires = ["cairo_", "zlib::zlib"] + if self.options.with_png: + add_component_and_base_requirements("cairo-xml", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-util_", ["expat::expat"]) if self.options.tee: - self.cpp_info.components["cairo-tee"].names["pkg_config"] = "cairo-tee" self.cpp_info.components["cairo-tee"].requires = ["cairo_"] # util directory if self.options.with_glib: - self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] - if self.options.with_zlib: - self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] - self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] - - # binary tools - if self.options.with_zlib and self.options.with_png: - self.cpp_info.components["cairo_util_"].requires.append("expat::expat") # trace-to-xml.c, xml-to-trace.c + self.cpp_info.components["cairo_"].requires += list(base_requirements) + self.cpp_info.components["cairo_"].system_libs += list(base_system_libs) def package_id(self): self.info.requires["glib"].full_package_mode() From 499575d0518937d7c671cbdd5f3902c68c1db86c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 15 Aug 2022 20:14:34 +0100 Subject: [PATCH 03/16] [cairo] fix v2 linting --- recipes/cairo/all/conanfile.py | 78 ++++++++++++++++---------------- recipes/cairo/meson/conanfile.py | 54 +++++++++++----------- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index b37cd3021266e..494aeb198d8a8 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,8 +1,12 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import os import shutil +from conan import ConanFile +from conan.tools import files, microsoft +from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans import tools +from conans.errors import ConanInvalidConfiguration + class CairoConan(ConanFile): name = "cairo" @@ -56,7 +60,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if self._is_msvc: + if microsoft.is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -69,7 +73,7 @@ def configure(self): del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if self._is_msvc: + if microsoft.is_msvc(self): if self.settings.build_type not in ["Debug", "Release"]: raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") @@ -90,23 +94,19 @@ def requirements(self): def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): self.build_requires("msys2/cci.latest") - if not self._is_msvc: + if not microsoft.is_msvc(self): self.build_requires("libtool/2.4.6") self.build_requires("pkgconf/1.7.4") self.build_requires("gtk-doc-stub/cci.20181216") - @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" - def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self._is_msvc: + files.patch(self, **patch) + if microsoft.is_msvc(self): self._build_msvc() else: self._build_configure() @@ -115,13 +115,13 @@ def _build_msvc(self): with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ win32_common = os.path.join("build", "Makefile.win32.common") - tools.replace_in_file(win32_common, "-MD ", "-%s " % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, "-MDd ", "-%s " % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + files.replace_in_file(self, win32_common, "-MD ", "-%s " % self.settings.compiler.runtime) + files.replace_in_file(self, win32_common, "-MDd ", "-%s " % self.settings.compiler.runtime) + files.replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", self.deps_cpp_info["zlib"].libs[0] + ".lib") - tools.replace_in_file(win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + files.replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", self.deps_cpp_info["libpng"].libs[0] + ".lib") - tools.replace_in_file(win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + files.replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", self.deps_cpp_info["freetype"].libs[0] + ".lib") with tools.vcvars(self.settings): env_msvc = VisualStudioBuildEnvironment(self) @@ -130,13 +130,13 @@ def _build_msvc(self): env_build = AutoToolsBuildEnvironment(self) args=[ "-f", "Makefile.win32", - "CFG={}".format(str(self.settings.build_type).lower()), + f"CFG={str(self.settings.build_type).lower()}", "CAIRO_HAS_FC_FONT=0", - "ZLIB_PATH={}".format(self.deps_cpp_info["zlib"].rootpath), - "LIBPNG_PATH={}".format(self.deps_cpp_info["libpng"].rootpath), - "PIXMAN_PATH={}".format(self.deps_cpp_info["pixman"].rootpath), - "FREETYPE_PATH={}".format(self.deps_cpp_info["freetype"].rootpath), - "GOBJECT_PATH={}".format(self.deps_cpp_info["glib"].rootpath) + f"ZLIB_PATH={self.deps_cpp_info['zlib'].rootpath}", + f"LIBPNG_PATH={self.deps_cpp_info['libpng'].rootpath}", + f"PIXMAN_PATH={self.deps_cpp_info['pixman'].rootpath}", + f"FREETYPE_PATH={self.deps_cpp_info['freetype'].rootpath}", + f"GOBJECT_PATH={self.deps_cpp_info['glib'].rootpath}" ] env_build.make(args=args) @@ -146,18 +146,20 @@ def _configure_autotools(self): if self._autotools: return self._autotools + def boolean(value): + return "yes" if value else "no" + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - yes_no = lambda v: "yes" if v else "no" configure_args = [ - "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), - "--enable-ft={}".format(yes_no(self.options.with_freetype)), - "--enable-gobject={}".format(yes_no(self.options.with_glib)), - "--enable-fc={}".format(yes_no(self.options.get_safe("with_fontconfig"))), - "--enable-xlib={}".format(yes_no(self.options.get_safe("with_xlib"))), - "--enable-xlib_xrender={}".format(yes_no(self.options.get_safe("with_xlib_xrender"))), - "--enable-xcb={}".format(yes_no(self.options.get_safe("xcb"))), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), + f"--datarootdir={tools.unix_path(os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={boolean(self.options.with_freetype)}", + f"--enable-gobject={boolean(self.options.with_glib)}", + f"--enable-fc={boolean(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={boolean(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={boolean(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={boolean(self.options.get_safe('xcb'))}", + f"--enable-shared={boolean(self.options.shared)}", + f"--enable-static={boolean(not self.options.shared)}", "--disable-gtk-doc", ] if self.settings.compiler in ["gcc", "clang", "apple-clang"]: @@ -170,10 +172,10 @@ def _configure_autotools(self): def _build_configure(self): with tools.chdir(self._source_subfolder): # disable build of test suite - tools.replace_in_file(os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", + files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", "") if self.options.with_freetype: - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), + files.replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") tools.touch(os.path.join("boilerplate", "Makefile.am.features")) @@ -182,7 +184,7 @@ def _build_configure(self): with tools.environment_append({"GTKDOCIZE": "echo"}): self.run( - "{} -fiv".format(tools.get_env("AUTORECONF")), + f"{tools.get_env('AUTORECONF')} -fiv", run_environment=True, win_bash=tools.os_info.is_windows, ) @@ -191,7 +193,7 @@ def _build_configure(self): def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - if self._is_msvc: + if microsoft.is_msvc(self): src = os.path.join(self._source_subfolder, "src") cairo_gobject = os.path.join(self._source_subfolder, "util", "cairo-gobject") inc = os.path.join("include", "cairo") @@ -222,7 +224,7 @@ def package(self): tools.remove_files_by_mask(self.package_folder, "*.la") self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.components["cairo_"].libs = ["cairo"] diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 312e12c5bbd40..083e2d8cbcb4a 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -1,11 +1,15 @@ -from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import contextlib import glob import os +from conan import ConanFile +from conan.tools import files, microsoft +from conans import tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration + required_conan_version = ">=1.38.0" + class CairoConan(ConanFile): name = "cairo" description = "Cairo is a 2D graphics library with support for multiple output devices" @@ -128,13 +132,9 @@ def validate(self): "Linking a shared library against static glib can cause unexpected behaviour." ) - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["msvc", "Visual Studio"] - @contextlib.contextmanager def _build_context(self): - if self._is_msvc: + if microsoft.is_msvc(self): env_build = VisualStudioBuildEnvironment(self) if not self.options.shared: env_build.flags.append("-DCAIRO_WIN32_STATIC_BUILD") @@ -145,23 +145,25 @@ def _build_context(self): yield def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_meson(self): - yes_no = lambda v: "enabled" if v else "disabled" + def boolean(value): + return "enabled" if value else "disabled" + meson = Meson(self) defs = dict() defs["tests"] = "disabled" - defs["zlib"] = yes_no(self.options.with_zlib) - defs["png"] = yes_no(self.options.with_png) - defs["freetype"] = yes_no(self.options.with_freetype) - defs["fontconfig"] = yes_no(self.options.with_fontconfig) + defs["zlib"] = boolean(self.options.with_zlib) + defs["png"] = boolean(self.options.with_png) + defs["freetype"] = boolean(self.options.with_freetype) + defs["fontconfig"] = boolean(self.options.with_fontconfig) if self.settings.os == "Linux": - defs["xcb"] = yes_no(self.options.get_safe("with_xcb")) - defs["xlib"] = yes_no(self.options.get_safe("with_xlib")) - defs["xlib-xrender"] = yes_no(self.options.get_safe("with_xlib_xrender")) + defs["xcb"] = boolean(self.options.get_safe("with_xcb")) + defs["xlib"] = boolean(self.options.get_safe("with_xlib")) + defs["xlib-xrender"] = boolean(self.options.get_safe("with_xlib_xrender")) else: defs["xcb"] = "disabled" defs["xlib"] = "disabled" @@ -173,10 +175,10 @@ def _configure_meson(self): defs["gl-backend"] = "glesv3" else: defs["gl-backend"] = "disabled" - defs["glesv2"] = yes_no(self.options.get_safe("with_opengl") == "gles2") - defs["glesv3"] = yes_no(self.options.get_safe("with_opengl") == "gles3") - defs["tee"] = yes_no(self.options.tee) - defs["symbol-lookup"] = yes_no(self.options.get_safe("with_symbol_lookup")) + defs["glesv2"] = boolean(self.options.get_safe("with_opengl") == "gles2") + defs["glesv3"] = boolean(self.options.get_safe("with_opengl") == "gles3") + defs["tee"] = boolean(self.options.tee) + defs["symbol-lookup"] = boolean(self.options.get_safe("with_symbol_lookup")) # future options to add, see meson_options.txt. # for now, disabling explicitly, to avoid non-reproducible auto-detection of system libs @@ -198,11 +200,11 @@ def _configure_meson(self): def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + files.patch(self, **patch) # Dependency freetype2 found: NO found 2.11.0 but need: '>= 9.7.3' if self.options.with_freetype: - tools.replace_in_file("freetype2.pc", + files.replace_in_file(self, "freetype2.pc", "Version: %s" % self.deps_cpp_info["freetype"].version, "Version: 9.7.3") with self._build_context(): @@ -210,12 +212,12 @@ def build(self): meson.build() def _fix_library_names(self): - if self._is_msvc: + if microsoft.is_msvc(self): with tools.chdir(os.path.join(self.package_folder, "lib")): for filename_old in glob.glob("*.a"): filename_new = filename_old[3:-2] + ".lib" self.output.info("rename %s into %s" % (filename_old, filename_new)) - tools.rename(filename_old, filename_new) + files.rename(self, filename_old, filename_new) def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) @@ -224,8 +226,8 @@ def package(self): meson = self._configure_meson() meson.install() self._fix_library_names() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): base_requirements = {"pixman::pixman"} From 649296e99b493437388e5a168486166388a43250 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 16 Aug 2022 09:29:52 +0100 Subject: [PATCH 04/16] [cairo] provide parent pkgconfig and use set_property_name --- recipes/cairo/all/conanfile.py | 16 ++++++++++++++++ recipes/cairo/meson/conanfile.py | 23 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 494aeb198d8a8..9db585d82bb76 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -227,9 +227,13 @@ def package(self): files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) self.cpp_info.components["cairo_"].requires = ["pixman::pixman", "libpng::libpng", "zlib::zlib"] + if self.options.get_safe("with_freetype", True): self.cpp_info.components["cairo_"].requires.append("freetype::freetype") @@ -242,6 +246,7 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["glib::gobject-2.0", "glib::glib-2.0"]) if self.options.with_fontconfig: self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") + if self.settings.os == "Linux": self.cpp_info.components["cairo_"].system_libs = ["pthread"] self.cpp_info.components["cairo_"].cflags = ["-pthread"] @@ -252,27 +257,38 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb-render"]) if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) + if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].requires = ["cairo_", "pixman::pixman", "libpng::libpng"] if self.options.get_safe("with_glib", True): + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] if self.settings.os != "Windows": if self.options.with_fontconfig: + self.cpp_info.components["cairo-fc"].set_property("pkg_config_name", "cairo-fc") self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] if self.options.get_safe("with_freetype", True): + self.cpp_info.components["cairo-ft"].set_property("pkg_config_name", "cairo-ft") self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] + + self.cpp_info.components["cairo-pdf"].set_property("pkg_config_name", "cairo-pdf") self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] if self.settings.os == "Linux": if self.options.with_xlib: + self.cpp_info.components["cairo-xlib"].set_property("pkg_config_name", "cairo-xlib") self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics"]) + + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 083e2d8cbcb4a..f61580c79705f 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -234,51 +234,67 @@ def package_info(self): base_system_libs = {} def add_component_and_base_requirements(component, requirements, system_libs=None): + self.cpp_info.components[component].set_property("pkg_config_name", component) self.cpp_info.components[component].requires += ["cairo_"] + requirements base_requirements.update(set(requirements)) if system_libs is not None: self.cpp_info.components[component].system_libs += system_libs base_system_libs.update(set(system_libs)) + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) + if self.settings.os == "Linux": self.cpp_info.components["cairo_"].system_libs.extend(["m", "dl", "pthread"]) if self.options.get_safe("with_symbol_lookup"): self.cpp_info.components["cairo_"].system_libs.append("bfd") self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] + if self.options.with_lzo: self.cpp_info.components["cairo_"].requires.append("lzo::lzo") + if self.options.with_zlib: self.cpp_info.components["cairo_"].requires.append("zlib::zlib") + if self.options.with_png: add_component_and_base_requirements("cairo-png", ["libpng::libpng"]) add_component_and_base_requirements("cairo-svg", ["libpng::libpng"]) + if self.options.with_fontconfig: add_component_and_base_requirements("cairo-fc", ["fontconfig::fontconfig"]) + if self.options.with_freetype: add_component_and_base_requirements("cairo-ft", ["freetype::freetype"]) + if self.options.get_safe("with_xlib"): add_component_and_base_requirements("cairo-xlib", ["xorg::x11", "xorg::xext"]) + if self.options.get_safe("with_xlib_xrender"): add_component_and_base_requirements("cairo-xlib-xrender", ["xorg::xrender"]) + if self.options.get_safe("with_xcb"): add_component_and_base_requirements("cairo-xcb", ["xorg::xcb", "xorg::xcb-render"]) add_component_and_base_requirements("cairo-xcb-shm", ["xorg::xcb", "xorg::xcb-shm"]) + if self.options.get_safe("with_xlib"): add_component_and_base_requirements("cairo-xlib-xcb", ["xorg::x11-xcb"]) if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] self.cpp_info.components["cairo-quartz-image"].requires = ["cairo_"] self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].requires = ["cairo_"] + self.cpp_info.components["cairo-win32-font"].set_property("pkg_config_name", "cairo-win32-font") self.cpp_info.components["cairo-win32-font"].requires = ["cairo_"] + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) + if not self.options.shared: self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") @@ -303,6 +319,7 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non add_component_and_base_requirements("cairo-script", ["zlib::zlib"]) add_component_and_base_requirements("cairo-ps", ["zlib::zlib"]) add_component_and_base_requirements("cairo-pdf", ["zlib::zlib"]) + self.cpp_info.components["cairo-script-interpreter"].set_property("pkg_config_name", "cairo-script-interpreter") self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] @@ -311,10 +328,12 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non add_component_and_base_requirements("cairo-util_", ["expat::expat"]) if self.options.tee: + self.cpp_info.components["cairo-tee"].set_property("pkg_config_name", "cairo-tee") self.cpp_info.components["cairo-tee"].requires = ["cairo_"] # util directory if self.options.with_glib: + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] From d865d22953540eae81ff1b1fe99b9fa792a94cf0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 16 Aug 2022 09:32:56 +0100 Subject: [PATCH 05/16] [cairo] resolve system lib warnings --- recipes/cairo/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 9db585d82bb76..26bb030d05f40 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -248,7 +248,7 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") if self.settings.os == "Linux": - self.cpp_info.components["cairo_"].system_libs = ["pthread"] + self.cpp_info.components["cairo_"].system_libs = ["pthread", "rt"] self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] if self.options.with_xcb: @@ -288,7 +288,7 @@ def package_info(self): if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] - self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics"]) + self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics", "ApplicationServices"]) self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] From 6faf10e51936360a529da4d34a3b242d636c0ec1 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 17 Aug 2022 13:29:48 +0100 Subject: [PATCH 06/16] [cairo] v2 linting --- recipes/cairo/all/conanfile.py | 10 +++++----- recipes/cairo/meson/conanfile.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 26bb030d05f40..b8bd5b953ccd2 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -2,10 +2,10 @@ import shutil from conan import ConanFile -from conan.tools import files, microsoft +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft, scm from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment from conans import tools -from conans.errors import ConanInvalidConfiguration class CairoConan(ConanFile): @@ -115,8 +115,8 @@ def _build_msvc(self): with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ win32_common = os.path.join("build", "Makefile.win32.common") - files.replace_in_file(self, win32_common, "-MD ", "-%s " % self.settings.compiler.runtime) - files.replace_in_file(self, win32_common, "-MDd ", "-%s " % self.settings.compiler.runtime) + files.replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") files.replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", self.deps_cpp_info["zlib"].libs[0] + ".lib") files.replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", @@ -197,7 +197,7 @@ def package(self): src = os.path.join(self._source_subfolder, "src") cairo_gobject = os.path.join(self._source_subfolder, "util", "cairo-gobject") inc = os.path.join("include", "cairo") - self.copy(pattern="cairo-version.h", dst=inc, src=(src if tools.Version(self.version) >= "1.17.4" else self._source_subfolder)) + self.copy(pattern="cairo-version.h", dst=inc, src=(src if scm.Version(self.version) >= "1.17.4" else self._source_subfolder)) self.copy(pattern="cairo-features.h", dst=inc, src=src) self.copy(pattern="cairo.h", dst=inc, src=src) self.copy(pattern="cairo-deprecated.h", dst=inc, src=src) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index f61580c79705f..d2fc1b2a1241f 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -3,9 +3,9 @@ import os from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools import files, microsoft from conans import tools, Meson, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration required_conan_version = ">=1.38.0" From 283dfe05c7f7a4d0e5b417ea8b37b2f67304f821 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 17 Aug 2022 18:31:48 +0100 Subject: [PATCH 07/16] Apply review suggestion Co-authored-by: Uilian Ries --- recipes/cairo/meson/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index d2fc1b2a1241f..20071de783b70 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -7,7 +7,7 @@ from conan.tools import files, microsoft from conans import tools, Meson, VisualStudioBuildEnvironment -required_conan_version = ">=1.38.0" +required_conan_version = ">=1.50.0" class CairoConan(ConanFile): From 63a79fbf213b823046df18b52f755111a397b441 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 17 Aug 2022 18:32:45 +0100 Subject: [PATCH 08/16] Apply review suggestion Co-authored-by: Uilian Ries --- recipes/cairo/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index b8bd5b953ccd2..86ab33831feca 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -7,6 +7,8 @@ from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment from conans import tools +required_conan_version = ">=1.50.0" + class CairoConan(ConanFile): name = "cairo" From d328ae8877715aa9dfd65bfd14ad75b67f04b023 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 18 Aug 2022 21:58:16 +0100 Subject: [PATCH 09/16] [cairo] bump requirements versions --- recipes/cairo/meson/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 20071de783b70..d668b161d2796 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -107,7 +107,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.37") if self.options.with_glib: - self.requires("glib/2.73.0") + self.requires("glib/2.73.3") if self.settings.os == "Linux": if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") @@ -121,7 +121,7 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.build_requires("meson/0.62.1") + self.build_requires("meson/0.63.1") self.build_requires("pkgconf/1.7.4") def validate(self): From 5c2a656fb8c6f11d9601f54dd627a9b77d2245f4 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 19 Aug 2022 09:49:50 +0100 Subject: [PATCH 10/16] [cairo] full package mode only for static glib --- recipes/cairo/all/conanfile.py | 4 ++++ recipes/cairo/meson/conanfile.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 86ab33831feca..5a0a8cea7438a 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -294,3 +294,7 @@ def package_info(self): self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + + def package_id(self): + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index d668b161d2796..71e99c0f38763 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -341,4 +341,5 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non self.cpp_info.components["cairo_"].system_libs += list(base_system_libs) def package_id(self): - self.info.requires["glib"].full_package_mode() + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() From e2b734a1d59a9f2382091b5673650fc582dafbc1 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 19 Aug 2022 12:54:29 +0100 Subject: [PATCH 11/16] [cairo] shared glib with static msvcrt is not supported --- recipes/cairo/all/conanfile.py | 9 ++++++++- recipes/cairo/meson/conanfile.py | 14 ++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 5a0a8cea7438a..2b8cdfdd7e996 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -75,9 +75,16 @@ def configure(self): del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx + + def validate(self): if microsoft.is_msvc(self): if self.settings.build_type not in ["Debug", "Release"]: raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") + if self.options.get_safe("with_glib") and self.options["glib"].shared \ + and microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) def requirements(self): if self.options.get_safe("with_freetype", True): @@ -294,7 +301,7 @@ def package_info(self): self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] - + def package_id(self): if self.options.get_safe("with_glib") and not self.options["glib"].shared: self.info.requires["glib"].full_package_mode() diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 71e99c0f38763..34a32c73f3c49 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -127,10 +127,16 @@ def build_requirements(self): def validate(self): if self.options.get_safe("with_xlib_xrender") and not self.options.get_safe("with_xlib"): raise ConanInvalidConfiguration("'with_xlib_xrender' option requires 'with_xlib' option to be enabled as well!") - if self.options.with_glib and not self.options["glib"].shared and self.options.shared: - raise ConanInvalidConfiguration( - "Linking a shared library against static glib can cause unexpected behaviour." - ) + if self.options.with_glib: + if self.options["glib"].shared: + if microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + elif self.options.shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) @contextlib.contextmanager def _build_context(self): From 970914bc1792169590b1cfda3fedb691036e5c3d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 24 Aug 2022 18:33:16 +0100 Subject: [PATCH 12/16] [cairo] restore old pkg-config file names --- recipes/cairo/all/conanfile.py | 13 +++++++++++-- recipes/cairo/meson/conanfile.py | 24 ++++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 2b8cdfdd7e996..04139fa26eff3 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -113,8 +113,7 @@ def source(self): destination=self._source_subfolder, strip_root=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - files.patch(self, **patch) + files.apply_conandata_patches(self) if microsoft.is_msvc(self): self._build_msvc() else: @@ -237,8 +236,10 @@ def package(self): def package_info(self): self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-not-use" self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") + self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) self.cpp_info.components["cairo_"].requires = ["pixman::pixman", "libpng::libpng", "zlib::zlib"] @@ -272,34 +273,42 @@ def package_info(self): if self.settings.os == "Windows": self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") + self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_", "pixman::pixman", "libpng::libpng"] if self.options.get_safe("with_glib", True): self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") + self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] if self.settings.os != "Windows": if self.options.with_fontconfig: self.cpp_info.components["cairo-fc"].set_property("pkg_config_name", "cairo-fc") + self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] if self.options.get_safe("with_freetype", True): self.cpp_info.components["cairo-ft"].set_property("pkg_config_name", "cairo-ft") + self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] self.cpp_info.components["cairo-pdf"].set_property("pkg_config_name", "cairo-pdf") + self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] if self.settings.os == "Linux": if self.options.with_xlib: self.cpp_info.components["cairo-xlib"].set_property("pkg_config_name", "cairo-xlib") + self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") + self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics", "ApplicationServices"]) self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") + self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] def package_id(self): diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 34a32c73f3c49..80378b2b46d03 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -151,7 +151,7 @@ def _build_context(self): yield def source(self): - files.get(self, **self.conan_data["sources"][self.version], + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_meson(self): @@ -205,13 +205,12 @@ def boolean(value): return meson def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - files.patch(self, **patch) + files.apply_conandata_patches(self) # Dependency freetype2 found: NO found 2.11.0 but need: '>= 9.7.3' if self.options.with_freetype: files.replace_in_file(self, "freetype2.pc", - "Version: %s" % self.deps_cpp_info["freetype"].version, + f"Version: {self.deps_cpp_info['freetype'].version}", "Version: 9.7.3") with self._build_context(): meson = self._configure_meson() @@ -241,6 +240,7 @@ def package_info(self): def add_component_and_base_requirements(component, requirements, system_libs=None): self.cpp_info.components[component].set_property("pkg_config_name", component) + self.cpp_info.components[component].names["pkg_config"] = component self.cpp_info.components[component].requires += ["cairo_"] + requirements base_requirements.update(set(requirements)) if system_libs is not None: @@ -248,6 +248,7 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non base_system_libs.update(set(system_libs)) self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-no-use" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) @@ -289,16 +290,28 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") + self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] + + self.cpp_info.components["cairo-quartz-image"].set_property("pkg_config_name", "cairo-quartz-image") + self.cpp_info.components["cairo-quartz-image"].names["pkg_config"] = "cairo-quartz-image" self.cpp_info.components["cairo-quartz-image"].requires = ["cairo_"] + + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") + self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") + self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_"] + self.cpp_info.components["cairo-win32-font"].set_property("pkg_config_name", "cairo-win32-font") + self.cpp_info.components["cairo-win32-font"].names["pkg_config"] = "cairo-win32-font" self.cpp_info.components["cairo-win32-font"].requires = ["cairo_"] + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) if not self.options.shared: @@ -326,6 +339,7 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non add_component_and_base_requirements("cairo-ps", ["zlib::zlib"]) add_component_and_base_requirements("cairo-pdf", ["zlib::zlib"]) self.cpp_info.components["cairo-script-interpreter"].set_property("pkg_config_name", "cairo-script-interpreter") + self.cpp_info.components["cairo-script-interpreter"].names["pkg_config"] = "cairo-script-interpreter" self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] @@ -335,11 +349,13 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non if self.options.tee: self.cpp_info.components["cairo-tee"].set_property("pkg_config_name", "cairo-tee") + self.cpp_info.components["cairo-tee"].names["pkg_config"] = "cairo-tee" self.cpp_info.components["cairo-tee"].requires = ["cairo_"] # util directory if self.options.with_glib: self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") + self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] From 8d6d988a317d2830eca85f53277b000ececbfa2d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 24 Aug 2022 18:36:17 +0100 Subject: [PATCH 13/16] [cairo] update source method --- recipes/cairo/meson/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 80378b2b46d03..60c0398358b20 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -151,8 +151,7 @@ def _build_context(self): yield def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_meson(self): def boolean(value): From adf4fb72c82c839f5c8775bef14dd743037cbf27 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 25 Aug 2022 20:58:52 +0100 Subject: [PATCH 14/16] [cairo] restore main pkg-config name --- recipes/cairo/meson/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 60c0398358b20..0d154885a231d 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -248,6 +248,9 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") self.cpp_info.names["pkg_config"] = "cairo-all-do-no-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") + self.cpp_info.components["cairo_"].names["pkg_config_name"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) From 9d6fb6163e5d32f2b006d33b09703d6813fac23f Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 31 Aug 2022 12:11:22 +0100 Subject: [PATCH 15/16] [cairo] fix property name typo --- recipes/cairo/meson/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 0d154885a231d..b540eb65609df 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -250,7 +250,7 @@ def add_component_and_base_requirements(component, requirements, system_libs=Non self.cpp_info.names["pkg_config"] = "cairo-all-do-no-use" self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") - self.cpp_info.components["cairo_"].names["pkg_config_name"] = "cairo" + self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) From 49787f55d6fabeb07d6e4a1f4519e759d9ff94c3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 31 Aug 2022 17:54:49 +0100 Subject: [PATCH 16/16] [cairo] use tool_requires --- recipes/cairo/all/conanfile.py | 8 ++++---- recipes/cairo/meson/conanfile.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 04139fa26eff3..363cd49cb6c52 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -102,11 +102,11 @@ def requirements(self): def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") + self.tool_requires("msys2/cci.latest") if not microsoft.is_msvc(self): - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") - self.build_requires("gtk-doc-stub/cci.20181216") + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") + self.tool_requires("gtk-doc-stub/cci.20181216") def source(self): files.get(self, **self.conan_data["sources"][self.version], diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index b540eb65609df..ebff14e5fdea3 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -121,8 +121,8 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.build_requires("meson/0.63.1") - self.build_requires("pkgconf/1.7.4") + self.tool_requires("meson/0.63.1") + self.tool_requires("pkgconf/1.7.4") def validate(self): if self.options.get_safe("with_xlib_xrender") and not self.options.get_safe("with_xlib"):