From 3e77de4ccaa5dcdee5dbbe07e2745c4f73347a04 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 14 Nov 2023 20:38:56 +0200 Subject: [PATCH 01/11] openslide: new recipe --- recipes/openslide/all/conandata.yml | 4 + recipes/openslide/all/conanfile.py | 95 +++++++++++++++++++ .../openslide/all/test_package/conanfile.py | 33 +++++++ .../openslide/all/test_package/meson.build | 5 + .../openslide/all/test_package/test_package.c | 6 ++ recipes/openslide/config.yml | 3 + 6 files changed, 146 insertions(+) create mode 100644 recipes/openslide/all/conandata.yml create mode 100644 recipes/openslide/all/conanfile.py create mode 100644 recipes/openslide/all/test_package/conanfile.py create mode 100644 recipes/openslide/all/test_package/meson.build create mode 100644 recipes/openslide/all/test_package/test_package.c create mode 100644 recipes/openslide/config.yml diff --git a/recipes/openslide/all/conandata.yml b/recipes/openslide/all/conandata.yml new file mode 100644 index 0000000000000..7296803a3fdda --- /dev/null +++ b/recipes/openslide/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "4.0.0": + url: "https://github.com/openslide/openslide/releases/download/v4.0.0/openslide-4.0.0.tar.xz" + sha256: "cc227c44316abb65fb28f1c967706eb7254f91dbfab31e9ae6a48db6cf4ae562" diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py new file mode 100644 index 0000000000000..9a293d50425c2 --- /dev/null +++ b/recipes/openslide/all/conanfile.py @@ -0,0 +1,95 @@ +import os + +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain + +required_conan_version = ">=1.53.0" + + +class OpenslideConan(ConanFile): + name = "openslide" + description = "OpenSlide is a C library for reading whole slide image files (also known as virtual slides)" + license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://openslide.org/" + topics = ("pathology", "whole-slide-imaging", "slide-image") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("cairo/1.18.0") + self.requires("gdk-pixbuf/2.42.10") + self.requires("glib/2.78.1", force=True) # FIXME + self.requires("libdicom/1.0.5") + self.requires("libjpeg/9e") + self.requires("libpng/1.6.40") + self.requires("libtiff/4.6.0") + self.requires("libxml2/2.11.5") + self.requires("openjpeg/2.5.0") + self.requires("sqlite3/3.44.0") + self.requires("zlib/[>=1.2.11 <2]") + + def build_requirements(self): + self.tool_requires("meson/1.2.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/2.0.3") + self.tool_requires("glib/") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + venv = VirtualBuildEnv(self) + venv.generate() + tc = MesonToolchain(self) + tc.project_options["test"] = "disabled" + tc.project_options["doc"] = "disabled" + tc.generate() + deps = PkgConfigDeps(self) + deps.generate() + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + meson = Meson(self) + meson.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.libs = ["openslide"] + self.cpp_info.includedirs.append(os.path.join("include", "openslide")) diff --git a/recipes/openslide/all/test_package/conanfile.py b/recipes/openslide/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8adddf3b7b73c --- /dev/null +++ b/recipes/openslide/all/test_package/conanfile.py @@ -0,0 +1,33 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + basic_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires("meson/1.2.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/2.0.3") + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/openslide/all/test_package/meson.build b/recipes/openslide/all/test_package/meson.build new file mode 100644 index 0000000000000..b22a34bfa7460 --- /dev/null +++ b/recipes/openslide/all/test_package/meson.build @@ -0,0 +1,5 @@ +project('test_package', 'c') +package_dep = dependency('openslide') +executable('test_package', + sources : ['test_package.c'], + dependencies : [package_dep]) diff --git a/recipes/openslide/all/test_package/test_package.c b/recipes/openslide/all/test_package/test_package.c new file mode 100644 index 0000000000000..c796dd4333035 --- /dev/null +++ b/recipes/openslide/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include + +int main() { + openslide_detect_vendor(""); + return 0; +} diff --git a/recipes/openslide/config.yml b/recipes/openslide/config.yml new file mode 100644 index 0000000000000..d2be8f453d7c0 --- /dev/null +++ b/recipes/openslide/config.yml @@ -0,0 +1,3 @@ +versions: + "4.0.0": + folder: all From cc6051c13ad0fdf08014a434a1b04e29c5807c7e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 14 Nov 2023 21:54:58 +0200 Subject: [PATCH 02/11] openslide: fix license copying --- recipes/openslide/all/conanfile.py | 4 ++-- recipes/openslide/all/test_package/conanfile.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index 9a293d50425c2..6be83b686d090 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -11,7 +11,7 @@ required_conan_version = ">=1.53.0" -class OpenslideConan(ConanFile): +class OpenSlideConan(ConanFile): name = "openslide" description = "OpenSlide is a C library for reading whole slide image files (also known as virtual slides)" license = "LGPL-2.1" @@ -81,7 +81,7 @@ def build(self): meson.build() def package(self): - copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING.LESSER", self.source_folder, os.path.join(self.package_folder, "licenses")) meson = Meson(self) meson.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) diff --git a/recipes/openslide/all/test_package/conanfile.py b/recipes/openslide/all/test_package/conanfile.py index 8adddf3b7b73c..2e3df45816e5a 100644 --- a/recipes/openslide/all/test_package/conanfile.py +++ b/recipes/openslide/all/test_package/conanfile.py @@ -5,7 +5,6 @@ import os -# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" From 569cfb24efc6765e69e920236a1b6c76408c5e07 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 15 Nov 2023 12:55:13 +0200 Subject: [PATCH 03/11] openslide: improve topics --- recipes/openslide/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index 6be83b686d090..d7b04f49e102c 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -17,7 +17,9 @@ class OpenSlideConan(ConanFile): license = "LGPL-2.1" url = "https://github.com/conan-io/conan-center-index" homepage = "https://openslide.org/" - topics = ("pathology", "whole-slide-imaging", "slide-image") + topics = ("image", "pathology", "whole-slide-imaging", "slide-image", + # supported formats + "bif", "dicom", "dcm", "mrxs", "ndpi", "scn", "svs", "svslide", "tiff", "vms", "vmu") package_type = "library" settings = "os", "arch", "compiler", "build_type" From 26622f8121da90e195bd72f621161eb005bbcd9e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 15 Nov 2023 13:00:10 +0200 Subject: [PATCH 04/11] openslide: disable for MSVC --- recipes/openslide/all/conanfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index d7b04f49e102c..acc8ace3603a6 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -1,12 +1,14 @@ import os from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.apple import fix_apple_shared_install_name from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get, rm, rmdir from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain +from conan.tools.microsoft import is_msvc required_conan_version = ">=1.53.0" @@ -58,6 +60,10 @@ def requirements(self): self.requires("sqlite3/3.44.0") self.requires("zlib/[>=1.2.11 <2]") + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"OpenSlide requires GNU C++ extensions support and is not compatible with MSVC") + def build_requirements(self): self.tool_requires("meson/1.2.3") if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): From 532e419b5e997638e997df81d925c5fba9dc4669 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 15 Nov 2023 13:03:30 +0200 Subject: [PATCH 05/11] openslide: improve test_package.c Based on #19592. --- recipes/openslide/all/conanfile.py | 2 +- recipes/openslide/all/test_package/test_package.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index acc8ace3603a6..011333a5f07f1 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -54,7 +54,7 @@ def requirements(self): self.requires("libdicom/1.0.5") self.requires("libjpeg/9e") self.requires("libpng/1.6.40") - self.requires("libtiff/4.6.0") + self.requires("libtiff/4.6.0", force=True) # FIXME self.requires("libxml2/2.11.5") self.requires("openjpeg/2.5.0") self.requires("sqlite3/3.44.0") diff --git a/recipes/openslide/all/test_package/test_package.c b/recipes/openslide/all/test_package/test_package.c index c796dd4333035..ea806b718030d 100644 --- a/recipes/openslide/all/test_package/test_package.c +++ b/recipes/openslide/all/test_package/test_package.c @@ -1,6 +1,7 @@ #include +#include int main() { - openslide_detect_vendor(""); + printf("OpenSlide version: %s\n", openslide_get_version()); return 0; } From 74104cc7050a26dd43a0481cc19c825c39bbd6f2 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 15 Nov 2023 13:11:51 +0200 Subject: [PATCH 06/11] openslide: add support for libjpeg-turbo, set cpp_info.requires --- recipes/openslide/all/conanfile.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index 011333a5f07f1..1f795d11d059d 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -28,10 +28,12 @@ class OpenSlideConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "jpeg": ["libjpeg", "libjpeg-turbo", "mozjpeg"], } default_options = { "shared": False, "fPIC": True, + "jpeg": "libjpeg", } def config_options(self): @@ -52,13 +54,18 @@ def requirements(self): self.requires("gdk-pixbuf/2.42.10") self.requires("glib/2.78.1", force=True) # FIXME self.requires("libdicom/1.0.5") - self.requires("libjpeg/9e") self.requires("libpng/1.6.40") self.requires("libtiff/4.6.0", force=True) # FIXME self.requires("libxml2/2.11.5") self.requires("openjpeg/2.5.0") self.requires("sqlite3/3.44.0") self.requires("zlib/[>=1.2.11 <2]") + if self.options.jpeg == "libjpeg": + self.requires("libjpeg/9e") + elif self.options.jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/3.0.1") + elif self.options.jpeg == "mozjpeg": + self.requires("mozjpeg/4.1.3") def validate(self): if is_msvc(self): @@ -101,3 +108,24 @@ def package(self): def package_info(self): self.cpp_info.libs = ["openslide"] self.cpp_info.includedirs.append(os.path.join("include", "openslide")) + + self.cpp_info.requires = [ + "cairo::cairo_", + "gdk-pixbuf::gdk-pixbuf", + "glib::gio-2.0", + "glib::glib-2.0", + "glib::gobject-2.0", + "libdicom::libdicom", + "libpng::libpng", + "libtiff::libtiff", + "libxml2::libxml2", + "openjpeg::openjpeg", + "sqlite3::sqlite3", + "zlib::zlib", + ] + if self.options.jpeg == "libjpeg": + self.cpp_info.requires.append("libjpeg::libjpeg") + elif self.options.jpeg == "libjpeg-turbo": + self.cpp_info.requires.append("libjpeg-turbo::jpeg") + elif self.options.jpeg == "mozjpeg": + self.cpp_info.requires.append("mozjpeg::libjpeg") From 15ceab40fd86f2985e64302a9128c1101c1b7877 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 15 Nov 2023 14:12:22 +0200 Subject: [PATCH 07/11] openslide: fix typo --- recipes/openslide/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index 1f795d11d059d..8f0c5ce5aeb18 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -69,7 +69,7 @@ def requirements(self): def validate(self): if is_msvc(self): - raise ConanInvalidConfiguration(f"OpenSlide requires GNU C++ extensions support and is not compatible with MSVC") + raise ConanInvalidConfiguration("OpenSlide requires GNU C extensions support and is not compatible with MSVC") def build_requirements(self): self.tool_requires("meson/1.2.3") From e08bfec112072dabba44543c17c1b407ff4bfa2d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 31 Mar 2024 12:31:14 +0300 Subject: [PATCH 08/11] openslide: drop force=True, bump deps --- recipes/openslide/all/conanfile.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index 8f0c5ce5aeb18..edae9882b9dad 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -52,29 +52,29 @@ def layout(self): def requirements(self): self.requires("cairo/1.18.0") self.requires("gdk-pixbuf/2.42.10") - self.requires("glib/2.78.1", force=True) # FIXME + self.requires("glib/2.78.3") self.requires("libdicom/1.0.5") - self.requires("libpng/1.6.40") - self.requires("libtiff/4.6.0", force=True) # FIXME - self.requires("libxml2/2.11.5") - self.requires("openjpeg/2.5.0") - self.requires("sqlite3/3.44.0") + self.requires("libpng/[>=1.6 <2]") + self.requires("libtiff/4.6.0") + self.requires("libxml2/[>=2.12.5 <3]") + self.requires("openjpeg/2.5.2") + self.requires("sqlite3/3.45.3") self.requires("zlib/[>=1.2.11 <2]") if self.options.jpeg == "libjpeg": self.requires("libjpeg/9e") elif self.options.jpeg == "libjpeg-turbo": - self.requires("libjpeg-turbo/3.0.1") + self.requires("libjpeg-turbo/3.0.2") elif self.options.jpeg == "mozjpeg": - self.requires("mozjpeg/4.1.3") + self.requires("mozjpeg/4.1.5") def validate(self): if is_msvc(self): raise ConanInvalidConfiguration("OpenSlide requires GNU C extensions support and is not compatible with MSVC") def build_requirements(self): - self.tool_requires("meson/1.2.3") + self.tool_requires("meson/1.4.0") if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): - self.tool_requires("pkgconf/2.0.3") + self.tool_requires("pkgconf/2.2.0") self.tool_requires("glib/") def source(self): From c45a37628368f1669d8d86e288504927bc10433e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 2 Aug 2024 14:59:17 +0300 Subject: [PATCH 09/11] openslide: backport a build bugfix --- recipes/openslide/all/conandata.yml | 6 + recipes/openslide/all/conanfile.py | 6 +- .../patches/0001-no-openslide-poison.patch | 308 ++++++++++++++++++ 3 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 recipes/openslide/all/patches/0001-no-openslide-poison.patch diff --git a/recipes/openslide/all/conandata.yml b/recipes/openslide/all/conandata.yml index 7296803a3fdda..ca29cdf478653 100644 --- a/recipes/openslide/all/conandata.yml +++ b/recipes/openslide/all/conandata.yml @@ -2,3 +2,9 @@ sources: "4.0.0": url: "https://github.com/openslide/openslide/releases/download/v4.0.0/openslide-4.0.0.tar.xz" sha256: "cc227c44316abb65fb28f1c967706eb7254f91dbfab31e9ae6a48db6cf4ae562" +patches: + "4.0.0": + - patch_file: "patches/0001-no-openslide-poison.patch" + patch_description: "Fix 'error__use__openslide_fclose_instead' compilation error" + patch_type: "backport" + patch_source: "https://github.com/openslide/openslide/commit/048865a3b61e9bc2b61219168d434b61e784d355" diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index edae9882b9dad..eceef565d2cc2 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -4,7 +4,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.apple import fix_apple_shared_install_name from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, get, rm, rmdir +from conan.tools.files import copy, get, rm, rmdir, export_conandata_patches, apply_conandata_patches from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain @@ -36,6 +36,9 @@ class OpenSlideConan(ConanFile): "jpeg": "libjpeg", } + def export_sources(self): + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -91,6 +94,7 @@ def generate(self): deps.generate() def build(self): + apply_conandata_patches(self) meson = Meson(self) meson.configure() meson.build() diff --git a/recipes/openslide/all/patches/0001-no-openslide-poison.patch b/recipes/openslide/all/patches/0001-no-openslide-poison.patch new file mode 100644 index 0000000000000..00a38642d6421 --- /dev/null +++ b/recipes/openslide/all/patches/0001-no-openslide-poison.patch @@ -0,0 +1,308 @@ +From 048865a3b61e9bc2b61219168d434b61e784d355 Mon Sep 17 00:00:00 2001 +From: Benjamin Gilbert +Date: Mon, 12 Feb 2024 20:44:45 +0900 +Subject: [PATCH] Replace _OPENSLIDE_POISON() with pre-commit check + +Preprocessor macros are somewhat clunky as a way to prevent use of +forbidden functions. Now that we have pre-commit checks, use those +instead. Allow forbidden function calls in wrapper implementations by +ignoring call sites with "ci-allow" in a comment on the same line. + +Signed-off-by: Benjamin Gilbert +--- + .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ + src/openslide-decode-sqlite.c | 10 +++------- + src/openslide-decode-tiff.c | 8 ++------ + src/openslide-file.c | 20 +++++++------------- + src/openslide-jdatasrc.c | 2 +- + src/openslide-private.h | 27 --------------------------- + src/openslide-util.c | 4 +--- + src/openslide-vendor-synthetic.c | 7 +++---- + 8 files changed, 46 insertions(+), 61 deletions(-) + +diff --git a/src/openslide-decode-sqlite.c b/src/openslide-decode-sqlite.c +index f75083df5..119b71b5a 100644 +--- a/src/openslide-decode-sqlite.c ++++ b/src/openslide-decode-sqlite.c +@@ -44,7 +44,6 @@ static int profile_callback(unsigned trace_type G_GNUC_UNUSED, + return 0; + } + +-#undef sqlite3_open_v2 + static sqlite3 *do_open(const char *filename, int flags, GError **err) { + sqlite3 *db; + +@@ -55,7 +54,7 @@ static sqlite3 *do_open(const char *filename, int flags, GError **err) { + return NULL; + } + +- ret = sqlite3_open_v2(filename, &db, flags, NULL); ++ ret = sqlite3_open_v2(filename, &db, flags, NULL); // ci-allow + + if (ret) { + if (db) { +@@ -76,7 +75,6 @@ static sqlite3 *do_open(const char *filename, int flags, GError **err) { + + return db; + } +-#define sqlite3_open_v2 _OPENSLIDE_POISON(_openslide_sqlite_open) + + sqlite3 *_openslide_sqlite_open(const char *filename, GError **err) { + // ":" filename prefix is reserved. +@@ -131,12 +129,10 @@ void _openslide_sqlite_propagate_stmt_error(sqlite3_stmt *stmt, GError **err) { + _openslide_sqlite_propagate_error(sqlite3_db_handle(stmt), err); + } + +-#undef sqlite3_close + void _openslide_sqlite_close(sqlite3 *db) { +- // sqlite3_close() failures indicate a leaked resource, probably a ++ // sqlite3_close failures indicate a leaked resource, probably a + // prepared statement. +- if (sqlite3_close(db)) { ++ if (sqlite3_close(db)) { // ci-allow + g_warning("SQLite error: %s", sqlite3_errmsg(db)); + } + } +-#define sqlite3_close _OPENSLIDE_POISON(_openslide_sqlite_close) +diff --git a/src/openslide-decode-tiff.c b/src/openslide-decode-tiff.c +index 0af196479..ed294f18f 100644 +--- a/src/openslide-decode-tiff.c ++++ b/src/openslide-decode-tiff.c +@@ -74,7 +74,6 @@ struct associated_image { + result = tmp; \ + } while (0) + +-#undef TIFFSetDirectory + bool _openslide_tiff_set_dir(TIFF *tiff, + tdir_t dir, + GError **err) { +@@ -82,14 +81,13 @@ bool _openslide_tiff_set_dir(TIFF *tiff, + // avoid libtiff unnecessarily rereading directory contents + return true; + } +- if (!TIFFSetDirectory(tiff, dir)) { ++ if (!TIFFSetDirectory(tiff, dir)) { // ci-allow + g_set_error(err, OPENSLIDE_ERROR, OPENSLIDE_ERROR_FAILED, + "Cannot set TIFF directory %d", dir); + return false; + } + return true; + } +-#define TIFFSetDirectory _OPENSLIDE_POISON(_openslide_tiff_set_dir) + + bool _openslide_tiff_level_init(TIFF *tiff, + tdir_t dir, +@@ -587,7 +585,6 @@ static toff_t tiff_do_size(thandle_t th) { + return hdl->size; + } + +-#undef TIFFClientOpen + static TIFF *tiff_open(struct _openslide_tiffcache *tc, GError **err) { + // open + g_autoptr(_openslide_file) f = _openslide_fopen(tc->filename, err); +@@ -646,7 +643,7 @@ static TIFF *tiff_open(struct _openslide_tiffcache *tc, GError **err) { + + // TIFFOpen + // mode: m disables mmap to avoid sigbus and other mmap fragility +- TIFF *tiff = TIFFClientOpen(tc->filename, "rm", hdl, ++ TIFF *tiff = TIFFClientOpen(tc->filename, "rm", hdl, // ci-allow + tiff_do_read, tiff_do_write, tiff_do_seek, + tiff_do_close, tiff_do_size, NULL, NULL); + if (tiff == NULL) { +@@ -656,7 +653,6 @@ static TIFF *tiff_open(struct _openslide_tiffcache *tc, GError **err) { + } + return tiff; + } +-#define TIFFClientOpen _OPENSLIDE_POISON(_openslide_tiffcache_get) + + struct _openslide_tiffcache *_openslide_tiffcache_create(const char *filename) { + struct _openslide_tiffcache *tc = g_new0(struct _openslide_tiffcache, 1); +diff --git a/src/openslide-file.c b/src/openslide-file.c +index 2763f3807..9eb9b1039 100644 +--- a/src/openslide-file.c ++++ b/src/openslide-file.c +@@ -22,7 +22,6 @@ + + #include + +-#define NO_POISON_FSEEKO + #include "openslide-private.h" + + #include +@@ -44,13 +43,8 @@ struct _openslide_dir { + GDir *dir; + }; + +-#undef fopen +-#undef fread +-#undef fclose +-#undef g_file_test +- + static void wrap_fclose(FILE *fp) { +- fclose(fp); ++ fclose(fp); // ci-allow + } + G_DEFINE_AUTOPTR_CLEANUP_FUNC(FILE, wrap_fclose) + +@@ -87,7 +81,7 @@ static FILE *do_fopen(const char *path, const char *mode, GError **err) { + io_error(err, "Couldn't open %s", path); + } + #else +- f = fopen(path, mode); ++ f = fopen(path, mode); // ci-allow + if (f == NULL) { + io_error(err, "Couldn't open %s", path); + } +@@ -132,7 +126,7 @@ size_t _openslide_fread(struct _openslide_file *file, void *buf, size_t size) { + char *bufp = buf; + size_t total = 0; + while (total < size) { +- size_t count = fread(bufp + total, 1, size - total, file->fp); ++ size_t count = fread(bufp + total, 1, size - total, file->fp); // ci-allow + if (count == 0) { + return total; + } +@@ -143,7 +137,7 @@ size_t _openslide_fread(struct _openslide_file *file, void *buf, size_t size) { + + bool _openslide_fseek(struct _openslide_file *file, off_t offset, int whence, + GError **err) { +- if (fseeko(file->fp, offset, whence)) { ++ if (fseeko(file->fp, offset, whence)) { // ci-allow + g_set_error(err, G_FILE_ERROR, g_file_error_from_errno(errno), + "%s", g_strerror(errno)); + return false; +@@ -152,7 +146,7 @@ bool _openslide_fseek(struct _openslide_file *file, off_t offset, int whence, + } + + off_t _openslide_ftell(struct _openslide_file *file, GError **err) { +- off_t ret = ftello(file->fp); ++ off_t ret = ftello(file->fp); // ci-allow + if (ret == -1) { + g_set_error(err, G_FILE_ERROR, g_file_error_from_errno(errno), + "%s", g_strerror(errno)); +@@ -179,12 +173,12 @@ off_t _openslide_fsize(struct _openslide_file *file, GError **err) { + } + + void _openslide_fclose(struct _openslide_file *file) { +- fclose(file->fp); ++ fclose(file->fp); // ci-allow + g_free(file); + } + + bool _openslide_fexists(const char *path, GError **err G_GNUC_UNUSED) { +- return g_file_test(path, G_FILE_TEST_EXISTS); ++ return g_file_test(path, G_FILE_TEST_EXISTS); // ci-allow + } + + struct _openslide_dir *_openslide_dir_open(const char *dirname, GError **err) { +diff --git a/src/openslide-jdatasrc.c b/src/openslide-jdatasrc.c +index 2ad068818..4de54eddf 100644 +--- a/src/openslide-jdatasrc.c ++++ b/src/openslide-jdatasrc.c +@@ -158,7 +158,7 @@ static void skip_input_data (j_decompress_ptr cinfo, long num_bytes) + { + struct jpeg_source_mgr * src = cinfo->src; + +- /* Just a dumb implementation for now. Could use fseek() except ++ /* Just a dumb implementation for now. Could use fseek except + * it doesn't work on pipes. Not clear that being smart is worth + * any trouble anyway --- large skips are infrequent. + */ +diff --git a/src/openslide-private.h b/src/openslide-private.h +index 5ae36939b..ed08f5ed7 100644 +--- a/src/openslide-private.h ++++ b/src/openslide-private.h +@@ -383,33 +383,6 @@ extern const int32_t _openslide_G_Cb[256]; + extern const int32_t _openslide_G_Cr[256]; + extern const int16_t _openslide_B_Cb[256]; + +-/* Prevent use of dangerous functions and functions with mandatory wrappers. +- Every @p replacement must be unique to avoid conflicting-type errors. */ +-#define _OPENSLIDE_POISON(replacement) error__use_ ## replacement ## _instead +-#define fopen _OPENSLIDE_POISON(_openslide_fopen) +-#define fread _OPENSLIDE_POISON(_openslide_fread) +-#define fseek _OPENSLIDE_POISON(_openslide_fseek) +-#define ftell _OPENSLIDE_POISON(_openslide_ftell) +-#define fclose _OPENSLIDE_POISON(_openslide_fclose) +-#define g_file_test _OPENSLIDE_POISON(_openslide_fexists) +-#define strtod _OPENSLIDE_POISON(_openslide_parse_double) +-#define g_ascii_strtod _OPENSLIDE_POISON(_openslide_parse_double_) +-#define sqlite3_open _OPENSLIDE_POISON(_openslide_sqlite_open) +-#define sqlite3_open_v2 _OPENSLIDE_POISON(_openslide_sqlite_open_) +-#define sqlite3_close _OPENSLIDE_POISON(_openslide_sqlite_close) +-#define TIFFClientOpen _OPENSLIDE_POISON(_openslide_tiffcache_get) +-#define TIFFFdOpen _OPENSLIDE_POISON(_openslide_tiffcache_get_) +-#define TIFFOpen _OPENSLIDE_POISON(_openslide_tiffcache_get__) +-#define TIFFSetDirectory _OPENSLIDE_POISON(_openslide_tiff_set_dir) +- +-#ifndef NO_POISON_FSEEKO +-// openslide-file.c needs the original macros +-#undef fseeko +-#undef ftello +-#define fseeko _OPENSLIDE_POISON(_openslide_fseek_) +-#define ftello _OPENSLIDE_POISON(_openslide_ftell_) +-#endif +- + #ifdef _WIN32 + // Prevent windows.h from defining the IN/OUT macro + #define _NO_W32_PSEUDO_MODIFIERS +diff --git a/src/openslide-util.c b/src/openslide-util.c +index 719953274..b85f9afa3 100644 +--- a/src/openslide-util.c ++++ b/src/openslide-util.c +@@ -170,7 +170,6 @@ void *_openslide_inflate_buffer(const void *src, int64_t src_len, + return g_steal_pointer(&dst); + } + +-#undef g_ascii_strtod + double _openslide_parse_double(const char *value) { + // Canonicalize comma to decimal point, since the locale of the + // originating system sometimes leaks into slide files. +@@ -180,14 +179,13 @@ double _openslide_parse_double(const char *value) { + + char *endptr; + errno = 0; +- double result = g_ascii_strtod(canonical, &endptr); ++ double result = g_ascii_strtod(canonical, &endptr); // ci-allow + // fail on overflow/underflow + if (canonical[0] == 0 || endptr[0] != 0 || errno == ERANGE) { + return NAN; + } + return result; + } +-#define g_ascii_strtod _OPENSLIDE_POISON(_openslide_parse_double) + + char *_openslide_format_double(double d) { + char buf[G_ASCII_DTOSTR_BUF_SIZE]; +diff --git a/src/openslide-vendor-synthetic.c b/src/openslide-vendor-synthetic.c +index e3a440569..79938a597 100644 +--- a/src/openslide-vendor-synthetic.c ++++ b/src/openslide-vendor-synthetic.c +@@ -204,7 +204,6 @@ static toff_t mem_tiff_size(thandle_t th) { + return mem->size; + } + +-#undef TIFFClientOpen + static bool decode_tiff(const void *data, uint32_t len, + uint32_t *dest, GError **err) { + // there's no reason for OpenSlide as a whole to support reading entire +@@ -216,8 +215,9 @@ static bool decode_tiff(const void *data, uint32_t len, + }; + // mode: m disables mmap to avoid sigbus and other mmap fragility + g_autoptr(TIFF) tiff = +- TIFFClientOpen("tiff", "rm", &mem, mem_tiff_read, mem_tiff_write, +- mem_tiff_seek, mem_tiff_close, mem_tiff_size, NULL, NULL); ++ TIFFClientOpen("tiff", "rm", &mem, mem_tiff_read, // ci-allow ++ mem_tiff_write, mem_tiff_seek, mem_tiff_close, ++ mem_tiff_size, NULL, NULL); + if (tiff == NULL) { + g_set_error(err, OPENSLIDE_ERROR, OPENSLIDE_ERROR_FAILED, + "Couldn't open TIFF"); +@@ -238,7 +238,6 @@ static bool decode_tiff(const void *data, uint32_t len, + + return _openslide_tiff_read_tile(&tiffl, tiff, dest, 0, 0, err); + } +-#define TIFFClientOpen _OPENSLIDE_POISON(_openslide_tiffcache_get) + + static bool decode_xml(const void *data, uint32_t len, + uint32_t *dest, GError **err) { From 16870ab68601c8dece83306a6f55ecec4abd4ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Wed, 21 Aug 2024 00:12:31 +0200 Subject: [PATCH 10/11] Bump more version ranges --- recipes/openslide/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index eceef565d2cc2..cf1d368c34e2c 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -75,9 +75,9 @@ def validate(self): raise ConanInvalidConfiguration("OpenSlide requires GNU C extensions support and is not compatible with MSVC") def build_requirements(self): - self.tool_requires("meson/1.4.0") + self.tool_requires("meson/[>=1.2.3 <2]") if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): - self.tool_requires("pkgconf/2.2.0") + self.tool_requires("pkgconf/[>=2.2 <3]") self.tool_requires("glib/") def source(self): From 584ebdf0835616d9c78fee8499bc6f1f5d644e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Wed, 21 Aug 2024 00:16:14 +0200 Subject: [PATCH 11/11] Add coretext usage --- recipes/openslide/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/openslide/all/conanfile.py b/recipes/openslide/all/conanfile.py index cf1d368c34e2c..0557d9913ef70 100644 --- a/recipes/openslide/all/conanfile.py +++ b/recipes/openslide/all/conanfile.py @@ -113,6 +113,9 @@ def package_info(self): self.cpp_info.libs = ["openslide"] self.cpp_info.includedirs.append(os.path.join("include", "openslide")) + if self.settings.os == "Macos": + self.cpp_info.frameworks = ["CoreText"] + self.cpp_info.requires = [ "cairo::cairo_", "gdk-pixbuf::gdk-pixbuf",