Skip to content

Commit

Permalink
(#21137) gdk-pixbuf: bump deps and several fixes
Browse files Browse the repository at this point in the history
* gdk-pixbuf: bump deps, fix static build

* enable gdk-pixbuf build for clang 13 and newer

* Revert "enable gdk-pixbuf build for clang 13 and newer"

This reverts commit 3fe80de.

* Added upstream report for the patch. Removed Macos validation. Added workaround for the breaking change to pkgconfig_variables

* Added workaround

* Using libgettext provided by Conan

* Update recipes/gdk-pixbuf/all/conanfile.py

* macOS always uses Conan libgettext

* Blank spaces

* Improved Conan libgettext requirement line in meson.build

* Adding gettext as tool require

* blank

* Simplifying (a little bit)

---------

Co-authored-by: Walid Boussafa <boussaffa.walid@outlook.com>
Co-authored-by: Rubén Rincón <rubenrb@jfrog.com>
Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com>
  • Loading branch information
4 people authored Mar 6, 2024
1 parent 9c7b034 commit 0b3b4ba
Showing 1 changed file with 49 additions and 27 deletions.
76 changes: 49 additions & 27 deletions recipes/gdk-pixbuf/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
Expand All @@ -10,15 +12,13 @@
from conan.tools.microsoft import is_msvc_static_runtime
from conan.tools.scm import Version

import os

required_conan_version = ">=1.56.0 <2 || >=2.0.6"
required_conan_version = ">=1.56.0 <2 || >=2.0.8"


class GdkPixbufConan(ConanFile):
name = "gdk-pixbuf"
description = "toolkit for image loading and pixel buffer manipulation"
topics = ("image")
topics = "image"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://developer.gnome.org/gdk-pixbuf/"
license = "LGPL-2.1-or-later"
Expand Down Expand Up @@ -63,36 +63,35 @@ def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("glib/2.77.0", transitive_headers=True, transitive_libs=True)
self.requires("glib/2.78.1", transitive_headers=True, transitive_libs=True)
if self.options.with_libpng:
self.requires("libpng/1.6.40")
if self.options.with_libtiff:
self.requires("libtiff/4.4.0")
self.requires("libtiff/4.6.0")
if self.options.with_libjpeg == "libjpeg-turbo":
self.requires("libjpeg-turbo/2.1.5")
self.requires("libjpeg-turbo/3.0.1")
elif self.options.with_libjpeg == "libjpeg":
self.requires("libjpeg/9e")
elif self.options.with_libjpeg == "mozjpeg":
self.requires("mozjpeg/4.1.1")
self.requires("mozjpeg/4.1.3")

def validate(self):
if self.options.shared and not self.dependencies["glib"].options.shared:
raise ConanInvalidConfiguration(
"Linking a shared library against static glib can cause unexpected behaviour."
)
if self.settings.os == "Macos":
# when running gdk-pixbuf-query-loaders
# dyld: malformed mach-o: load commands size (97560) > 32768
raise ConanInvalidConfiguration("This package does not support Macos currently")
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"
)

def build_requirements(self):
self.tool_requires("meson/1.0.0")
self.tool_requires("meson/1.2.3")
# FIXME: unify libgettext and gettext??
# INFO: gettext provides msgfmt, which is required to build the .mo files
self.tool_requires("gettext/0.21")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/1.9.3")
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("glib/<host_version>")
if self.options.with_introspection:
self.tool_requires("gobject-introspection/1.72.0")
Expand All @@ -113,7 +112,6 @@ def generate(self):

deps = PkgConfigDeps(self)
deps.generate()

tc = MesonToolchain(self)
enabled_disabled = lambda v: "enabled" if v else "disabled"
true_false = lambda v: "true" if v else "false"
Expand All @@ -140,7 +138,6 @@ def generate(self):
"tiff": true_false(self.options.with_libtiff),
"jpeg": true_false(self.options.with_libjpeg)
})

# Workaround for https://bugs.llvm.org/show_bug.cgi?id=16404
# Only really for the purposes of building on CCI - end users can
# workaround this by appropriately setting global linker flags in their profile
Expand All @@ -150,21 +147,42 @@ def generate(self):

def _patch_sources(self):
apply_conandata_patches(self)

meson_build = os.path.join(self.source_folder, "meson.build")
gdk_meson_build = os.path.join(self.source_folder, "gdk-pixbuf", "meson.build")

