From 36de76c744b930d269bc21fce4a97611616e6dd6 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 1 Nov 2022 23:30:35 +0000 Subject: [PATCH 01/33] [cairo] bump glib dependency in meson build --- 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 3871b067363f2..408e882251649 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -111,7 +111,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.38") if self.options.with_glib: - self.requires("glib/2.74.0") + self.requires("glib/2.74.1") 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") From 42ce19cf8e8420baa13223f8416f13fc4c183b53 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 1 Nov 2022 23:34:06 +0000 Subject: [PATCH 02/33] [cairo] bump deps in autotools build --- recipes/cairo/all/conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 363cd49cb6c52..ab6123dcba16b 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -88,24 +88,24 @@ def validate(self): def requirements(self): if self.options.get_safe("with_freetype", True): - self.requires("freetype/2.11.0") + self.requires("freetype/2.12.1") if self.options.get_safe("with_fontconfig", False): self.requires("fontconfig/2.13.93") 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") if self.options.get_safe("with_glib", True): - self.requires("glib/2.70.0") - self.requires("zlib/1.2.11") + self.requires("glib/2.74.1") + self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") - self.requires("libpng/1.6.37") + self.requires("libpng/1.6.38") def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): self.tool_requires("msys2/cci.latest") if not microsoft.is_msvc(self): - self.tool_requires("libtool/2.4.6") - self.tool_requires("pkgconf/1.7.4") + self.tool_requires("libtool/2.4.7") + self.tool_requires("pkgconf/1.9.3") self.tool_requires("gtk-doc-stub/cci.20181216") def source(self): From f3e7ff76880971f0b156fce8ff5f249993f9e5ec Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 3 Nov 2022 14:47:10 +0000 Subject: [PATCH 03/33] [cairo] update the autotools toolchain --- recipes/cairo/all/conandata.yml | 9 +- recipes/cairo/all/conanfile.py | 267 ++++++++++++++++---------------- 2 files changed, 137 insertions(+), 139 deletions(-) diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index e6ad418ca420e..1a8b3ea9d9cc4 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -11,16 +11,13 @@ sources: patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + base_path: "util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + base_path: "util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + base_path: "util/cairo-trace" diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index ab6123dcba16b..d23e6a128d874 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -3,11 +3,23 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools import files, microsoft, scm -from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment -from conans import tools - -required_conan_version = ">=1.50.0" +from conan.tools.apple import is_apple_os +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + replace_in_file, + rm, + rmdir +) +from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path +from conan.tools.scm import Version + +required_conan_version = ">=1.52.0" class CairoConan(ConanFile): @@ -38,19 +50,7 @@ class CairoConan(ConanFile): "with_xcb": True, "with_glib": True, } - - exports_sources = "patches/*" - generators = "pkg_config" - - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + short_paths = True @property def _settings_build(self): @@ -62,7 +62,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if microsoft.is_msvc(self): + if is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -77,11 +77,11 @@ def configure(self): del self.settings.compiler.libcxx def validate(self): - if microsoft.is_msvc(self): + if 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): + and is_msvc_static_runtime(self): raise ConanInvalidConfiguration( "Linking shared glib with the MSVC static runtime is not supported" ) @@ -101,138 +101,139 @@ def requirements(self): self.requires("libpng/1.6.38") def build_requirements(self): - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + if self._settings_build.os == "Windows" and not os.get_env("CONAN_BASH_PATH"): self.tool_requires("msys2/cci.latest") - if not microsoft.is_msvc(self): + if not is_msvc(self): self.tool_requires("libtool/2.4.7") self.tool_requires("pkgconf/1.9.3") self.tool_requires("gtk-doc-stub/cci.20181216") + def layout(self): + basic_layout(self, src_folder="src") + + def _msvc_make_args(self): + return [ + "-f", "Makefile.win32", + f"CFG={str(self.settings.build_type).lower()}", + "CAIRO_HAS_FC_FONT=0", + 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}" + ] + + def generate(self): + def is_enabled(value): + return "yes" if value else "no" + + PkgConfigDeps(self).generate() + + tc = AutotoolsToolchain(self) + tc.configure_args += [ + f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={is_enabled(self.options.with_freetype)}", + f"--enable-gobject={is_enabled(self.options.with_glib)}", + f"--enable-fc={is_enabled(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={is_enabled(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={is_enabled(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={is_enabled(self.options.get_safe('xcb'))}", + "--disable-gtk-doc" + ] + if is_msvc(self): + tc.make_args += self._msvc_make_args() + tc.extra_cflags += "/FS" + + if self.settings.compiler in ["gcc", "clang", "apple-clang"]: + tc.extra_cflags.append("-Wno-enum-conversion") + + tc.generate() + + VirtualBuildEnv(self).generate() + + def export_sources(self): + export_conandata_patches(self) + def source(self): - files.get(self, **self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def build(self): - files.apply_conandata_patches(self) - if microsoft.is_msvc(self): - self._build_msvc() - else: - self._build_configure() + def _patch_sources(self): + apply_conandata_patches(self) + + def fix_freetype_version(): + replace_in_file( + self, + os.path.join(self.source_folder, "configure.ac"), + "FREETYPE_MIN_VERSION=9.7.3", + f"FREETYPE_MIN_VERSION={Version(self.deps_cpp_info['freetype'].version)}" + ) + + def exclude_tests_and_docs_from_build(): + makefile_am = os.path.join(self.source_folder, "Makefile.am") + replace_in_file(self, makefile_am, "SUBDIRS += boilerplate test perf", "") + replace_in_file(self, makefile_am, "SUBDIRS = src doc util", "SUBDIRS = src util") - def _build_msvc(self): - with tools.chdir(self._source_subfolder): + fix_freetype_version() + exclude_tests_and_docs_from_build() + + if self.options.with_freetype: + replace_in_file(self, os.path.join(self.source_folder, "src", "cairo-ft-font.c"), + "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") + + if is_msvc(self): # 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 ", 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", - self.deps_cpp_info["libpng"].libs[0] + ".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) - env_msvc.flags.append("/FS") # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS - with tools.environment_append(env_msvc.vars): - env_build = AutoToolsBuildEnvironment(self) - args=[ - "-f", "Makefile.win32", - f"CFG={str(self.settings.build_type).lower()}", - "CAIRO_HAS_FC_FONT=0", - 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) - env_build.make(args=["-C", os.path.join("util", "cairo-gobject")] + args) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - - def boolean(value): - return "yes" if value else "no" + replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") + replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + self.deps_cpp_info["zlib"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + self.deps_cpp_info["libpng"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + self.deps_cpp_info["freetype"].libs[0] + ".lib") - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - configure_args = [ - 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"]: - self._autotools.flags.append("-Wno-enum-conversion") - - with tools.run_environment(self): - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools - - def _build_configure(self): - with tools.chdir(self._source_subfolder): - # disable build of test suite - files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", - "") - if self.options.with_freetype: - 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")) - tools.touch(os.path.join("src", "Makefile.am.features")) - tools.touch("ChangeLog") - - with tools.environment_append({"GTKDOCIZE": "echo"}): - self.run( - f"{tools.get_env('AUTORECONF')} -fiv", - run_environment=True, - win_bash=tools.os_info.is_windows, - ) - autotools = self._configure_autotools() + def build(self): + self._patch_sources() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - if microsoft.is_msvc(self): - src = os.path.join(self._source_subfolder, "src") - cairo_gobject = os.path.join(self._source_subfolder, "util", "cairo-gobject") + copy(self, pattern="LICENSE", dst="licenses", src=self.source_folder) + if is_msvc(self): + src = os.path.join(self.source_folder, "src") + cairo_gobject = os.path.join(self.source_folder, "util", "cairo-gobject") inc = os.path.join("include", "cairo") - 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) - self.copy(pattern="cairo-win32.h", dst=inc, src=src) - self.copy(pattern="cairo-script.h", dst=inc, src=src) - self.copy(pattern="cairo-ft.h", dst=inc, src=src) - self.copy(pattern="cairo-ps.h", dst=inc, src=src) - self.copy(pattern="cairo-pdf.h", dst=inc, src=src) - self.copy(pattern="cairo-svg.h", dst=inc, src=src) - self.copy(pattern="cairo-gobject.h", dst=inc, src=cairo_gobject) + copy(self, "cairo-version.h", (src if Version(self.version) >= "1.17.4" else self.source_folder), inc) + copy(self, "cairo-features.h", src, inc) + copy(self, "cairo.h", src, inc) + copy(self, "cairo-deprecated.h", src, inc) + copy("cairo-win32.h", src, inc) + copy(self, "cairo-script.h", src, inc) + copy(self, "cairo-ft.h", src, inc) + copy(self, "cairo-ps.h", src, inc) + copy(self, "cairo-pdf.h", src, inc) + copy(self, "cairo-svg.h", src, inc) + copy(self, "cairo-gobject.h", inc, cairo_gobject) if self.options.shared: - self.copy(pattern="*cairo.lib", dst="lib", src=src, keep_path=False) - self.copy(pattern="*cairo.dll", dst="bin", src=src, keep_path=False) - self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - self.copy(pattern="*cairo-gobject.dll", dst="bin", src=cairo_gobject, keep_path=False) + copy(self, "*cairo.lib", src, keep_path=False) + copy(self, "*cairo.dll", src, keep_path=False) + copy(self, "*cairo-gobject.lib", cairo_gobject, os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*cairo-gobject.dll", cairo_gobject, os.path.join(self.package_folder, "bin"), keep_path=False) else: - self.copy(pattern="*cairo-static.lib", dst="lib", src=src, keep_path=False) - self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) + copy(self, "*cairo-static.lib", dst="lib", src=src, keep_path=False) + copy(self, "*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), os.path.join(self.package_folder, "lib", "cairo.lib")) else: - autotools = self._configure_autotools() + autotools = Autotools(self) autotools.install() - tools.remove_files_by_mask(self.package_folder, "*.la") - self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.la", self.package_folder, recursive=True) + 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") @@ -268,7 +269,7 @@ def package_info(self): if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": @@ -301,7 +302,7 @@ def package_info(self): 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): + if is_apple_os(self): 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_"] From a51d7ab57240f2883844c5a855131b6e3665e5d3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 3 Nov 2022 14:04:04 -0700 Subject: [PATCH 04/33] [cairo] fix env vars for msvc autotools --- recipes/cairo/all/conanfile.py | 70 +++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index d23e6a128d874..2b5298570e525 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -4,7 +4,8 @@ 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.build import cross_building +from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv from conan.tools.files import ( apply_conandata_patches, copy, @@ -14,7 +15,7 @@ rm, rmdir ) -from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsToolchain +from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsDeps, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path from conan.tools.scm import Version @@ -56,6 +57,10 @@ class CairoConan(ConanFile): def _settings_build(self): return getattr(self, "settings_build", self.settings) + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd @@ -101,39 +106,51 @@ def requirements(self): self.requires("libpng/1.6.38") def build_requirements(self): - if self._settings_build.os == "Windows" and not os.get_env("CONAN_BASH_PATH"): - self.tool_requires("msys2/cci.latest") - if not is_msvc(self): - self.tool_requires("libtool/2.4.7") + self.tool_requires("libtool/2.4.7") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): self.tool_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") + else: self.tool_requires("gtk-doc-stub/cci.20181216") def layout(self): basic_layout(self, src_folder="src") def _msvc_make_args(self): + def dep_path(dependency): + return unix_path(self, self.deps_cpp_info[dependency].rootpath) + return [ + "--directory", unix_path(self, self.source_folder), "-f", "Makefile.win32", f"CFG={str(self.settings.build_type).lower()}", "CAIRO_HAS_FC_FONT=0", - 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}" + f"ZLIB_PATH={dep_path('zlib')}", + f"LIBPNG_PATH={dep_path('libpng')}", + f"PIXMAN_PATH={dep_path('pixman')}", + f"FREETYPE_PATH={dep_path('freetype')}", + f"GOBJECT_PATH={dep_path('glib')}" ] def generate(self): def is_enabled(value): return "yes" if value else "no" - PkgConfigDeps(self).generate() + VirtualBuildEnv(self).generate() + + if not cross_building(self): + VirtualRunEnv(self).generate(scope="build") tc = AutotoolsToolchain(self) tc.configure_args += [ f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", - f"--enable-ft={is_enabled(self.options.with_freetype)}", - f"--enable-gobject={is_enabled(self.options.with_glib)}", + f"--enable-ft={is_enabled(self.options.get_safe('with_freetype', True))}", + f"--enable-gobject={is_enabled(self.options.get_safe('with_glib', True))}", f"--enable-fc={is_enabled(self.options.get_safe('with_fontconfig'))}", f"--enable-xlib={is_enabled(self.options.get_safe('with_xlib'))}", f"--enable-xlib_xrender={is_enabled(self.options.get_safe('with_xlib_xrender'))}", @@ -142,14 +159,22 @@ def is_enabled(value): ] if is_msvc(self): tc.make_args += self._msvc_make_args() - tc.extra_cflags += "/FS" + tc.extra_cflags += ["-FS"] if self.settings.compiler in ["gcc", "clang", "apple-clang"]: tc.extra_cflags.append("-Wno-enum-conversion") tc.generate() - VirtualBuildEnv(self).generate() + PkgConfigDeps(self).generate() + deps = AutotoolsDeps(self) + if is_msvc(self): + cppflags = deps.vars().get("CPPFLAGS") + deps.environment.append('CFLAGS', cppflags.replace("/I", "-I")) + ldflags = deps.vars().get("LDFLAGS") + deps.environment.define('LDFLAGS', ldflags.replace("/LIBPATH:", "-LIBPATH:")) + + deps.generate() def export_sources(self): export_conandata_patches(self) @@ -177,27 +202,26 @@ def exclude_tests_and_docs_from_build(): fix_freetype_version() exclude_tests_and_docs_from_build() - if self.options.with_freetype: + if self.options.get_safe("with_freetype"): replace_in_file(self, os.path.join(self.source_folder, "src", "cairo-ft-font.c"), "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") if is_msvc(self): # https://cairographics.org/end_to_end_build_for_win32/ - win32_common = os.path.join("build", "Makefile.win32.common") + win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", self.deps_cpp_info["zlib"].libs[0] + ".lib") replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", self.deps_cpp_info["libpng"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", - self.deps_cpp_info["freetype"].libs[0] + ".lib") def build(self): self._patch_sources() autotools = Autotools(self) - autotools.autoreconf() - autotools.configure() + if not is_msvc(self): + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): @@ -210,7 +234,7 @@ def package(self): copy(self, "cairo-features.h", src, inc) copy(self, "cairo.h", src, inc) copy(self, "cairo-deprecated.h", src, inc) - copy("cairo-win32.h", src, inc) + copy(self, "cairo-win32.h", src, inc) copy(self, "cairo-script.h", src, inc) copy(self, "cairo-ft.h", src, inc) copy(self, "cairo-ps.h", src, inc) From e7df9ff1022008f06af83d9d0f6f2223209f1edf Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 4 Nov 2022 07:05:06 -0700 Subject: [PATCH 05/33] [cairo] ignore CAIRO_LIBS --- recipes/cairo/all/conanfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 2b5298570e525..4ad0aa8fb8d28 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -128,6 +128,7 @@ def dep_path(dependency): return [ "--directory", unix_path(self, self.source_folder), "-f", "Makefile.win32", + "-n", f"CFG={str(self.settings.build_type).lower()}", "CAIRO_HAS_FC_FONT=0", f"ZLIB_PATH={dep_path('zlib')}", @@ -173,9 +174,11 @@ def is_enabled(value): deps.environment.append('CFLAGS', cppflags.replace("/I", "-I")) ldflags = deps.vars().get("LDFLAGS") deps.environment.define('LDFLAGS', ldflags.replace("/LIBPATH:", "-LIBPATH:")) + deps.environment.append('LDFLAGS', deps.vars().get("LIBS")) deps.generate() + def export_sources(self): export_conandata_patches(self) @@ -211,10 +214,7 @@ def exclude_tests_and_docs_from_build(): win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") - replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", - self.deps_cpp_info["zlib"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", - self.deps_cpp_info["libpng"].libs[0] + ".lib") + replace_in_file(self, win32_common, "# Some generic rules",'CAIRO_LIBS = ""') def build(self): self._patch_sources() From 4f21d80392835414db65d7ce7ceb582e252518f9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 6 Nov 2022 07:56:01 -0800 Subject: [PATCH 06/33] [cairo] update the autotools build --- recipes/cairo/all/conanfile.py | 102 ++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 4ad0aa8fb8d28..eb188219a5a97 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -12,6 +12,7 @@ export_conandata_patches, get, replace_in_file, + rename, rm, rmdir ) @@ -121,33 +122,14 @@ def build_requirements(self): def layout(self): basic_layout(self, src_folder="src") - def _msvc_make_args(self): - def dep_path(dependency): - return unix_path(self, self.deps_cpp_info[dependency].rootpath) - - return [ - "--directory", unix_path(self, self.source_folder), - "-f", "Makefile.win32", - "-n", - f"CFG={str(self.settings.build_type).lower()}", - "CAIRO_HAS_FC_FONT=0", - f"ZLIB_PATH={dep_path('zlib')}", - f"LIBPNG_PATH={dep_path('libpng')}", - f"PIXMAN_PATH={dep_path('pixman')}", - f"FREETYPE_PATH={dep_path('freetype')}", - f"GOBJECT_PATH={dep_path('glib')}" - ] - - def generate(self): + def _create_toolchain(self, namespace, directory): def is_enabled(value): return "yes" if value else "no" - VirtualBuildEnv(self).generate() - - if not cross_building(self): - VirtualRunEnv(self).generate(scope="build") + def dep_path(dependency): + return unix_path(self, self.deps_cpp_info[dependency].rootpath) - tc = AutotoolsToolchain(self) + tc = AutotoolsToolchain(self, namespace=namespace) tc.configure_args += [ f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", f"--enable-ft={is_enabled(self.options.get_safe('with_freetype', True))}", @@ -159,13 +141,37 @@ def is_enabled(value): "--disable-gtk-doc" ] if is_msvc(self): - tc.make_args += self._msvc_make_args() + tc.make_args += [ + "--directory", directory, + "-f", "Makefile.win32", + f"CFG={str(self.settings.build_type).lower()}", + "CAIRO_HAS_FC_FONT=0", + f"ZLIB_PATH={dep_path('zlib')}", + f"LIBPNG_PATH={dep_path('libpng')}", + f"PIXMAN_PATH={dep_path('pixman')}", + f"FREETYPE_PATH={dep_path('freetype')}", + f"GOBJECT_PATH={dep_path('glib')}" + ] tc.extra_cflags += ["-FS"] if self.settings.compiler in ["gcc", "clang", "apple-clang"]: tc.extra_cflags.append("-Wno-enum-conversion") - tc.generate() + return tc + + + def generate(self): + VirtualBuildEnv(self).generate() + + if not cross_building(self): + VirtualRunEnv(self).generate(scope="build") + + tc_main = self._create_toolchain("main", unix_path(self, self.source_folder)) + tc_main.generate() + + if is_msvc(self): + tc_gobject = self._create_toolchain("gobject", unix_path(self, os.path.join(self.source_folder, "util", "cairo-gobject"))) + tc_gobject.generate() PkgConfigDeps(self).generate() deps = AutotoolsDeps(self) @@ -214,22 +220,32 @@ def exclude_tests_and_docs_from_build(): win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") - replace_in_file(self, win32_common, "# Some generic rules",'CAIRO_LIBS = ""') + replace_in_file(self, win32_common, "$(PIXMAN_PATH)/lib/pixman-1.lib", + self.deps_cpp_info["pixman"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + self.deps_cpp_info["freetype"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + self.deps_cpp_info["zlib"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + self.deps_cpp_info["libpng"].libs[0] + ".lib") def build(self): self._patch_sources() - autotools = Autotools(self) - if not is_msvc(self): + autotools = Autotools(self, namespace="main") + if is_msvc(self): + autotools.make() + autotools_gobject = Autotools(self, namespace="gobject") + autotools_gobject.make() + else: autotools.autoreconf() autotools.configure() - autotools.make() + autotolls.make() def package(self): copy(self, pattern="LICENSE", dst="licenses", src=self.source_folder) if is_msvc(self): src = os.path.join(self.source_folder, "src") - cairo_gobject = os.path.join(self.source_folder, "util", "cairo-gobject") - inc = os.path.join("include", "cairo") + inc = os.path.join(self.package_folder, "include", "cairo") copy(self, "cairo-version.h", (src if Version(self.version) >= "1.17.4" else self.source_folder), inc) copy(self, "cairo-features.h", src, inc) copy(self, "cairo.h", src, inc) @@ -240,17 +256,23 @@ def package(self): copy(self, "cairo-ps.h", src, inc) copy(self, "cairo-pdf.h", src, inc) copy(self, "cairo-svg.h", src, inc) - copy(self, "cairo-gobject.h", inc, cairo_gobject) + copy(self, "cairo-gobject.h", inc, os.path.join(self.source_folder, "util", "cairo-gobject")) + + config = str(self.settings.build_type).lower() + lib_src_path = os.path.join(self.source_folder, "src", config) + cairo_gobject_src_path = os.path.join(self.source_folder, "util", "cairo-gobject", config) + lib_dest_path = os.path.join(self.package_folder, "lib") + runtime_dest_path = os.path.join(self.package_folder, "bin") + if self.options.shared: - copy(self, "*cairo.lib", src, keep_path=False) - copy(self, "*cairo.dll", src, keep_path=False) - copy(self, "*cairo-gobject.lib", cairo_gobject, os.path.join(self.package_folder, "lib"), keep_path=False) - copy(self, "*cairo-gobject.dll", cairo_gobject, os.path.join(self.package_folder, "bin"), keep_path=False) + copy(self, "*cairo.lib", lib_src_path, lib_dest_path) + copy(self, "*cairo.dll", lib_src_path, runtime_dest_path) + copy(self, "*cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) + copy(self, "*cairo-gobject.dll", cairo_gobject_src_path, runtime_dest_path) else: - copy(self, "*cairo-static.lib", dst="lib", src=src, keep_path=False) - copy(self, "*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), - os.path.join(self.package_folder, "lib", "cairo.lib")) + copy(self, "cairo-static.lib", lib_src_path, lib_dest_path) + copy(self, "cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) + rename(self, os.path.join(lib_dest_path, "cairo-static.lib"), os.path.join(lib_dest_path, "cairo.lib")) else: autotools = Autotools(self) autotools.install() From a61f198bba61ec773c844ff2b792a914e7749b5b Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 6 Nov 2022 07:58:30 -0800 Subject: [PATCH 07/33] [cairo] update test packages for the autotools build --- recipes/cairo/all/test_package/CMakeLists.txt | 5 ++-- recipes/cairo/all/test_package/conanfile.py | 20 +++++++++----- recipes/cairo/all/test_package/test_package.c | 27 +++++++++++++++++++ .../cairo/all/test_v1_package/CMakeLists.txt | 8 ++++++ .../cairo/all/test_v1_package/conanfile.py | 18 +++++++++++++ 5 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 recipes/cairo/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cairo/all/test_v1_package/conanfile.py diff --git a/recipes/cairo/all/test_package/CMakeLists.txt b/recipes/cairo/all/test_package/CMakeLists.txt index bed5cd67420b6..4f33d55898eb2 100644 --- a/recipes/cairo/all/test_package/CMakeLists.txt +++ b/recipes/cairo/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1.2) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cairo CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE cairo::cairo) diff --git a/recipes/cairo/all/test_package/conanfile.py b/recipes/cairo/all/test_package/conanfile.py index 112349b422c25..e904c93b97465 100644 --- a/recipes/cairo/all/test_package/conanfile.py +++ b/recipes/cairo/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self, skip_x64_x86=True): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cairo/all/test_package/test_package.c b/recipes/cairo/all/test_package/test_package.c index e7474b6da5809..5854291cea177 100644 --- a/recipes/cairo/all/test_package/test_package.c +++ b/recipes/cairo/all/test_package/test_package.c @@ -2,8 +2,35 @@ #include #include +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + +#include +#include + +#endif + int main() { +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + + HDC hDC = GetDC(0); + if (hDC) + { + cairo_surface_t * surface = cairo_win32_surface_create(hDC); + if (surface) + { + HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); + cairo_font_face_t* font = cairo_win32_font_face_create_for_hfont(hFont); + if (font) + cairo_font_face_destroy(font); + + cairo_surface_destroy(surface); + } + ReleaseDC(0, hDC); + } +#endif + printf("cairo version is %s\n", cairo_version_string()); + return 0; } diff --git a/recipes/cairo/all/test_v1_package/CMakeLists.txt b/recipes/cairo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..692a4909c85a7 --- /dev/null +++ b/recipes/cairo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1.2) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairo/all/test_v1_package/conanfile.py b/recipes/cairo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..24f9e474d6cd2 --- /dev/null +++ b/recipes/cairo/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + From 7cbe8a4611e745c05e3392455b02cbd4e9e3dc97 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 6 Nov 2022 16:03:44 +0000 Subject: [PATCH 08/33] [cairo] fix linux autotools build --- recipes/cairo/all/conanfile.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index eb188219a5a97..dd1b27443bf46 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,11 +1,10 @@ import os -import shutil from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os from conan.tools.build import cross_building -from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv from conan.tools.files import ( apply_conandata_patches, copy, @@ -60,7 +59,7 @@ def _settings_build(self): @property def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) + return getattr(self, "user_info_build", self.deps_user_info) def config_options(self): del self.settings.compiler.libcxx @@ -158,7 +157,7 @@ def dep_path(dependency): tc.extra_cflags.append("-Wno-enum-conversion") return tc - + def generate(self): VirtualBuildEnv(self).generate() @@ -239,7 +238,7 @@ def build(self): else: autotools.autoreconf() autotools.configure() - autotolls.make() + autotools.make() def package(self): copy(self, pattern="LICENSE", dst="licenses", src=self.source_folder) @@ -274,7 +273,7 @@ def package(self): copy(self, "cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) rename(self, os.path.join(lib_dest_path, "cairo-static.lib"), os.path.join(lib_dest_path, "cairo.lib")) else: - autotools = Autotools(self) + autotools = Autotools(self, namespace="main") autotools.install() copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) From fc42ab58dcda65ac1684252f6b52f388a252f4bd Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 26 Nov 2022 09:38:49 +0000 Subject: [PATCH 09/33] [cairo] update autotools deps --- recipes/cairo/all/conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index dd1b27443bf46..544e70651e36a 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -20,7 +20,7 @@ from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path from conan.tools.scm import Version -required_conan_version = ">=1.52.0" +required_conan_version = ">=1.53.0" class CairoConan(ConanFile): @@ -77,9 +77,9 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") def validate(self): if is_msvc(self): @@ -100,10 +100,10 @@ def requirements(self): if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") if self.options.get_safe("with_glib", True): - self.requires("glib/2.74.1") + self.requires("glib/2.75.0") self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") - self.requires("libpng/1.6.38") + self.requires("libpng/1.6.39") def build_requirements(self): self.tool_requires("libtool/2.4.7") From b8979eca76d86a7d0fedbd73083453b14ba28dc7 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 26 Nov 2022 09:41:56 +0000 Subject: [PATCH 10/33] [cairo] bump deps in meson build --- recipes/cairo/meson/conanfile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 408e882251649..447193110deeb 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -20,7 +20,7 @@ from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version -required_conan_version = ">=1.52.0" +required_conan_version = ">=1.53.0" class CairoConan(ConanFile): @@ -90,16 +90,16 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") if self.options.with_glib and self.options.shared: self.options["glib"].shared = True def requirements(self): self.requires("pixman/0.40.0") if self.options.with_zlib and self.options.with_png: - self.requires("expat/2.4.9") + self.requires("expat/2.5.0") if self.options.with_lzo: self.requires("lzo/2.10") if self.options.with_zlib: @@ -109,9 +109,9 @@ def requirements(self): if self.options.with_fontconfig: self.requires("fontconfig/2.13.93") if self.options.with_png: - self.requires("libpng/1.6.38") + self.requires("libpng/1.6.39") if self.options.with_glib: - self.requires("glib/2.74.1") + self.requires("glib/2.75.0") 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") @@ -125,7 +125,7 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.tool_requires("meson/0.63.3") + self.tool_requires("meson/0.64.1") self.tool_requires("pkgconf/1.9.3") def validate(self): From 80cfa1c43ccfb147e288f3b65ba2b72640814e6f Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 26 Nov 2022 16:53:59 +0000 Subject: [PATCH 11/33] [cairo] fix msvc static runtime test --- recipes/cairo/all/conanfile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 544e70651e36a..5fc6dbc43a7a6 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -85,8 +85,7 @@ def validate(self): if 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 is_msvc_static_runtime(self): + if self.options["glib"].shared and is_msvc_static_runtime(self): raise ConanInvalidConfiguration( "Linking shared glib with the MSVC static runtime is not supported" ) @@ -158,7 +157,6 @@ def dep_path(dependency): return tc - def generate(self): VirtualBuildEnv(self).generate() @@ -183,7 +181,6 @@ def generate(self): deps.generate() - def export_sources(self): export_conandata_patches(self) From 232170d4939dab0a54127385515919ce2e22140d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 26 Nov 2022 17:02:24 +0000 Subject: [PATCH 12/33] [cairo] document patches --- recipes/cairo/all/conandata.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index 1a8b3ea9d9cc4..a0a5e63d84308 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -11,13 +11,24 @@ sources: patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" + patch_type: portability + patch_description: support more features in MSVC build - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 base_path: "util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 base_path: "util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 base_path: "util/cairo-trace" From 60a6654b28860b0aff8cc0042018e73fec688cde Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 4 Dec 2022 12:01:49 +0000 Subject: [PATCH 13/33] Update recipes/cairo/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/cairo/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 5fc6dbc43a7a6..4e373a6c74fc7 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -85,7 +85,7 @@ def validate(self): if 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["glib"].shared and is_msvc_static_runtime(self): + 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" ) From 00278f2f12ae23ad89a971825934481b499558a9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 4 Dec 2022 12:02:02 +0000 Subject: [PATCH 14/33] Update recipes/cairo/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/cairo/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 4e373a6c74fc7..e89eb31a170cf 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -238,7 +238,7 @@ def build(self): autotools.make() def package(self): - copy(self, pattern="LICENSE", dst="licenses", src=self.source_folder) + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) if is_msvc(self): src = os.path.join(self.source_folder, "src") inc = os.path.join(self.package_folder, "include", "cairo") From f73b4b39b416988d8f68775449679e46cddc5864 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 5 Dec 2022 10:36:16 +0000 Subject: [PATCH 15/33] [cairo] revert recipe changes --- recipes/cairo/all/conandata.yml | 20 +- recipes/cairo/all/conanfile.py | 343 ++++++++---------- recipes/cairo/all/test_package/CMakeLists.txt | 5 +- recipes/cairo/all/test_package/conanfile.py | 20 +- recipes/cairo/all/test_package/test_package.c | 27 -- recipes/cairo/meson/conanfile.py | 16 +- 6 files changed, 173 insertions(+), 258 deletions(-) diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index a0a5e63d84308..e6ad418ca420e 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -11,24 +11,16 @@ sources: patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - patch_type: portability - patch_description: support more features in MSVC build + base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - patch_description: "fix build with newer versions of bfd" - patch_type: backport - patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 - base_path: "util/cairo-trace" + base_path: "source_subfolder/util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" + base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - patch_description: "fix build with newer versions of bfd" - patch_type: backport - patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 - base_path: "util/cairo-trace" + base_path: "source_subfolder/util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" + base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - patch_description: "fix build with newer versions of bfd" - patch_type: backport - patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 - base_path: "util/cairo-trace" + base_path: "source_subfolder/util/cairo-trace" diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index e89eb31a170cf..363cd49cb6c52 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,26 +1,13 @@ import os +import shutil from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.apple import is_apple_os -from conan.tools.build import cross_building -from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import ( - apply_conandata_patches, - copy, - export_conandata_patches, - get, - replace_in_file, - rename, - rm, - rmdir -) -from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsDeps, AutotoolsToolchain -from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path -from conan.tools.scm import Version - -required_conan_version = ">=1.53.0" +from conan.tools import files, microsoft, scm +from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans import tools + +required_conan_version = ">=1.50.0" class CairoConan(ConanFile): @@ -51,15 +38,23 @@ class CairoConan(ConanFile): "with_xcb": True, "with_glib": True, } - short_paths = True + + exports_sources = "patches/*" + generators = "pkg_config" + + _autotools = None @property - def _settings_build(self): - return getattr(self, "settings_build", self.settings) + def _source_subfolder(self): + return "source_subfolder" @property - def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) + def _build_subfolder(self): + return "build_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): del self.settings.compiler.libcxx @@ -67,7 +62,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if is_msvc(self): + if microsoft.is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -77,205 +72,167 @@ def config_options(self): def configure(self): if self.options.shared: - self.options.rm_safe("fPIC") - self.settings.rm_safe("compiler.cppstd") - self.settings.rm_safe("compiler.libcxx") + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx def validate(self): - if is_msvc(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.dependencies["glib"].options.shared and is_msvc_static_runtime(self): + 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): - self.requires("freetype/2.12.1") + self.requires("freetype/2.11.0") if self.options.get_safe("with_fontconfig", False): self.requires("fontconfig/2.13.93") 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") if self.options.get_safe("with_glib", True): - self.requires("glib/2.75.0") - self.requires("zlib/1.2.13") + self.requires("glib/2.70.0") + self.requires("zlib/1.2.11") self.requires("pixman/0.40.0") - self.requires("libpng/1.6.39") + self.requires("libpng/1.6.37") def build_requirements(self): - self.tool_requires("libtool/2.4.7") - if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): - self.tool_requires("pkgconf/1.9.3") - if self._settings_build.os == "Windows": - self.win_bash = True - if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): - self.tool_requires("msys2/cci.latest") - if is_msvc(self): - self.tool_requires("automake/1.16.5") - else: + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") + if not microsoft.is_msvc(self): + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") self.tool_requires("gtk-doc-stub/cci.20181216") - def layout(self): - basic_layout(self, src_folder="src") - - def _create_toolchain(self, namespace, directory): - def is_enabled(value): - return "yes" if value else "no" - - def dep_path(dependency): - return unix_path(self, self.deps_cpp_info[dependency].rootpath) - - tc = AutotoolsToolchain(self, namespace=namespace) - tc.configure_args += [ - f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", - f"--enable-ft={is_enabled(self.options.get_safe('with_freetype', True))}", - f"--enable-gobject={is_enabled(self.options.get_safe('with_glib', True))}", - f"--enable-fc={is_enabled(self.options.get_safe('with_fontconfig'))}", - f"--enable-xlib={is_enabled(self.options.get_safe('with_xlib'))}", - f"--enable-xlib_xrender={is_enabled(self.options.get_safe('with_xlib_xrender'))}", - f"--enable-xcb={is_enabled(self.options.get_safe('xcb'))}", - "--disable-gtk-doc" - ] - if is_msvc(self): - tc.make_args += [ - "--directory", directory, - "-f", "Makefile.win32", - f"CFG={str(self.settings.build_type).lower()}", - "CAIRO_HAS_FC_FONT=0", - f"ZLIB_PATH={dep_path('zlib')}", - f"LIBPNG_PATH={dep_path('libpng')}", - f"PIXMAN_PATH={dep_path('pixman')}", - f"FREETYPE_PATH={dep_path('freetype')}", - f"GOBJECT_PATH={dep_path('glib')}" - ] - tc.extra_cflags += ["-FS"] - - if self.settings.compiler in ["gcc", "clang", "apple-clang"]: - tc.extra_cflags.append("-Wno-enum-conversion") - - return tc - - def generate(self): - VirtualBuildEnv(self).generate() - - if not cross_building(self): - VirtualRunEnv(self).generate(scope="build") - - tc_main = self._create_toolchain("main", unix_path(self, self.source_folder)) - tc_main.generate() - - if is_msvc(self): - tc_gobject = self._create_toolchain("gobject", unix_path(self, os.path.join(self.source_folder, "util", "cairo-gobject"))) - tc_gobject.generate() - - PkgConfigDeps(self).generate() - deps = AutotoolsDeps(self) - if is_msvc(self): - cppflags = deps.vars().get("CPPFLAGS") - deps.environment.append('CFLAGS', cppflags.replace("/I", "-I")) - ldflags = deps.vars().get("LDFLAGS") - deps.environment.define('LDFLAGS', ldflags.replace("/LIBPATH:", "-LIBPATH:")) - deps.environment.append('LDFLAGS', deps.vars().get("LIBS")) - - deps.generate() - - def export_sources(self): - export_conandata_patches(self) - def source(self): - get(self, **self.conan_data["sources"][self.version], - destination=self.source_folder, strip_root=True) - - def _patch_sources(self): - apply_conandata_patches(self) - - def fix_freetype_version(): - replace_in_file( - self, - os.path.join(self.source_folder, "configure.ac"), - "FREETYPE_MIN_VERSION=9.7.3", - f"FREETYPE_MIN_VERSION={Version(self.deps_cpp_info['freetype'].version)}" - ) - - def exclude_tests_and_docs_from_build(): - makefile_am = os.path.join(self.source_folder, "Makefile.am") - replace_in_file(self, makefile_am, "SUBDIRS += boilerplate test perf", "") - replace_in_file(self, makefile_am, "SUBDIRS = src doc util", "SUBDIRS = src util") + files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - fix_freetype_version() - exclude_tests_and_docs_from_build() - - if self.options.get_safe("with_freetype"): - replace_in_file(self, os.path.join(self.source_folder, "src", "cairo-ft-font.c"), - "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") + def build(self): + files.apply_conandata_patches(self) + if microsoft.is_msvc(self): + self._build_msvc() + else: + self._build_configure() - if is_msvc(self): + def _build_msvc(self): + with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ - win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") - replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") - replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") - replace_in_file(self, win32_common, "$(PIXMAN_PATH)/lib/pixman-1.lib", - self.deps_cpp_info["pixman"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", - self.deps_cpp_info["freetype"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", - self.deps_cpp_info["zlib"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", - self.deps_cpp_info["libpng"].libs[0] + ".lib") + win32_common = os.path.join("build", "Makefile.win32.common") + 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", + self.deps_cpp_info["libpng"].libs[0] + ".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) + env_msvc.flags.append("/FS") # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS + with tools.environment_append(env_msvc.vars): + env_build = AutoToolsBuildEnvironment(self) + args=[ + "-f", "Makefile.win32", + f"CFG={str(self.settings.build_type).lower()}", + "CAIRO_HAS_FC_FONT=0", + 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) + env_build.make(args=["-C", os.path.join("util", "cairo-gobject")] + args) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + + def boolean(value): + return "yes" if value else "no" - def build(self): - self._patch_sources() - autotools = Autotools(self, namespace="main") - if is_msvc(self): - autotools.make() - autotools_gobject = Autotools(self, namespace="gobject") - autotools_gobject.make() - else: - autotools.autoreconf() - autotools.configure() - autotools.make() + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + configure_args = [ + 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"]: + self._autotools.flags.append("-Wno-enum-conversion") + + with tools.run_environment(self): + self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return self._autotools + + def _build_configure(self): + with tools.chdir(self._source_subfolder): + # disable build of test suite + files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", + "") + if self.options.with_freetype: + 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")) + tools.touch(os.path.join("src", "Makefile.am.features")) + tools.touch("ChangeLog") + + with tools.environment_append({"GTKDOCIZE": "echo"}): + self.run( + f"{tools.get_env('AUTORECONF')} -fiv", + run_environment=True, + win_bash=tools.os_info.is_windows, + ) + autotools = self._configure_autotools() + autotools.make() def package(self): - copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) - if is_msvc(self): - src = os.path.join(self.source_folder, "src") - inc = os.path.join(self.package_folder, "include", "cairo") - copy(self, "cairo-version.h", (src if Version(self.version) >= "1.17.4" else self.source_folder), inc) - copy(self, "cairo-features.h", src, inc) - copy(self, "cairo.h", src, inc) - copy(self, "cairo-deprecated.h", src, inc) - copy(self, "cairo-win32.h", src, inc) - copy(self, "cairo-script.h", src, inc) - copy(self, "cairo-ft.h", src, inc) - copy(self, "cairo-ps.h", src, inc) - copy(self, "cairo-pdf.h", src, inc) - copy(self, "cairo-svg.h", src, inc) - copy(self, "cairo-gobject.h", inc, os.path.join(self.source_folder, "util", "cairo-gobject")) - - config = str(self.settings.build_type).lower() - lib_src_path = os.path.join(self.source_folder, "src", config) - cairo_gobject_src_path = os.path.join(self.source_folder, "util", "cairo-gobject", config) - lib_dest_path = os.path.join(self.package_folder, "lib") - runtime_dest_path = os.path.join(self.package_folder, "bin") - + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + 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") + 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) + self.copy(pattern="cairo-win32.h", dst=inc, src=src) + self.copy(pattern="cairo-script.h", dst=inc, src=src) + self.copy(pattern="cairo-ft.h", dst=inc, src=src) + self.copy(pattern="cairo-ps.h", dst=inc, src=src) + self.copy(pattern="cairo-pdf.h", dst=inc, src=src) + self.copy(pattern="cairo-svg.h", dst=inc, src=src) + self.copy(pattern="cairo-gobject.h", dst=inc, src=cairo_gobject) if self.options.shared: - copy(self, "*cairo.lib", lib_src_path, lib_dest_path) - copy(self, "*cairo.dll", lib_src_path, runtime_dest_path) - copy(self, "*cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) - copy(self, "*cairo-gobject.dll", cairo_gobject_src_path, runtime_dest_path) + self.copy(pattern="*cairo.lib", dst="lib", src=src, keep_path=False) + self.copy(pattern="*cairo.dll", dst="bin", src=src, keep_path=False) + self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) + self.copy(pattern="*cairo-gobject.dll", dst="bin", src=cairo_gobject, keep_path=False) else: - copy(self, "cairo-static.lib", lib_src_path, lib_dest_path) - copy(self, "cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) - rename(self, os.path.join(lib_dest_path, "cairo-static.lib"), os.path.join(lib_dest_path, "cairo.lib")) + self.copy(pattern="*cairo-static.lib", dst="lib", src=src, keep_path=False) + self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) + shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), + os.path.join(self.package_folder, "lib", "cairo.lib")) else: - autotools = Autotools(self, namespace="main") + autotools = self._configure_autotools() autotools.install() + tools.remove_files_by_mask(self.package_folder, "*.la") - copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) - rm(self, "*.la", self.package_folder, recursive=True) - rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) + 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") @@ -311,7 +268,7 @@ def package_info(self): if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if is_apple_os(self): + if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": @@ -344,7 +301,7 @@ def package_info(self): self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] - if is_apple_os(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"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] diff --git a/recipes/cairo/all/test_package/CMakeLists.txt b/recipes/cairo/all/test_package/CMakeLists.txt index 4f33d55898eb2..bed5cd67420b6 100644 --- a/recipes/cairo/all/test_package/CMakeLists.txt +++ b/recipes/cairo/all/test_package/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.1.2) project(test_package C) -find_package(cairo CONFIG REQUIRED) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PRIVATE cairo::cairo) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/cairo/all/test_package/conanfile.py b/recipes/cairo/all/test_package/conanfile.py index e904c93b97465..112349b422c25 100644 --- a/recipes/cairo/all/test_package/conanfile.py +++ b/recipes/cairo/all/test_package/conanfile.py @@ -1,19 +1,10 @@ -from conan import ConanFile -from conan.tools.cmake import CMake, cmake_layout -from conan.tools.build import can_run +from conans import ConanFile, CMake, tools import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" - test_type = "explicit" - - def requirements(self): - self.requires(self.tested_reference_str) - - def layout(self): - cmake_layout(self) + generators = "cmake" def build(self): cmake = CMake(self) @@ -21,6 +12,7 @@ def build(self): cmake.build() def test(self): - if can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") - self.run(bin_path, env="conanrun") + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/cairo/all/test_package/test_package.c b/recipes/cairo/all/test_package/test_package.c index 5854291cea177..e7474b6da5809 100644 --- a/recipes/cairo/all/test_package/test_package.c +++ b/recipes/cairo/all/test_package/test_package.c @@ -2,35 +2,8 @@ #include #include -#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT - -#include -#include - -#endif - int main() { -#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT - - HDC hDC = GetDC(0); - if (hDC) - { - cairo_surface_t * surface = cairo_win32_surface_create(hDC); - if (surface) - { - HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); - cairo_font_face_t* font = cairo_win32_font_face_create_for_hfont(hFont); - if (font) - cairo_font_face_destroy(font); - - cairo_surface_destroy(surface); - } - ReleaseDC(0, hDC); - } -#endif - printf("cairo version is %s\n", cairo_version_string()); - return 0; } diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 447193110deeb..3871b067363f2 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -20,7 +20,7 @@ from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.52.0" class CairoConan(ConanFile): @@ -90,16 +90,16 @@ def config_options(self): def configure(self): if self.options.shared: - self.options.rm_safe("fPIC") - self.settings.rm_safe("compiler.cppstd") - self.settings.rm_safe("compiler.libcxx") + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx if self.options.with_glib and self.options.shared: self.options["glib"].shared = True def requirements(self): self.requires("pixman/0.40.0") if self.options.with_zlib and self.options.with_png: - self.requires("expat/2.5.0") + self.requires("expat/2.4.9") if self.options.with_lzo: self.requires("lzo/2.10") if self.options.with_zlib: @@ -109,9 +109,9 @@ def requirements(self): if self.options.with_fontconfig: self.requires("fontconfig/2.13.93") if self.options.with_png: - self.requires("libpng/1.6.39") + self.requires("libpng/1.6.38") if self.options.with_glib: - self.requires("glib/2.75.0") + self.requires("glib/2.74.0") 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") @@ -125,7 +125,7 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.tool_requires("meson/0.64.1") + self.tool_requires("meson/0.63.3") self.tool_requires("pkgconf/1.9.3") def validate(self): From 5bfe1ab2378fd216cf59e0e32e76a603a6061314 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 5 Dec 2022 10:42:50 +0000 Subject: [PATCH 16/33] [cairo] bump deps in meson build --- recipes/cairo/meson/conanfile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 3871b067363f2..447193110deeb 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -20,7 +20,7 @@ from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version -required_conan_version = ">=1.52.0" +required_conan_version = ">=1.53.0" class CairoConan(ConanFile): @@ -90,16 +90,16 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") if self.options.with_glib and self.options.shared: self.options["glib"].shared = True def requirements(self): self.requires("pixman/0.40.0") if self.options.with_zlib and self.options.with_png: - self.requires("expat/2.4.9") + self.requires("expat/2.5.0") if self.options.with_lzo: self.requires("lzo/2.10") if self.options.with_zlib: @@ -109,9 +109,9 @@ def requirements(self): if self.options.with_fontconfig: self.requires("fontconfig/2.13.93") if self.options.with_png: - self.requires("libpng/1.6.38") + self.requires("libpng/1.6.39") if self.options.with_glib: - self.requires("glib/2.74.0") + self.requires("glib/2.75.0") 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") @@ -125,7 +125,7 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.tool_requires("meson/0.63.3") + self.tool_requires("meson/0.64.1") self.tool_requires("pkgconf/1.9.3") def validate(self): From caeebb9060094eede6da2e5f25c6648208db7904 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 5 Dec 2022 10:49:51 +0000 Subject: [PATCH 17/33] [cairo] bump deps in autotools build --- recipes/cairo/all/conanfile.py | 21 ++++++++++----------- recipes/cairo/meson/conanfile.py | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 363cd49cb6c52..05242804b3ba3 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -72,40 +72,39 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("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): + if self.dependencies["glib"].options.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): - self.requires("freetype/2.11.0") + self.requires("freetype/2.12.1") if self.options.get_safe("with_fontconfig", False): self.requires("fontconfig/2.13.93") 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") if self.options.get_safe("with_glib", True): - self.requires("glib/2.70.0") - self.requires("zlib/1.2.11") + self.requires("glib/2.75.0") + self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") - self.requires("libpng/1.6.37") + self.requires("libpng/1.6.39") def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): self.tool_requires("msys2/cci.latest") if not microsoft.is_msvc(self): - self.tool_requires("libtool/2.4.6") - self.tool_requires("pkgconf/1.7.4") + self.tool_requires("libtool/2.4.7") + self.tool_requires("pkgconf/1.9.3") self.tool_requires("gtk-doc-stub/cci.20181216") def source(self): diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 447193110deeb..fc4b0ed85b93d 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -132,7 +132,7 @@ 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: - if self.options["glib"].shared: + if self.dependencies["glib"].options.shared: if is_msvc_static_runtime(self): raise ConanInvalidConfiguration( "Linking shared glib with the MSVC static runtime is not supported" From 6f547d3e1cdf7449c25f2bc582fc3aa1ae4e21c0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 17 Dec 2022 17:59:11 +0000 Subject: [PATCH 18/33] [cairo] remove test-v1-package --- .../cairo/all/test_v1_package/CMakeLists.txt | 8 -------- recipes/cairo/all/test_v1_package/conanfile.py | 18 ------------------ 2 files changed, 26 deletions(-) delete mode 100644 recipes/cairo/all/test_v1_package/CMakeLists.txt delete mode 100644 recipes/cairo/all/test_v1_package/conanfile.py diff --git a/recipes/cairo/all/test_v1_package/CMakeLists.txt b/recipes/cairo/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 692a4909c85a7..0000000000000 --- a/recipes/cairo/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1.2) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairo/all/test_v1_package/conanfile.py b/recipes/cairo/all/test_v1_package/conanfile.py deleted file mode 100644 index 24f9e474d6cd2..0000000000000 --- a/recipes/cairo/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,18 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self, skip_x64_x86=True): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - From 2e3a64a6a5b3e01145a4a940a65fdf1f38f5fe5b Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 1 Jan 2023 15:02:18 +0000 Subject: [PATCH 19/33] Revert "[cairo] remove test-v1-package" This reverts commit 6f547d3e1cdf7449c25f2bc582fc3aa1ae4e21c0. --- .../cairo/all/test_v1_package/CMakeLists.txt | 8 ++++++++ recipes/cairo/all/test_v1_package/conanfile.py | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 recipes/cairo/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cairo/all/test_v1_package/conanfile.py diff --git a/recipes/cairo/all/test_v1_package/CMakeLists.txt b/recipes/cairo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..692a4909c85a7 --- /dev/null +++ b/recipes/cairo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1.2) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairo/all/test_v1_package/conanfile.py b/recipes/cairo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..24f9e474d6cd2 --- /dev/null +++ b/recipes/cairo/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + From 2b782c0c5c67986f267641cbbb2d9771493f6a46 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 1 Jan 2023 15:04:51 +0000 Subject: [PATCH 20/33] Revert "[cairo] revert recipe changes" restore modernization of autotools build --- recipes/cairo/all/conandata.yml | 20 +- recipes/cairo/all/conanfile.py | 326 ++++++++++-------- recipes/cairo/all/test_package/CMakeLists.txt | 5 +- recipes/cairo/all/test_package/conanfile.py | 20 +- recipes/cairo/all/test_package/test_package.c | 27 ++ 5 files changed, 242 insertions(+), 156 deletions(-) diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index e6ad418ca420e..a0a5e63d84308 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -11,16 +11,24 @@ sources: patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" + patch_type: portability + patch_description: support more features in MSVC build - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 + base_path: "util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 + base_path: "util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 + base_path: "util/cairo-trace" diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 05242804b3ba3..e89eb31a170cf 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,13 +1,26 @@ import os -import shutil from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools import files, microsoft, scm -from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment -from conans import tools - -required_conan_version = ">=1.50.0" +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + replace_in_file, + rename, + rm, + rmdir +) +from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" class CairoConan(ConanFile): @@ -38,31 +51,23 @@ class CairoConan(ConanFile): "with_xcb": True, "with_glib": True, } - - exports_sources = "patches/*" - generators = "pkg_config" - - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + short_paths = True @property def _settings_build(self): return getattr(self, "settings_build", self.settings) + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if microsoft.is_msvc(self): + if is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -77,10 +82,10 @@ def configure(self): self.settings.rm_safe("compiler.libcxx") def validate(self): - if microsoft.is_msvc(self): + if 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.dependencies["glib"].options.shared and microsoft.is_msvc_static_runtime(self): + 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" ) @@ -100,138 +105,177 @@ def requirements(self): self.requires("libpng/1.6.39") def build_requirements(self): - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.tool_requires("msys2/cci.latest") - if not microsoft.is_msvc(self): - self.tool_requires("libtool/2.4.7") + self.tool_requires("libtool/2.4.7") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): self.tool_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") + else: self.tool_requires("gtk-doc-stub/cci.20181216") - def source(self): - files.get(self, **self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + def layout(self): + basic_layout(self, src_folder="src") - def build(self): - files.apply_conandata_patches(self) - if microsoft.is_msvc(self): - self._build_msvc() - else: - self._build_configure() - - 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 ", 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", - self.deps_cpp_info["libpng"].libs[0] + ".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) - env_msvc.flags.append("/FS") # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS - with tools.environment_append(env_msvc.vars): - env_build = AutoToolsBuildEnvironment(self) - args=[ - "-f", "Makefile.win32", - f"CFG={str(self.settings.build_type).lower()}", - "CAIRO_HAS_FC_FONT=0", - 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) - env_build.make(args=["-C", os.path.join("util", "cairo-gobject")] + args) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - - def boolean(value): + def _create_toolchain(self, namespace, directory): + def is_enabled(value): return "yes" if value else "no" - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - configure_args = [ - 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", + def dep_path(dependency): + return unix_path(self, self.deps_cpp_info[dependency].rootpath) + + tc = AutotoolsToolchain(self, namespace=namespace) + tc.configure_args += [ + f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={is_enabled(self.options.get_safe('with_freetype', True))}", + f"--enable-gobject={is_enabled(self.options.get_safe('with_glib', True))}", + f"--enable-fc={is_enabled(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={is_enabled(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={is_enabled(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={is_enabled(self.options.get_safe('xcb'))}", + "--disable-gtk-doc" ] + if is_msvc(self): + tc.make_args += [ + "--directory", directory, + "-f", "Makefile.win32", + f"CFG={str(self.settings.build_type).lower()}", + "CAIRO_HAS_FC_FONT=0", + f"ZLIB_PATH={dep_path('zlib')}", + f"LIBPNG_PATH={dep_path('libpng')}", + f"PIXMAN_PATH={dep_path('pixman')}", + f"FREETYPE_PATH={dep_path('freetype')}", + f"GOBJECT_PATH={dep_path('glib')}" + ] + tc.extra_cflags += ["-FS"] + if self.settings.compiler in ["gcc", "clang", "apple-clang"]: - self._autotools.flags.append("-Wno-enum-conversion") - - with tools.run_environment(self): - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools - - def _build_configure(self): - with tools.chdir(self._source_subfolder): - # disable build of test suite - files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", - "") - if self.options.with_freetype: - 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")) - tools.touch(os.path.join("src", "Makefile.am.features")) - tools.touch("ChangeLog") - - with tools.environment_append({"GTKDOCIZE": "echo"}): - self.run( - f"{tools.get_env('AUTORECONF')} -fiv", - run_environment=True, - win_bash=tools.os_info.is_windows, - ) - autotools = self._configure_autotools() - autotools.make() + tc.extra_cflags.append("-Wno-enum-conversion") + + return tc + + def generate(self): + VirtualBuildEnv(self).generate() + + if not cross_building(self): + VirtualRunEnv(self).generate(scope="build") + + tc_main = self._create_toolchain("main", unix_path(self, self.source_folder)) + tc_main.generate() + + if is_msvc(self): + tc_gobject = self._create_toolchain("gobject", unix_path(self, os.path.join(self.source_folder, "util", "cairo-gobject"))) + tc_gobject.generate() + + PkgConfigDeps(self).generate() + deps = AutotoolsDeps(self) + if is_msvc(self): + cppflags = deps.vars().get("CPPFLAGS") + deps.environment.append('CFLAGS', cppflags.replace("/I", "-I")) + ldflags = deps.vars().get("LDFLAGS") + deps.environment.define('LDFLAGS', ldflags.replace("/LIBPATH:", "-LIBPATH:")) + deps.environment.append('LDFLAGS', deps.vars().get("LIBS")) + + deps.generate() + + def export_sources(self): + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + def fix_freetype_version(): + replace_in_file( + self, + os.path.join(self.source_folder, "configure.ac"), + "FREETYPE_MIN_VERSION=9.7.3", + f"FREETYPE_MIN_VERSION={Version(self.deps_cpp_info['freetype'].version)}" + ) + + def exclude_tests_and_docs_from_build(): + makefile_am = os.path.join(self.source_folder, "Makefile.am") + replace_in_file(self, makefile_am, "SUBDIRS += boilerplate test perf", "") + replace_in_file(self, makefile_am, "SUBDIRS = src doc util", "SUBDIRS = src util") + + fix_freetype_version() + exclude_tests_and_docs_from_build() + + if self.options.get_safe("with_freetype"): + replace_in_file(self, os.path.join(self.source_folder, "src", "cairo-ft-font.c"), + "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") + + if is_msvc(self): + # https://cairographics.org/end_to_end_build_for_win32/ + win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") + replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") + replace_in_file(self, win32_common, "$(PIXMAN_PATH)/lib/pixman-1.lib", + self.deps_cpp_info["pixman"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + self.deps_cpp_info["freetype"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + self.deps_cpp_info["zlib"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + self.deps_cpp_info["libpng"].libs[0] + ".lib") + + def build(self): + self._patch_sources() + autotools = Autotools(self, namespace="main") + if is_msvc(self): + autotools.make() + autotools_gobject = Autotools(self, namespace="gobject") + autotools_gobject.make() + else: + autotools.autoreconf() + autotools.configure() + autotools.make() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - 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") - 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) - self.copy(pattern="cairo-win32.h", dst=inc, src=src) - self.copy(pattern="cairo-script.h", dst=inc, src=src) - self.copy(pattern="cairo-ft.h", dst=inc, src=src) - self.copy(pattern="cairo-ps.h", dst=inc, src=src) - self.copy(pattern="cairo-pdf.h", dst=inc, src=src) - self.copy(pattern="cairo-svg.h", dst=inc, src=src) - self.copy(pattern="cairo-gobject.h", dst=inc, src=cairo_gobject) + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if is_msvc(self): + src = os.path.join(self.source_folder, "src") + inc = os.path.join(self.package_folder, "include", "cairo") + copy(self, "cairo-version.h", (src if Version(self.version) >= "1.17.4" else self.source_folder), inc) + copy(self, "cairo-features.h", src, inc) + copy(self, "cairo.h", src, inc) + copy(self, "cairo-deprecated.h", src, inc) + copy(self, "cairo-win32.h", src, inc) + copy(self, "cairo-script.h", src, inc) + copy(self, "cairo-ft.h", src, inc) + copy(self, "cairo-ps.h", src, inc) + copy(self, "cairo-pdf.h", src, inc) + copy(self, "cairo-svg.h", src, inc) + copy(self, "cairo-gobject.h", inc, os.path.join(self.source_folder, "util", "cairo-gobject")) + + config = str(self.settings.build_type).lower() + lib_src_path = os.path.join(self.source_folder, "src", config) + cairo_gobject_src_path = os.path.join(self.source_folder, "util", "cairo-gobject", config) + lib_dest_path = os.path.join(self.package_folder, "lib") + runtime_dest_path = os.path.join(self.package_folder, "bin") + if self.options.shared: - self.copy(pattern="*cairo.lib", dst="lib", src=src, keep_path=False) - self.copy(pattern="*cairo.dll", dst="bin", src=src, keep_path=False) - self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - self.copy(pattern="*cairo-gobject.dll", dst="bin", src=cairo_gobject, keep_path=False) + copy(self, "*cairo.lib", lib_src_path, lib_dest_path) + copy(self, "*cairo.dll", lib_src_path, runtime_dest_path) + copy(self, "*cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) + copy(self, "*cairo-gobject.dll", cairo_gobject_src_path, runtime_dest_path) else: - self.copy(pattern="*cairo-static.lib", dst="lib", src=src, keep_path=False) - self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), - os.path.join(self.package_folder, "lib", "cairo.lib")) + copy(self, "cairo-static.lib", lib_src_path, lib_dest_path) + copy(self, "cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) + rename(self, os.path.join(lib_dest_path, "cairo-static.lib"), os.path.join(lib_dest_path, "cairo.lib")) else: - autotools = self._configure_autotools() + autotools = Autotools(self, namespace="main") autotools.install() - tools.remove_files_by_mask(self.package_folder, "*.la") - self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.la", self.package_folder, recursive=True) + 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") @@ -267,7 +311,7 @@ def package_info(self): if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": @@ -300,7 +344,7 @@ def package_info(self): 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): + if is_apple_os(self): 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_"] diff --git a/recipes/cairo/all/test_package/CMakeLists.txt b/recipes/cairo/all/test_package/CMakeLists.txt index bed5cd67420b6..4f33d55898eb2 100644 --- a/recipes/cairo/all/test_package/CMakeLists.txt +++ b/recipes/cairo/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1.2) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cairo CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE cairo::cairo) diff --git a/recipes/cairo/all/test_package/conanfile.py b/recipes/cairo/all/test_package/conanfile.py index 112349b422c25..e904c93b97465 100644 --- a/recipes/cairo/all/test_package/conanfile.py +++ b/recipes/cairo/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self, skip_x64_x86=True): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cairo/all/test_package/test_package.c b/recipes/cairo/all/test_package/test_package.c index e7474b6da5809..5854291cea177 100644 --- a/recipes/cairo/all/test_package/test_package.c +++ b/recipes/cairo/all/test_package/test_package.c @@ -2,8 +2,35 @@ #include #include +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + +#include +#include + +#endif + int main() { +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + + HDC hDC = GetDC(0); + if (hDC) + { + cairo_surface_t * surface = cairo_win32_surface_create(hDC); + if (surface) + { + HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); + cairo_font_face_t* font = cairo_win32_font_face_create_for_hfont(hFont); + if (font) + cairo_font_face_destroy(font); + + cairo_surface_destroy(surface); + } + ReleaseDC(0, hDC); + } +#endif + printf("cairo version is %s\n", cairo_version_string()); + return 0; } From 992ae15be6ca93f729c81ec79f590086037aaa1b Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 1 Jan 2023 15:09:30 +0000 Subject: [PATCH 21/33] [cairo] bump dependencies --- recipes/cairo/all/conanfile.py | 2 +- recipes/cairo/meson/conanfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index e89eb31a170cf..cb461a5755b12 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -99,7 +99,7 @@ def requirements(self): if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") if self.options.get_safe("with_glib", True): - self.requires("glib/2.75.0") + self.requires("glib/2.75.1") self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") self.requires("libpng/1.6.39") diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index fc4b0ed85b93d..dcd66b70bf912 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -111,7 +111,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.39") if self.options.with_glib: - self.requires("glib/2.75.0") + self.requires("glib/2.75.1") 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") From 2095e9202cf018860cbd2d96a5dbe6599e951dba Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 1 Jan 2023 19:37:46 +0000 Subject: [PATCH 22/33] [cairo] use rm_safe --- 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 cb461a5755b12..7ce1d4686d45c 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -62,8 +62,8 @@ def _user_info_build(self): return getattr(self, "user_info_build", self.deps_user_info) def config_options(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig From f597cd04361108e737a2187d267d9a8d6612326a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 3 Jan 2023 08:32:16 +0000 Subject: [PATCH 23/33] [cairo] use rm_safe in meson build --- 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 dcd66b70bf912..71be7bacd6d91 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -76,8 +76,8 @@ def export_sources(self): export_conandata_patches(self) def config_options(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") if self.settings.os == "Windows": del self.options.fPIC if self.settings.os != "Linux": From f47aeab3825f0517717f98511f7083c24c6773a3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 4 Jan 2023 11:41:38 +0000 Subject: [PATCH 24/33] [cairo] add download mirror --- recipes/cairo/all/conandata.yml | 10 ++++++++-- recipes/cairo/meson/conandata.yml | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index a0a5e63d84308..affa65cd35e92 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -1,13 +1,19 @@ sources: "1.17.4": sha256: "74b24c1ed436bbe87499179a3b27c43f4143b8676d8ad237a6fa787401959705" - url: "https://www.cairographics.org/snapshots/cairo-1.17.4.tar.xz" + url: [ + "https://www.cairographics.org/snapshots/cairo-1.17.4.tar.xz", + "https://mirror.koddos.net/blfs/conglomeration/cairo/cairo-1.17.4.tar.xz" + ] "1.17.2": sha256: "6b70d4655e2a47a22b101c666f4b29ba746eda4aa8a0f7255b32b2e9408801df" url: "https://www.cairographics.org/snapshots/cairo-1.17.2.tar.xz" "1.16.0": sha256: "5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331" - url: "https://www.cairographics.org/releases/cairo-1.16.0.tar.xz" + url: [ + "https://www.cairographics.org/releases/cairo-1.16.0.tar.xz", + "https://mirror.koddos.net/blfs/conglomeration/cairo/cairo-1.16.0.tar.xz" + ] patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" diff --git a/recipes/cairo/meson/conandata.yml b/recipes/cairo/meson/conandata.yml index b5df6a0c87d1c..a11ad02ade2dd 100644 --- a/recipes/cairo/meson/conandata.yml +++ b/recipes/cairo/meson/conandata.yml @@ -1,7 +1,10 @@ sources: "1.17.4": sha256: "74b24c1ed436bbe87499179a3b27c43f4143b8676d8ad237a6fa787401959705" - url: "https://www.cairographics.org/snapshots/cairo-1.17.4.tar.xz" + url: [ + "https://www.cairographics.org/snapshots/cairo-1.17.4.tar.xz", + "https://mirror.koddos.net/blfs/conglomeration/cairo/cairo-1.17.4.tar.xz" + ] patches: "1.17.4": - patch_file: "patches/binutils-2.34-libbfd-fix.patch" From fa27bc77a88bc22f210e8a758839b7f45aa919b3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 5 Jan 2023 08:40:48 +0000 Subject: [PATCH 25/33] Revert update of autotools build to new toolchain --- recipes/cairo/all/conandata.yml | 20 +- recipes/cairo/all/conanfile.py | 332 ++++++++---------- recipes/cairo/all/test_package/CMakeLists.txt | 5 +- recipes/cairo/all/test_package/conanfile.py | 20 +- recipes/cairo/all/test_package/test_package.c | 27 -- .../cairo/all/test_v1_package/CMakeLists.txt | 8 - .../cairo/all/test_v1_package/conanfile.py | 18 - recipes/cairo/meson/conanfile.py | 2 +- 8 files changed, 160 insertions(+), 272 deletions(-) delete mode 100644 recipes/cairo/all/test_v1_package/CMakeLists.txt delete mode 100644 recipes/cairo/all/test_v1_package/conanfile.py diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index affa65cd35e92..7cce1fd16968f 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -17,24 +17,16 @@ sources: patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - patch_type: portability - patch_description: support more features in MSVC build + base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - patch_description: "fix build with newer versions of bfd" - patch_type: backport - patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 - base_path: "util/cairo-trace" + base_path: "source_subfolder/util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" + base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - patch_description: "fix build with newer versions of bfd" - patch_type: backport - patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 - base_path: "util/cairo-trace" + base_path: "source_subfolder/util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" + base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - patch_description: "fix build with newer versions of bfd" - patch_type: backport - patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 - base_path: "util/cairo-trace" + base_path: "source_subfolder/util/cairo-trace" diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 7ce1d4686d45c..05242804b3ba3 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,26 +1,13 @@ import os +import shutil from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.apple import is_apple_os -from conan.tools.build import cross_building -from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import ( - apply_conandata_patches, - copy, - export_conandata_patches, - get, - replace_in_file, - rename, - rm, - rmdir -) -from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsDeps, AutotoolsToolchain -from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path -from conan.tools.scm import Version - -required_conan_version = ">=1.53.0" +from conan.tools import files, microsoft, scm +from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans import tools + +required_conan_version = ">=1.50.0" class CairoConan(ConanFile): @@ -51,23 +38,31 @@ class CairoConan(ConanFile): "with_xcb": True, "with_glib": True, } - short_paths = True + + exports_sources = "patches/*" + generators = "pkg_config" + + _autotools = None @property - def _settings_build(self): - return getattr(self, "settings_build", self.settings) + def _source_subfolder(self): + return "source_subfolder" @property - def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) + def _build_subfolder(self): + return "build_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): - self.settings.rm_safe("compiler.libcxx") - self.settings.rm_safe("compiler.cppstd") + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if is_msvc(self): + if microsoft.is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -82,10 +77,10 @@ def configure(self): self.settings.rm_safe("compiler.libcxx") def validate(self): - if is_msvc(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.dependencies["glib"].options.shared and is_msvc_static_runtime(self): + if self.dependencies["glib"].options.shared and microsoft.is_msvc_static_runtime(self): raise ConanInvalidConfiguration( "Linking shared glib with the MSVC static runtime is not supported" ) @@ -99,183 +94,144 @@ def requirements(self): if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") if self.options.get_safe("with_glib", True): - self.requires("glib/2.75.1") + self.requires("glib/2.75.0") self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") self.requires("libpng/1.6.39") def build_requirements(self): - self.tool_requires("libtool/2.4.7") - if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") + if not microsoft.is_msvc(self): + self.tool_requires("libtool/2.4.7") self.tool_requires("pkgconf/1.9.3") - if self._settings_build.os == "Windows": - self.win_bash = True - if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): - self.tool_requires("msys2/cci.latest") - if is_msvc(self): - self.tool_requires("automake/1.16.5") - else: self.tool_requires("gtk-doc-stub/cci.20181216") - def layout(self): - basic_layout(self, src_folder="src") - - def _create_toolchain(self, namespace, directory): - def is_enabled(value): - return "yes" if value else "no" - - def dep_path(dependency): - return unix_path(self, self.deps_cpp_info[dependency].rootpath) - - tc = AutotoolsToolchain(self, namespace=namespace) - tc.configure_args += [ - f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", - f"--enable-ft={is_enabled(self.options.get_safe('with_freetype', True))}", - f"--enable-gobject={is_enabled(self.options.get_safe('with_glib', True))}", - f"--enable-fc={is_enabled(self.options.get_safe('with_fontconfig'))}", - f"--enable-xlib={is_enabled(self.options.get_safe('with_xlib'))}", - f"--enable-xlib_xrender={is_enabled(self.options.get_safe('with_xlib_xrender'))}", - f"--enable-xcb={is_enabled(self.options.get_safe('xcb'))}", - "--disable-gtk-doc" - ] - if is_msvc(self): - tc.make_args += [ - "--directory", directory, - "-f", "Makefile.win32", - f"CFG={str(self.settings.build_type).lower()}", - "CAIRO_HAS_FC_FONT=0", - f"ZLIB_PATH={dep_path('zlib')}", - f"LIBPNG_PATH={dep_path('libpng')}", - f"PIXMAN_PATH={dep_path('pixman')}", - f"FREETYPE_PATH={dep_path('freetype')}", - f"GOBJECT_PATH={dep_path('glib')}" - ] - tc.extra_cflags += ["-FS"] - - if self.settings.compiler in ["gcc", "clang", "apple-clang"]: - tc.extra_cflags.append("-Wno-enum-conversion") - - return tc - - def generate(self): - VirtualBuildEnv(self).generate() - - if not cross_building(self): - VirtualRunEnv(self).generate(scope="build") - - tc_main = self._create_toolchain("main", unix_path(self, self.source_folder)) - tc_main.generate() - - if is_msvc(self): - tc_gobject = self._create_toolchain("gobject", unix_path(self, os.path.join(self.source_folder, "util", "cairo-gobject"))) - tc_gobject.generate() - - PkgConfigDeps(self).generate() - deps = AutotoolsDeps(self) - if is_msvc(self): - cppflags = deps.vars().get("CPPFLAGS") - deps.environment.append('CFLAGS', cppflags.replace("/I", "-I")) - ldflags = deps.vars().get("LDFLAGS") - deps.environment.define('LDFLAGS', ldflags.replace("/LIBPATH:", "-LIBPATH:")) - deps.environment.append('LDFLAGS', deps.vars().get("LIBS")) - - deps.generate() - - def export_sources(self): - export_conandata_patches(self) - def source(self): - get(self, **self.conan_data["sources"][self.version], - destination=self.source_folder, strip_root=True) - - def _patch_sources(self): - apply_conandata_patches(self) - - def fix_freetype_version(): - replace_in_file( - self, - os.path.join(self.source_folder, "configure.ac"), - "FREETYPE_MIN_VERSION=9.7.3", - f"FREETYPE_MIN_VERSION={Version(self.deps_cpp_info['freetype'].version)}" - ) - - def exclude_tests_and_docs_from_build(): - makefile_am = os.path.join(self.source_folder, "Makefile.am") - replace_in_file(self, makefile_am, "SUBDIRS += boilerplate test perf", "") - replace_in_file(self, makefile_am, "SUBDIRS = src doc util", "SUBDIRS = src util") + files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - fix_freetype_version() - exclude_tests_and_docs_from_build() - - if self.options.get_safe("with_freetype"): - replace_in_file(self, os.path.join(self.source_folder, "src", "cairo-ft-font.c"), - "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") + def build(self): + files.apply_conandata_patches(self) + if microsoft.is_msvc(self): + self._build_msvc() + else: + self._build_configure() - if is_msvc(self): + def _build_msvc(self): + with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ - win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") - replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") - replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") - replace_in_file(self, win32_common, "$(PIXMAN_PATH)/lib/pixman-1.lib", - self.deps_cpp_info["pixman"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", - self.deps_cpp_info["freetype"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", - self.deps_cpp_info["zlib"].libs[0] + ".lib") - replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", - self.deps_cpp_info["libpng"].libs[0] + ".lib") + win32_common = os.path.join("build", "Makefile.win32.common") + 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", + self.deps_cpp_info["libpng"].libs[0] + ".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) + env_msvc.flags.append("/FS") # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS + with tools.environment_append(env_msvc.vars): + env_build = AutoToolsBuildEnvironment(self) + args=[ + "-f", "Makefile.win32", + f"CFG={str(self.settings.build_type).lower()}", + "CAIRO_HAS_FC_FONT=0", + 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) + env_build.make(args=["-C", os.path.join("util", "cairo-gobject")] + args) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + + def boolean(value): + return "yes" if value else "no" - def build(self): - self._patch_sources() - autotools = Autotools(self, namespace="main") - if is_msvc(self): - autotools.make() - autotools_gobject = Autotools(self, namespace="gobject") - autotools_gobject.make() - else: - autotools.autoreconf() - autotools.configure() - autotools.make() + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + configure_args = [ + 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"]: + self._autotools.flags.append("-Wno-enum-conversion") + + with tools.run_environment(self): + self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return self._autotools + + def _build_configure(self): + with tools.chdir(self._source_subfolder): + # disable build of test suite + files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", + "") + if self.options.with_freetype: + 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")) + tools.touch(os.path.join("src", "Makefile.am.features")) + tools.touch("ChangeLog") + + with tools.environment_append({"GTKDOCIZE": "echo"}): + self.run( + f"{tools.get_env('AUTORECONF')} -fiv", + run_environment=True, + win_bash=tools.os_info.is_windows, + ) + autotools = self._configure_autotools() + autotools.make() def package(self): - copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) - if is_msvc(self): - src = os.path.join(self.source_folder, "src") - inc = os.path.join(self.package_folder, "include", "cairo") - copy(self, "cairo-version.h", (src if Version(self.version) >= "1.17.4" else self.source_folder), inc) - copy(self, "cairo-features.h", src, inc) - copy(self, "cairo.h", src, inc) - copy(self, "cairo-deprecated.h", src, inc) - copy(self, "cairo-win32.h", src, inc) - copy(self, "cairo-script.h", src, inc) - copy(self, "cairo-ft.h", src, inc) - copy(self, "cairo-ps.h", src, inc) - copy(self, "cairo-pdf.h", src, inc) - copy(self, "cairo-svg.h", src, inc) - copy(self, "cairo-gobject.h", inc, os.path.join(self.source_folder, "util", "cairo-gobject")) - - config = str(self.settings.build_type).lower() - lib_src_path = os.path.join(self.source_folder, "src", config) - cairo_gobject_src_path = os.path.join(self.source_folder, "util", "cairo-gobject", config) - lib_dest_path = os.path.join(self.package_folder, "lib") - runtime_dest_path = os.path.join(self.package_folder, "bin") - + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + 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") + 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) + self.copy(pattern="cairo-win32.h", dst=inc, src=src) + self.copy(pattern="cairo-script.h", dst=inc, src=src) + self.copy(pattern="cairo-ft.h", dst=inc, src=src) + self.copy(pattern="cairo-ps.h", dst=inc, src=src) + self.copy(pattern="cairo-pdf.h", dst=inc, src=src) + self.copy(pattern="cairo-svg.h", dst=inc, src=src) + self.copy(pattern="cairo-gobject.h", dst=inc, src=cairo_gobject) if self.options.shared: - copy(self, "*cairo.lib", lib_src_path, lib_dest_path) - copy(self, "*cairo.dll", lib_src_path, runtime_dest_path) - copy(self, "*cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) - copy(self, "*cairo-gobject.dll", cairo_gobject_src_path, runtime_dest_path) + self.copy(pattern="*cairo.lib", dst="lib", src=src, keep_path=False) + self.copy(pattern="*cairo.dll", dst="bin", src=src, keep_path=False) + self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) + self.copy(pattern="*cairo-gobject.dll", dst="bin", src=cairo_gobject, keep_path=False) else: - copy(self, "cairo-static.lib", lib_src_path, lib_dest_path) - copy(self, "cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) - rename(self, os.path.join(lib_dest_path, "cairo-static.lib"), os.path.join(lib_dest_path, "cairo.lib")) + self.copy(pattern="*cairo-static.lib", dst="lib", src=src, keep_path=False) + self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) + shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), + os.path.join(self.package_folder, "lib", "cairo.lib")) else: - autotools = Autotools(self, namespace="main") + autotools = self._configure_autotools() autotools.install() + tools.remove_files_by_mask(self.package_folder, "*.la") - copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) - rm(self, "*.la", self.package_folder, recursive=True) - rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) + 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") @@ -311,7 +267,7 @@ def package_info(self): if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if is_apple_os(self): + if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": @@ -344,7 +300,7 @@ def package_info(self): self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] - if is_apple_os(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"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] diff --git a/recipes/cairo/all/test_package/CMakeLists.txt b/recipes/cairo/all/test_package/CMakeLists.txt index 4f33d55898eb2..bed5cd67420b6 100644 --- a/recipes/cairo/all/test_package/CMakeLists.txt +++ b/recipes/cairo/all/test_package/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.1.2) project(test_package C) -find_package(cairo CONFIG REQUIRED) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PRIVATE cairo::cairo) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/cairo/all/test_package/conanfile.py b/recipes/cairo/all/test_package/conanfile.py index e904c93b97465..112349b422c25 100644 --- a/recipes/cairo/all/test_package/conanfile.py +++ b/recipes/cairo/all/test_package/conanfile.py @@ -1,19 +1,10 @@ -from conan import ConanFile -from conan.tools.cmake import CMake, cmake_layout -from conan.tools.build import can_run +from conans import ConanFile, CMake, tools import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" - test_type = "explicit" - - def requirements(self): - self.requires(self.tested_reference_str) - - def layout(self): - cmake_layout(self) + generators = "cmake" def build(self): cmake = CMake(self) @@ -21,6 +12,7 @@ def build(self): cmake.build() def test(self): - if can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") - self.run(bin_path, env="conanrun") + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/cairo/all/test_package/test_package.c b/recipes/cairo/all/test_package/test_package.c index 5854291cea177..e7474b6da5809 100644 --- a/recipes/cairo/all/test_package/test_package.c +++ b/recipes/cairo/all/test_package/test_package.c @@ -2,35 +2,8 @@ #include #include -#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT - -#include -#include - -#endif - int main() { -#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT - - HDC hDC = GetDC(0); - if (hDC) - { - cairo_surface_t * surface = cairo_win32_surface_create(hDC); - if (surface) - { - HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); - cairo_font_face_t* font = cairo_win32_font_face_create_for_hfont(hFont); - if (font) - cairo_font_face_destroy(font); - - cairo_surface_destroy(surface); - } - ReleaseDC(0, hDC); - } -#endif - printf("cairo version is %s\n", cairo_version_string()); - return 0; } diff --git a/recipes/cairo/all/test_v1_package/CMakeLists.txt b/recipes/cairo/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 692a4909c85a7..0000000000000 --- a/recipes/cairo/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1.2) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairo/all/test_v1_package/conanfile.py b/recipes/cairo/all/test_v1_package/conanfile.py deleted file mode 100644 index 24f9e474d6cd2..0000000000000 --- a/recipes/cairo/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,18 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self, skip_x64_x86=True): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 71be7bacd6d91..de6215c05313e 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -111,7 +111,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.39") if self.options.with_glib: - self.requires("glib/2.75.1") + self.requires("glib/2.75.0") 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") From 413e828c04f43616182c3e0b991fcd04fc795cf3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 5 Jan 2023 08:42:31 +0000 Subject: [PATCH 26/33] [cairo] bump glib dependency --- recipes/cairo/all/conanfile.py | 2 +- recipes/cairo/meson/conanfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 05242804b3ba3..ba14914d29b0b 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -94,7 +94,7 @@ def requirements(self): if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") if self.options.get_safe("with_glib", True): - self.requires("glib/2.75.0") + self.requires("glib/2.75.1") self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") self.requires("libpng/1.6.39") diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index de6215c05313e..71be7bacd6d91 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -111,7 +111,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.39") if self.options.with_glib: - self.requires("glib/2.75.0") + self.requires("glib/2.75.1") 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") From d8d0aebd9676ab278122f55b96052415d38fd864 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Jan 2023 14:38:11 +0000 Subject: [PATCH 27/33] [cairo] disable autotools build for macos --- recipes/cairo/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index ba14914d29b0b..e6badcc79f98b 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -4,6 +4,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools import files, microsoft, scm +from conan.tools.apple import is_apple_os from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment from conans import tools @@ -77,6 +78,9 @@ def configure(self): self.settings.rm_safe("compiler.libcxx") def validate(self): + if is_apple_os(self): + # TODO V2 autotools can handle macos build - but there are issues building on CCI. See PR #13943 + raise ConanInvalidConfiguration("Cairo autotools build is not supported on Macos") 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") From 27950e4ff8651ef3c1f00d5ff9797e447dbe7caf Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Jan 2023 12:07:39 +0000 Subject: [PATCH 28/33] Revert "[cairo] disable autotools build for macos" This reverts commit d8d0aebd9676ab278122f55b96052415d38fd864. --- recipes/cairo/all/conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index e6badcc79f98b..ba14914d29b0b 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -4,7 +4,6 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools import files, microsoft, scm -from conan.tools.apple import is_apple_os from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment from conans import tools @@ -78,9 +77,6 @@ def configure(self): self.settings.rm_safe("compiler.libcxx") def validate(self): - if is_apple_os(self): - # TODO V2 autotools can handle macos build - but there are issues building on CCI. See PR #13943 - raise ConanInvalidConfiguration("Cairo autotools build is not supported on Macos") 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") From fc26c9dfd4c97c913bc7140a977f736bdea25834 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Jan 2023 12:07:39 +0000 Subject: [PATCH 29/33] Revert "Revert update of autotools build to new toolchain" This reverts commit fa27bc77a88bc22f210e8a758839b7f45aa919b3. --- recipes/cairo/all/conandata.yml | 20 +- recipes/cairo/all/conanfile.py | 330 ++++++++++-------- recipes/cairo/all/test_package/CMakeLists.txt | 5 +- recipes/cairo/all/test_package/conanfile.py | 20 +- recipes/cairo/all/test_package/test_package.c | 27 ++ .../cairo/all/test_v1_package/CMakeLists.txt | 8 + .../cairo/all/test_v1_package/conanfile.py | 18 + 7 files changed, 270 insertions(+), 158 deletions(-) create mode 100644 recipes/cairo/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cairo/all/test_v1_package/conanfile.py diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index 7cce1fd16968f..affa65cd35e92 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -17,16 +17,24 @@ sources: patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" + patch_type: portability + patch_description: support more features in MSVC build - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 + base_path: "util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 + base_path: "util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" - base_path: "source_subfolder" - patch_file: "patches/binutils-2.34-libbfd-fix.patch" - base_path: "source_subfolder/util/cairo-trace" + patch_description: "fix build with newer versions of bfd" + patch_type: backport + patch_source: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/128 + base_path: "util/cairo-trace" diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index ba14914d29b0b..7ce1d4686d45c 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,13 +1,26 @@ import os -import shutil from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools import files, microsoft, scm -from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment -from conans import tools - -required_conan_version = ">=1.50.0" +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + replace_in_file, + rename, + rm, + rmdir +) +from conan.tools.gnu import PkgConfigDeps, Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" class CairoConan(ConanFile): @@ -38,31 +51,23 @@ class CairoConan(ConanFile): "with_xcb": True, "with_glib": True, } - - exports_sources = "patches/*" - generators = "pkg_config" - - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + short_paths = True @property def _settings_build(self): return getattr(self, "settings_build", self.settings) + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if microsoft.is_msvc(self): + if is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -77,10 +82,10 @@ def configure(self): self.settings.rm_safe("compiler.libcxx") def validate(self): - if microsoft.is_msvc(self): + if 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.dependencies["glib"].options.shared and microsoft.is_msvc_static_runtime(self): + 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" ) @@ -100,138 +105,177 @@ def requirements(self): self.requires("libpng/1.6.39") def build_requirements(self): - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.tool_requires("msys2/cci.latest") - if not microsoft.is_msvc(self): - self.tool_requires("libtool/2.4.7") + self.tool_requires("libtool/2.4.7") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): self.tool_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") + else: self.tool_requires("gtk-doc-stub/cci.20181216") - def source(self): - files.get(self, **self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def build(self): - files.apply_conandata_patches(self) - if microsoft.is_msvc(self): - self._build_msvc() - else: - self._build_configure() + def layout(self): + basic_layout(self, src_folder="src") - 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 ", 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", - self.deps_cpp_info["libpng"].libs[0] + ".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) - env_msvc.flags.append("/FS") # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS - with tools.environment_append(env_msvc.vars): - env_build = AutoToolsBuildEnvironment(self) - args=[ - "-f", "Makefile.win32", - f"CFG={str(self.settings.build_type).lower()}", - "CAIRO_HAS_FC_FONT=0", - 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) - env_build.make(args=["-C", os.path.join("util", "cairo-gobject")] + args) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - - def boolean(value): + def _create_toolchain(self, namespace, directory): + def is_enabled(value): return "yes" if value else "no" - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - configure_args = [ - 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", + def dep_path(dependency): + return unix_path(self, self.deps_cpp_info[dependency].rootpath) + + tc = AutotoolsToolchain(self, namespace=namespace) + tc.configure_args += [ + f"--datarootdir={unix_path(self, os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={is_enabled(self.options.get_safe('with_freetype', True))}", + f"--enable-gobject={is_enabled(self.options.get_safe('with_glib', True))}", + f"--enable-fc={is_enabled(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={is_enabled(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={is_enabled(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={is_enabled(self.options.get_safe('xcb'))}", + "--disable-gtk-doc" ] + if is_msvc(self): + tc.make_args += [ + "--directory", directory, + "-f", "Makefile.win32", + f"CFG={str(self.settings.build_type).lower()}", + "CAIRO_HAS_FC_FONT=0", + f"ZLIB_PATH={dep_path('zlib')}", + f"LIBPNG_PATH={dep_path('libpng')}", + f"PIXMAN_PATH={dep_path('pixman')}", + f"FREETYPE_PATH={dep_path('freetype')}", + f"GOBJECT_PATH={dep_path('glib')}" + ] + tc.extra_cflags += ["-FS"] + if self.settings.compiler in ["gcc", "clang", "apple-clang"]: - self._autotools.flags.append("-Wno-enum-conversion") - - with tools.run_environment(self): - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools - - def _build_configure(self): - with tools.chdir(self._source_subfolder): - # disable build of test suite - files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", - "") - if self.options.with_freetype: - 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")) - tools.touch(os.path.join("src", "Makefile.am.features")) - tools.touch("ChangeLog") - - with tools.environment_append({"GTKDOCIZE": "echo"}): - self.run( - f"{tools.get_env('AUTORECONF')} -fiv", - run_environment=True, - win_bash=tools.os_info.is_windows, - ) - autotools = self._configure_autotools() - autotools.make() + tc.extra_cflags.append("-Wno-enum-conversion") + + return tc + + def generate(self): + VirtualBuildEnv(self).generate() + + if not cross_building(self): + VirtualRunEnv(self).generate(scope="build") + + tc_main = self._create_toolchain("main", unix_path(self, self.source_folder)) + tc_main.generate() + + if is_msvc(self): + tc_gobject = self._create_toolchain("gobject", unix_path(self, os.path.join(self.source_folder, "util", "cairo-gobject"))) + tc_gobject.generate() + + PkgConfigDeps(self).generate() + deps = AutotoolsDeps(self) + if is_msvc(self): + cppflags = deps.vars().get("CPPFLAGS") + deps.environment.append('CFLAGS', cppflags.replace("/I", "-I")) + ldflags = deps.vars().get("LDFLAGS") + deps.environment.define('LDFLAGS', ldflags.replace("/LIBPATH:", "-LIBPATH:")) + deps.environment.append('LDFLAGS', deps.vars().get("LIBS")) + + deps.generate() + + def export_sources(self): + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + def fix_freetype_version(): + replace_in_file( + self, + os.path.join(self.source_folder, "configure.ac"), + "FREETYPE_MIN_VERSION=9.7.3", + f"FREETYPE_MIN_VERSION={Version(self.deps_cpp_info['freetype'].version)}" + ) + + def exclude_tests_and_docs_from_build(): + makefile_am = os.path.join(self.source_folder, "Makefile.am") + replace_in_file(self, makefile_am, "SUBDIRS += boilerplate test perf", "") + replace_in_file(self, makefile_am, "SUBDIRS = src doc util", "SUBDIRS = src util") + + fix_freetype_version() + exclude_tests_and_docs_from_build() + + if self.options.get_safe("with_freetype"): + replace_in_file(self, os.path.join(self.source_folder, "src", "cairo-ft-font.c"), + "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") + + if is_msvc(self): + # https://cairographics.org/end_to_end_build_for_win32/ + win32_common = os.path.join(self.source_folder, "build", "Makefile.win32.common") + replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") + replace_in_file(self, win32_common, "$(PIXMAN_PATH)/lib/pixman-1.lib", + self.deps_cpp_info["pixman"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + self.deps_cpp_info["freetype"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + self.deps_cpp_info["zlib"].libs[0] + ".lib") + replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + self.deps_cpp_info["libpng"].libs[0] + ".lib") + + def build(self): + self._patch_sources() + autotools = Autotools(self, namespace="main") + if is_msvc(self): + autotools.make() + autotools_gobject = Autotools(self, namespace="gobject") + autotools_gobject.make() + else: + autotools.autoreconf() + autotools.configure() + autotools.make() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - 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") - 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) - self.copy(pattern="cairo-win32.h", dst=inc, src=src) - self.copy(pattern="cairo-script.h", dst=inc, src=src) - self.copy(pattern="cairo-ft.h", dst=inc, src=src) - self.copy(pattern="cairo-ps.h", dst=inc, src=src) - self.copy(pattern="cairo-pdf.h", dst=inc, src=src) - self.copy(pattern="cairo-svg.h", dst=inc, src=src) - self.copy(pattern="cairo-gobject.h", dst=inc, src=cairo_gobject) + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if is_msvc(self): + src = os.path.join(self.source_folder, "src") + inc = os.path.join(self.package_folder, "include", "cairo") + copy(self, "cairo-version.h", (src if Version(self.version) >= "1.17.4" else self.source_folder), inc) + copy(self, "cairo-features.h", src, inc) + copy(self, "cairo.h", src, inc) + copy(self, "cairo-deprecated.h", src, inc) + copy(self, "cairo-win32.h", src, inc) + copy(self, "cairo-script.h", src, inc) + copy(self, "cairo-ft.h", src, inc) + copy(self, "cairo-ps.h", src, inc) + copy(self, "cairo-pdf.h", src, inc) + copy(self, "cairo-svg.h", src, inc) + copy(self, "cairo-gobject.h", inc, os.path.join(self.source_folder, "util", "cairo-gobject")) + + config = str(self.settings.build_type).lower() + lib_src_path = os.path.join(self.source_folder, "src", config) + cairo_gobject_src_path = os.path.join(self.source_folder, "util", "cairo-gobject", config) + lib_dest_path = os.path.join(self.package_folder, "lib") + runtime_dest_path = os.path.join(self.package_folder, "bin") + if self.options.shared: - self.copy(pattern="*cairo.lib", dst="lib", src=src, keep_path=False) - self.copy(pattern="*cairo.dll", dst="bin", src=src, keep_path=False) - self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - self.copy(pattern="*cairo-gobject.dll", dst="bin", src=cairo_gobject, keep_path=False) + copy(self, "*cairo.lib", lib_src_path, lib_dest_path) + copy(self, "*cairo.dll", lib_src_path, runtime_dest_path) + copy(self, "*cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) + copy(self, "*cairo-gobject.dll", cairo_gobject_src_path, runtime_dest_path) else: - self.copy(pattern="*cairo-static.lib", dst="lib", src=src, keep_path=False) - self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), - os.path.join(self.package_folder, "lib", "cairo.lib")) + copy(self, "cairo-static.lib", lib_src_path, lib_dest_path) + copy(self, "cairo-gobject.lib", cairo_gobject_src_path, lib_dest_path) + rename(self, os.path.join(lib_dest_path, "cairo-static.lib"), os.path.join(lib_dest_path, "cairo.lib")) else: - autotools = self._configure_autotools() + autotools = Autotools(self, namespace="main") autotools.install() - tools.remove_files_by_mask(self.package_folder, "*.la") - self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.la", self.package_folder, recursive=True) + 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") @@ -267,7 +311,7 @@ def package_info(self): if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") if self.settings.os == "Windows": @@ -300,7 +344,7 @@ def package_info(self): 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): + if is_apple_os(self): 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_"] diff --git a/recipes/cairo/all/test_package/CMakeLists.txt b/recipes/cairo/all/test_package/CMakeLists.txt index bed5cd67420b6..4f33d55898eb2 100644 --- a/recipes/cairo/all/test_package/CMakeLists.txt +++ b/recipes/cairo/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1.2) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cairo CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE cairo::cairo) diff --git a/recipes/cairo/all/test_package/conanfile.py b/recipes/cairo/all/test_package/conanfile.py index 112349b422c25..e904c93b97465 100644 --- a/recipes/cairo/all/test_package/conanfile.py +++ b/recipes/cairo/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self, skip_x64_x86=True): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cairo/all/test_package/test_package.c b/recipes/cairo/all/test_package/test_package.c index e7474b6da5809..5854291cea177 100644 --- a/recipes/cairo/all/test_package/test_package.c +++ b/recipes/cairo/all/test_package/test_package.c @@ -2,8 +2,35 @@ #include #include +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + +#include +#include + +#endif + int main() { +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + + HDC hDC = GetDC(0); + if (hDC) + { + cairo_surface_t * surface = cairo_win32_surface_create(hDC); + if (surface) + { + HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); + cairo_font_face_t* font = cairo_win32_font_face_create_for_hfont(hFont); + if (font) + cairo_font_face_destroy(font); + + cairo_surface_destroy(surface); + } + ReleaseDC(0, hDC); + } +#endif + printf("cairo version is %s\n", cairo_version_string()); + return 0; } diff --git a/recipes/cairo/all/test_v1_package/CMakeLists.txt b/recipes/cairo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..692a4909c85a7 --- /dev/null +++ b/recipes/cairo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1.2) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairo/all/test_v1_package/conanfile.py b/recipes/cairo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..24f9e474d6cd2 --- /dev/null +++ b/recipes/cairo/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + From b407fe22b40ff88ade51dc42147af8815d3507bd Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Jan 2023 12:13:20 +0000 Subject: [PATCH 30/33] [cairo] bump dependencies --- recipes/cairo/all/conanfile.py | 2 +- recipes/cairo/meson/conanfile.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 7ce1d4686d45c..6f49ada0064f2 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -99,7 +99,7 @@ def requirements(self): if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") if self.options.get_safe("with_glib", True): - self.requires("glib/2.75.1") + self.requires("glib/2.75.2") self.requires("zlib/1.2.13") self.requires("pixman/0.40.0") self.requires("libpng/1.6.39") diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 71be7bacd6d91..8208f1f3fc298 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -111,7 +111,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.39") if self.options.with_glib: - self.requires("glib/2.75.1") + self.requires("glib/2.75.2") 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") @@ -125,7 +125,7 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.tool_requires("meson/0.64.1") + self.tool_requires("meson/1.0.0") self.tool_requires("pkgconf/1.9.3") def validate(self): From da9842cd4e3f6390dfa4cf32066176c3bd740270 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Jan 2023 15:36:27 +0000 Subject: [PATCH 31/33] [cairo] disable msvc build where LNK1127 error manifests --- recipes/cairo/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 6f49ada0064f2..a5173648acf1e 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -83,6 +83,11 @@ def configure(self): def validate(self): if is_msvc(self): + version = Version(self.version) + if version < "1.17.2" and self.settings.build_type == "Debug": + # TODO autotools build results in LNK1127 error from a library in the WindowsSDK on CCI + # should be retested in case this is just a CCI environment issue + raise ConanInvalidConfiguration("MSVC Debug build is only supported for 1.17.2 and later") if self.settings.build_type not in ["Debug", "Release"]: raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") if self.dependencies["glib"].options.shared and is_msvc_static_runtime(self): From bbbd7bf2da1befe6e0ed8c51426c4be03543660c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Jan 2023 17:34:04 +0000 Subject: [PATCH 32/33] [cairo] disable msvc build entirely for autotools --- recipes/cairo/all/conanfile.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index a5173648acf1e..bf7b382fbcd46 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -83,17 +83,7 @@ def configure(self): def validate(self): if is_msvc(self): - version = Version(self.version) - if version < "1.17.2" and self.settings.build_type == "Debug": - # TODO autotools build results in LNK1127 error from a library in the WindowsSDK on CCI - # should be retested in case this is just a CCI environment issue - raise ConanInvalidConfiguration("MSVC Debug build is only supported for 1.17.2 and later") - if self.settings.build_type not in ["Debug", "Release"]: - raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") - 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" - ) + raise ConanInvalidConfiguration("MSVC autotools build is not supported. Use the Meson build instead.") def requirements(self): if self.options.get_safe("with_freetype", True): From fcd0f023905723068650df2707a2d6b49eed4851 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Jan 2023 18:53:58 +0000 Subject: [PATCH 33/33] [cairo] add alternative mirror for 1.17.2 --- recipes/cairo/all/conandata.yml | 5 ++++- recipes/cairo/all/conanfile.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index affa65cd35e92..9402c1b9260e5 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -7,7 +7,10 @@ sources: ] "1.17.2": sha256: "6b70d4655e2a47a22b101c666f4b29ba746eda4aa8a0f7255b32b2e9408801df" - url: "https://www.cairographics.org/snapshots/cairo-1.17.2.tar.xz" + url: [ + "https://www.cairographics.org/snapshots/cairo-1.17.2.tar.xz", + "https://www.mirrorservice.org/sites/tinycorelinux.net/11.x/x86_64/tcz/src/cairo/cairo-1.17.2.tar.xz" + ] "1.16.0": sha256: "5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331" url: [ diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index bf7b382fbcd46..4b88236ddeb7c 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -83,6 +83,8 @@ def configure(self): def validate(self): if is_msvc(self): + # TODO autotools build results in LNK1127 error from a library in the WindowsSDK on CCI + # should be retested in case this is just a CCI environment issue raise ConanInvalidConfiguration("MSVC autotools build is not supported. Use the Meson build instead.") def requirements(self):