Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openslide: new recipe #21138

Merged
merged 13 commits into from
Sep 9, 2024
10 changes: 10 additions & 0 deletions recipes/openslide/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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"

Check warning on line 9 in recipes/openslide/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. found arbitrary text in patch_type: backport ^ (line: 9)
patch_source: "https://github.com/openslide/openslide/commit/048865a3b61e9bc2b61219168d434b61e784d355"
138 changes: 138 additions & 0 deletions recipes/openslide/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
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, 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
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.53.0"
valgur marked this conversation as resolved.
Show resolved Hide resolved


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 = ("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"
options = {
"shared": [True, False],
"fPIC": [True, False],
"jpeg": ["libjpeg", "libjpeg-turbo", "mozjpeg"],
}
default_options = {
"shared": False,
"fPIC": True,
"jpeg": "libjpeg",
}

def export_sources(self):
export_conandata_patches(self)

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.3")
self.requires("libdicom/1.0.5")
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.2")
elif self.options.jpeg == "mozjpeg":
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 <2]")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/[>=2.2 <3]")
self.tool_requires("glib/<host_version>")

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):
apply_conandata_patches(self)
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
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"))
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"))

if self.settings.os == "Macos":
self.cpp_info.frameworks = ["CoreText"]

self.cpp_info.requires = [
"cairo::cairo_",
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
"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")
Loading
Loading