replace_in_file(self, meson_build, "subdir('tests')", "#subdir('tests')")
replace_in_file(self, meson_build, "subdir('thumbnailer')", "#subdir('thumbnailer')")
replace_in_file(self, meson_build,
"gmodule_dep.get_variable(pkgconfig: 'gmodule_supported')" if Version(self.version) >= "2.42.6"
else "gmodule_dep.get_pkgconfig_variable('gmodule_supported')", "'true'")
replace_in_file(self, meson_build, "gmodule_dep.get_variable(pkgconfig: 'gmodule_supported')", "'true'")
# workaround https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/203
if Version(self.version) >= "2.42.6":
replace_in_file(self, os.path.join(self.source_folder, "build-aux", "post-install.py"),
"close_fds=True", "close_fds=(sys.platform != 'win32')")
replace_in_file(self, os.path.join(self.source_folder, "build-aux", "post-install.py"),
"close_fds=True", "close_fds=(sys.platform != 'win32')")
if Version(self.version) >= "2.42.9":
replace_in_file(self, meson_build, "is_msvc_like ? 'png' : 'libpng'", "'libpng'")
replace_in_file(self, meson_build, "is_msvc_like ? 'jpeg' : 'libjpeg'", "'libjpeg'")
replace_in_file(self, meson_build, "is_msvc_like ? 'tiff' : 'libtiff-4'", "'libtiff-4'")
replace_in_file(self, meson_build, "is_msvc_like = ", "is_msvc_like = false #")
# Fix libtiff and libpng not being linked against when building statically
# Reported upstream: https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/159
replace_in_file(self, gdk_meson_build,
"dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ],",
"dependencies: loaders_deps + gdk_pixbuf_deps + [ gdkpixbuf_dep ],")
# Forcing Conan libgettext instead of system one (if OS != Linux)
if self.settings.os != "Linux":
# FIXME: unify libgettext and gettext ??
replace_in_file(self, meson_build,
"intl_dep = cc.find_library('intl', required: false)",
"intl_dep = dependency('libgettext', version: '>=0.21', required: false, method: 'pkg-config')")
if self.settings.os == "Macos" and self.options.shared:
# Workaround to avoid generating gdk-pixbuf/loaders.cache fails
# Error output:
# [167/167] Generating gdk-pixbuf/loaders.cache with a custom command (wrapped by meson to capture output)
# FAILED: gdk-pixbuf/loaders.cache
# meson.py --internal exe --capture gdk-pixbuf/loaders.cache -- xxxx/gdk-pixbuf/gdk-pixbuf-query-loaders
# --- stderr ---
# dyld[25158]: Library not loaded: /lib/libgnuintl.8.dylib
# Reason: tried: '/lib/libgnuintl.8.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/lib/libgnuintl.8.dylib' (no such file)
#
# Obviously, the libgnuintl.8.dylib is in the VirtualRunEnv, but the current env is not passed to
# the meson custom_target function as it's wrappering the execution
# custom_target admits also an "env" parameter, but it's not working as expected
replace_in_file(self, gdk_meson_build, "build_by_default: true", "build_by_default: false")

def build(self):
self._patch_sources()
Expand Down Expand Up @@ -195,10 +213,13 @@ def package_info(self):
self.cpp_info.exelinkflags = ldflags
self.cpp_info.sharedlinkflags = ldflags

# Breaking change since Conan >= 2.0.8
# Related to https://github.com/conan-io/conan/pull/14233
libdir_variable = "libdir1" if Version(conan_version) < "2.0" else "libdir"
pkgconfig_variables = {
"bindir": "${prefix}/bin",
"gdk_pixbuf_binary_version": "2.10.0",
"gdk_pixbuf_binarydir": "${libdir1}/gdk-pixbuf-2.0/2.10",
"gdk_pixbuf_binarydir": "${%s}/gdk-pixbuf-2.0/2.10" % libdir_variable,
"gdk_pixbuf_moduledir": "${gdk_pixbuf_binarydir}/loaders",
"gdk_pixbuf_cache_file": "${gdk_pixbuf_binarydir}/loaders.cache",
"gdk_pixbuf_csource": "${bindir}/gdk-pixbuf-csource",
Expand All @@ -213,6 +234,7 @@ def package_info(self):
self.runenv_info.define_path("GDK_PIXBUF_PIXDATA", gdk_pixbuf_pixdata)
self.env_info.GDK_PIXBUF_PIXDATA = gdk_pixbuf_pixdata # remove in conan v2?


def fix_msvc_libname(conanfile, remove_lib_prefix=True):
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
if not conanfile.settings.get_safe("compiler.runtime"):
Expand Down

0 comments on commit 0b3b4ba

Please sign in to comment.