From 457545a08abc11e73985176cd62c2624d71704cc Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 20 Nov 2020 12:44:38 +0100 Subject: [PATCH 1/8] gdk-pixbuf 2.42.0 this is a port of https://github.com/bincrafters/conan-gdk-pixbuf --- recipes/gdk-pixbuf/all/conandata.yml | 4 + recipes/gdk-pixbuf/all/conanfile.py | 112 ++++++++++++++++++ .../all/test_package/CMakeLists.txt | 9 ++ .../gdk-pixbuf/all/test_package/conanfile.py | 18 +++ .../all/test_package/test_package.c | 8 ++ recipes/gdk-pixbuf/config.yml | 3 + 6 files changed, 154 insertions(+) create mode 100644 recipes/gdk-pixbuf/all/conandata.yml create mode 100644 recipes/gdk-pixbuf/all/conanfile.py create mode 100644 recipes/gdk-pixbuf/all/test_package/CMakeLists.txt create mode 100644 recipes/gdk-pixbuf/all/test_package/conanfile.py create mode 100644 recipes/gdk-pixbuf/all/test_package/test_package.c create mode 100644 recipes/gdk-pixbuf/config.yml diff --git a/recipes/gdk-pixbuf/all/conandata.yml b/recipes/gdk-pixbuf/all/conandata.yml new file mode 100644 index 0000000000000..4fc8567643ab9 --- /dev/null +++ b/recipes/gdk-pixbuf/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.42.0": + url: "http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.0.tar.xz" + sha256: "73441338d1a901dc7a3940113cb0aac22776b2832f7eab8f8ec7ec5755adaec7" diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py new file mode 100644 index 0000000000000..83f61da901e51 --- /dev/null +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -0,0 +1,112 @@ +from conans import ConanFile, Meson, tools +from conans.errors import ConanInvalidConfiguration +import os +import shutil + + +class LibnameConan(ConanFile): + name = "gdk-pixbuf" + description = "toolkit for image loading and pixel buffer manipulation" + topics = ("conan", "gdk-pixbuf", "image") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://developer.gnome.org/gdk-pixbuf/" + license = "LGPL-2.1-or-later" + generators = "pkg_config" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libpng": [True, False], + "with_libtiff": [True, False], + "with_libjpeg": [True, False], + "with_jasper": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_libpng": True, + "with_libtiff": True, + "with_libjpeg": True, + "with_jasper": False, + } + + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.build_requires('meson/0.54.2') + if not tools.which('pkg-config') or self.settings.os == "Windows": + self.build_requires('pkgconf/1.7.3') + + def requirements(self): + self.requires('glib/2.67.0') + if self.options.with_libpng: + self.requires('libpng/1.6.37') + if self.options.with_libtiff: + self.requires('libtiff/4.0.9') + if self.options.with_libjpeg: + self.requires('libjpeg/9d') + if self.options.with_jasper: + self.requires('jasper/2.0.19') + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = self.name + "-" + self.version + os.rename(extracted_dir, self._source_subfolder) + tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), "subdir('tests')", "#subdir('tests')") + tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), "subdir('thumbnailer')", "#subdir('thumbnailer')") + tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"), "gmodule_dep.get_pkgconfig_variable('gmodule_supported')", "'true'") + + def _configure_meson(self): + meson = Meson(self) + defs = {} + defs['gir'] = 'false' + defs['docs'] = 'false' + defs['man'] = 'false' + defs['installed_tests'] = 'false' + defs['png'] = 'true' if self.options.with_libpng else 'false' + defs['tiff'] = 'true' if self.options.with_libtiff else 'false' + defs['jpeg'] = 'true' if self.options.with_libjpeg else 'false' + defs['jasper'] = 'true' if self.options.with_jasper else 'false' + defs['x11'] = 'false' + defs['builtin_loaders'] = 'all' + args=[] + args.append('--wrap-mode=nofallback') + meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths='.', args=args) + return meson + + def build(self): + shutil.move('libpng.pc', 'libpng16.pc') + meson = self._configure_meson() + meson.build() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append({'LD_LIBRARY_PATH': os.path.join(self.package_folder, 'lib')}): + meson = self._configure_meson() + meson.install() + if self.settings.compiler == "Visual Studio" and not self.options.shared: + os.rename(os.path.join(self.package_folder, 'lib', 'libgdk_pixbuf-2.0.a'), os.path.join(self.package_folder, 'lib', 'gdk_pixbuf-2.0.lib')) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.includedirs = ['include/gdk-pixbuf-2.0'] + self.cpp_info.names['pkg_config'] = 'gdk-pixbuf-2.0' + if not self.options.shared: + self.cpp_info.defines.append('GDK_PIXBUF_STATIC_COMPILATION') + if self.settings.os == 'Linux': + self.cpp_info.system_libs = ['m'] + self.env_info.GDK_PIXBUF_PIXDATA = os.path.join(self.package_folder, 'bin', 'gdk-pixbuf-pixdata') diff --git a/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt b/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..afa2476357074 --- /dev/null +++ b/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/gdk-pixbuf/all/test_package/conanfile.py b/recipes/gdk-pixbuf/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1afb874cf3521 --- /dev/null +++ b/recipes/gdk-pixbuf/all/test_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" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run("gdk-pixbuf-pixdata -v", run_environment=True) + self.run(bin_path, run_environment=True) diff --git a/recipes/gdk-pixbuf/all/test_package/test_package.c b/recipes/gdk-pixbuf/all/test_package/test_package.c new file mode 100644 index 0000000000000..2dd09f555d9aa --- /dev/null +++ b/recipes/gdk-pixbuf/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include +#include "gdk-pixbuf/gdk-pixbuf.h" + +int main() +{ + printf("gdk-pixbuf version %s %d.%d.%d\n", gdk_pixbuf_version, gdk_pixbuf_major_version, gdk_pixbuf_minor_version, gdk_pixbuf_micro_version); + return 0; +} diff --git a/recipes/gdk-pixbuf/config.yml b/recipes/gdk-pixbuf/config.yml new file mode 100644 index 0000000000000..8e56dcd3a0e95 --- /dev/null +++ b/recipes/gdk-pixbuf/config.yml @@ -0,0 +1,3 @@ +versions: + "2.42.0": + folder: all From be9889711979d2f79c9ac71867222f28b6280f7d Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 20 Nov 2020 15:11:54 +0100 Subject: [PATCH 2/8] remove dependency on shared-mime-info --- recipes/gdk-pixbuf/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index 83f61da901e51..25a17f94e747c 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -81,6 +81,7 @@ def _configure_meson(self): defs['jasper'] = 'true' if self.options.with_jasper else 'false' defs['x11'] = 'false' defs['builtin_loaders'] = 'all' + defs['gio_sniffing'] = 'false' args=[] args.append('--wrap-mode=nofallback') meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths='.', args=args) From 627c18471eab0d5a42f4f72db9f58714f90b07ca Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 20 Nov 2020 15:58:52 +0100 Subject: [PATCH 3/8] remove pdb files --- recipes/gdk-pixbuf/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index 25a17f94e747c..ea003bd1ddf85 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -101,6 +101,7 @@ def package(self): os.rename(os.path.join(self.package_folder, 'lib', 'libgdk_pixbuf-2.0.a'), os.path.join(self.package_folder, 'lib', 'gdk_pixbuf-2.0.lib')) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") def package_info(self): self.cpp_info.libs = tools.collect_libs(self) From 69ecfd80b8a1c7ad22a4ae9e9307407aba7d2e70 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 20 Nov 2020 15:59:04 +0100 Subject: [PATCH 4/8] disable macos --- recipes/gdk-pixbuf/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index ea003bd1ddf85..57148063cb14b 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -43,6 +43,10 @@ def configure(self): del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + 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') def build_requirements(self): self.build_requires('meson/0.54.2') From 56bbe212a5a6781ba248a3fcd1503ba417a1cbdc Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Fri, 20 Nov 2020 17:01:05 +0100 Subject: [PATCH 5/8] Update recipes/gdk-pixbuf/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/gdk-pixbuf/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index 57148063cb14b..3545bc023caf4 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -50,8 +50,7 @@ def configure(self): def build_requirements(self): self.build_requires('meson/0.54.2') - if not tools.which('pkg-config') or self.settings.os == "Windows": - self.build_requires('pkgconf/1.7.3') + self.build_requires('pkgconf/1.7.3') def requirements(self): self.requires('glib/2.67.0') From e9b32fc07ac0614e9d125e5639978b7d1f2f6515 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 20 Nov 2020 18:53:41 +0100 Subject: [PATCH 6/8] allow libjpeg-turbo too --- recipes/gdk-pixbuf/all/conanfile.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index 3545bc023caf4..44132cc75a332 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -19,7 +19,7 @@ class LibnameConan(ConanFile): "fPIC": [True, False], "with_libpng": [True, False], "with_libtiff": [True, False], - "with_libjpeg": [True, False], + "with_libjpeg": ["libjpeg", "libjpeg-turbo", False], "with_jasper": [True, False], } default_options = { @@ -27,7 +27,7 @@ class LibnameConan(ConanFile): "fPIC": True, "with_libpng": True, "with_libtiff": True, - "with_libjpeg": True, + "with_libjpeg": "libjpeg", "with_jasper": False, } @@ -58,8 +58,10 @@ def requirements(self): self.requires('libpng/1.6.37') if self.options.with_libtiff: self.requires('libtiff/4.0.9') - if self.options.with_libjpeg: - self.requires('libjpeg/9d') + if self.options.with_libjpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.0.5") + elif self.options.with_libjpeg == "libjpeg": + self.requires("libjpeg/9d") if self.options.with_jasper: self.requires('jasper/2.0.19') From 2b6912e3b362f9e7e8c288440ba6406b49d9d769 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 20 Nov 2020 18:54:11 +0100 Subject: [PATCH 7/8] test some functions --- recipes/gdk-pixbuf/all/test_package/test_package.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/recipes/gdk-pixbuf/all/test_package/test_package.c b/recipes/gdk-pixbuf/all/test_package/test_package.c index 2dd09f555d9aa..74bab77ccac41 100644 --- a/recipes/gdk-pixbuf/all/test_package/test_package.c +++ b/recipes/gdk-pixbuf/all/test_package/test_package.c @@ -3,6 +3,18 @@ int main() { + GdkPixbuf *pixbuf; printf("gdk-pixbuf version %s %d.%d.%d\n", gdk_pixbuf_version, gdk_pixbuf_major_version, gdk_pixbuf_minor_version, gdk_pixbuf_micro_version); + pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 100, 100); + + g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); + g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); + g_assert (gdk_pixbuf_get_has_alpha (pixbuf)); + g_assert (gdk_pixbuf_get_n_channels (pixbuf) == 4); + + g_assert (gdk_pixbuf_get_width (pixbuf) == 100); + g_assert (gdk_pixbuf_get_height (pixbuf) == 100); + + g_object_unref(pixbuf); return 0; } From a99ddf50fde94a4ee1d8e9f8d4651224b5a0d0be Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Sat, 21 Nov 2020 16:11:52 +0100 Subject: [PATCH 8/8] Update recipes/gdk-pixbuf/all/conanfile.py Co-authored-by: Chris Mc --- recipes/gdk-pixbuf/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index 44132cc75a332..328ab94dc7e13 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -4,6 +4,10 @@ import shutil +required_conan_version = ">=1.29.1" + + + class LibnameConan(ConanFile): name = "gdk-pixbuf" description = "toolkit for image loading and pixel buffer manipulation"