diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/openslide | |
Diffstat (limited to 'vcpkg/ports/openslide')
| -rw-r--r-- | vcpkg/ports/openslide/cross-build.diff | 32 | ||||
| -rw-r--r-- | vcpkg/ports/openslide/fix-win-build.patch | 248 | ||||
| -rw-r--r-- | vcpkg/ports/openslide/portfile.cmake | 52 | ||||
| -rw-r--r-- | vcpkg/ports/openslide/slidetool-unicode.patch | 33 | ||||
| -rw-r--r-- | vcpkg/ports/openslide/vcpkg.json | 51 | ||||
| -rw-r--r-- | vcpkg/ports/openslide/windows-dll-name.patch | 27 |
6 files changed, 443 insertions, 0 deletions
diff --git a/vcpkg/ports/openslide/cross-build.diff b/vcpkg/ports/openslide/cross-build.diff new file mode 100644 index 0000000..7adf018 --- /dev/null +++ b/vcpkg/ports/openslide/cross-build.diff @@ -0,0 +1,32 @@ +diff --git a/meson.build b/meson.build +index 0b4d7d4..de8773c 100644 +--- a/meson.build ++++ b/meson.build +@@ -45,7 +45,7 @@ versions = { + + # Compiler flags + cc = meson.get_compiler('c') +-cc_native = meson.get_compiler('c', native : true) ++cc_native = meson.get_compiler('c') + add_project_arguments( + cc.get_supported_arguments( + '-Wstrict-prototypes', +diff --git a/src/meson.build b/src/meson.build +index e886eea..97309e5 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -1,3 +1,6 @@ ++if meson.is_cross_build() ++ openslide_tables_c = [ '../openslide-tables.c' ] ++else + # generate openslide-tables.c + make_tables = executable( + 'make-tables', 'make-tables.c', +@@ -9,6 +12,7 @@ openslide_tables_c = custom_target( + output : 'openslide-tables.c', + command : [make_tables, '@OUTPUT@'], + ) ++endif + + # Windows resources + openslide_dll_manifest = configure_file( diff --git a/vcpkg/ports/openslide/fix-win-build.patch b/vcpkg/ports/openslide/fix-win-build.patch new file mode 100644 index 0000000..3fc1ed8 --- /dev/null +++ b/vcpkg/ports/openslide/fix-win-build.patch @@ -0,0 +1,248 @@ +diff --git a/common/openslide-common-fd.c b/common/openslide-common-fd.c +index 3d3ce955f3c1..20127ce4bdd9 100644 +--- a/common/openslide-common-fd.c ++++ b/common/openslide-common-fd.c +@@ -27,10 +27,13 @@ + + #include <sys/types.h> + #include <sys/stat.h> +-#include <unistd.h> + #include <fcntl.h> + #include <glib.h> + ++#ifndef _WIN32 ++#include <unistd.h> ++#endif ++ + #ifdef __APPLE__ + #include <sys/param.h> // MAXPATHLEN + #include <libproc.h> +diff --git a/meson.build b/meson.build +index 0b4d7d47b695..ac106fb1001f 100644 +--- a/meson.build ++++ b/meson.build +@@ -59,6 +59,17 @@ add_project_arguments( + '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_MIN_REQUIRED', + language : 'c' + ) ++if host_machine.system() == 'windows' ++ # Windows likes to warn about C and POSIX functions ++ foreach native : [false, true] ++ add_project_arguments( ++ '-D_CRT_NONSTDC_NO_DEPRECATE', ++ '-D_CRT_SECURE_NO_WARNINGS', ++ language : 'c', ++ native : native, ++ ) ++ endforeach ++endif + add_project_link_arguments( + cc.get_supported_link_arguments( + '-Wl,--no-undefined', +@@ -66,6 +77,13 @@ add_project_link_arguments( + language : 'c' + ) + ++# Functions ++foreach f : ['fseeko', 'ftello'] ++ if cc.has_function(f) ++ conf.set('HAVE_' + f.to_upper(), 1) ++ endif ++endforeach ++ + # fopen cloexec flag + if host_machine.system() in ['dragonfly', 'freebsd', 'linux', 'netbsd', 'openbsd'] + message('Using "e" flag for close-on-exec') +diff --git a/src/meson.build b/src/meson.build +index e886eea4b5c4..4be22f64aef7 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -24,6 +24,8 @@ openslide_dll_rc = configure_file( + if host_machine.system() == 'windows' + openslide_dll_o = import('windows').compile_resources( + openslide_dll_rc, ++ # https://github.com/llvm/llvm-project/issues/63426 ++ args : [cc.get_argument_syntax() == 'msvc' ? '/c' : '-c', '65001'], + depend_files : [openslide_dll_manifest], + ) + else +diff --git a/src/openslide-decode-dicom.c b/src/openslide-decode-dicom.c +index 24dcfbfe4568..d5fa053e94ef 100644 +--- a/src/openslide-decode-dicom.c ++++ b/src/openslide-decode-dicom.c +@@ -88,7 +88,7 @@ static int64_t vfs_seek(DcmError **dcm_error, DcmIO *io, + + // libdicom uses lseek(2) semantics, so it must always return the new file + // pointer +- off_t new_position = _openslide_ftell(dio->file, &err); ++ int64_t new_position = _openslide_ftell(dio->file, &err); + if (new_position < 0) { + propagate_gerror(dcm_error, err); + } +diff --git a/src/openslide-decode-tifflike.c b/src/openslide-decode-tifflike.c +index 626cd4039110..3ca3e374f208 100644 +--- a/src/openslide-decode-tifflike.c ++++ b/src/openslide-decode-tifflike.c +@@ -470,8 +470,9 @@ static struct tiff_directory *read_directory(struct _openslide_file *f, + return NULL; + } + +- // check for overflow +- if (count > SSIZE_MAX / value_size) { ++ // compute total size ++ size_t value_len; ++ if (!g_size_checked_mul(&value_len, value_size, count)) { + g_set_error(err, OPENSLIDE_ERROR, OPENSLIDE_ERROR_FAILED, + "Value count too large"); + return NULL; +@@ -486,7 +487,7 @@ static struct tiff_directory *read_directory(struct _openslide_file *f, + } + + // does value/offset contain the value? +- if (value_size * count <= sizeof(value)) { ++ if (value_len <= sizeof(value)) { + // yes + fix_byte_order(value, value_size, count, big_endian); + if (!set_item_values(item, value, err)) { +diff --git a/src/openslide-dll.rc.in b/src/openslide-dll.rc.in +index 0670ee539e02..47e4d729e2bd 100644 +--- a/src/openslide-dll.rc.in ++++ b/src/openslide-dll.rc.in +@@ -10,16 +10,16 @@ FILETYPE VFT_DLL + BEGIN + BLOCK "StringFileInfo" + BEGIN +- BLOCK "040904e4" ++ BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "OpenSlide library" + VALUE "FileVersion", "@SUFFIXED_VERSION@" + VALUE "InternalName", "OpenSlide" +- VALUE "LegalCopyright", "Copyright \251 2007-2023 Carnegie Mellon University and others. OpenSlide is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1." ++ VALUE "LegalCopyright", "Copyright © 2007-2023 Carnegie Mellon University and others. OpenSlide is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1." + END + END + BLOCK "VarFileInfo" + BEGIN +- VALUE "Translation", 0x0409, 0x04e4 ++ VALUE "Translation", 0x0409, 0x04b0 + END + END +diff --git a/src/openslide-file.c b/src/openslide-file.c +index 2763f38071dc..11b568913cfe 100644 +--- a/src/openslide-file.c ++++ b/src/openslide-file.c +@@ -36,6 +36,13 @@ + #include <fcntl.h> + #endif + ++#if !defined(HAVE_FSEEKO) && defined(_WIN32) ++#define fseeko _fseeki64 ++#endif ++#if !defined(HAVE_FTELLO) && defined(_WIN32) ++#define ftello _ftelli64 ++#endif ++ + struct _openslide_file { + FILE *fp; + }; +@@ -141,7 +148,7 @@ size_t _openslide_fread(struct _openslide_file *file, void *buf, size_t size) { + return total; + } + +-bool _openslide_fseek(struct _openslide_file *file, off_t offset, int whence, ++bool _openslide_fseek(struct _openslide_file *file, int64_t offset, int whence, + GError **err) { + if (fseeko(file->fp, offset, whence)) { + g_set_error(err, G_FILE_ERROR, g_file_error_from_errno(errno), +@@ -151,8 +158,8 @@ bool _openslide_fseek(struct _openslide_file *file, off_t offset, int whence, + return true; + } + +-off_t _openslide_ftell(struct _openslide_file *file, GError **err) { +- off_t ret = ftello(file->fp); ++int64_t _openslide_ftell(struct _openslide_file *file, GError **err) { ++ int64_t ret = ftello(file->fp); + if (ret == -1) { + g_set_error(err, G_FILE_ERROR, g_file_error_from_errno(errno), + "%s", g_strerror(errno)); +@@ -160,15 +167,15 @@ off_t _openslide_ftell(struct _openslide_file *file, GError **err) { + return ret; + } + +-off_t _openslide_fsize(struct _openslide_file *file, GError **err) { +- off_t orig = _openslide_ftell(file, err); ++int64_t _openslide_fsize(struct _openslide_file *file, GError **err) { ++ int64_t orig = _openslide_ftell(file, err); + if (orig == -1) { + return -1; + } + if (!_openslide_fseek(file, 0, SEEK_END, err)) { + return -1; + } +- off_t ret = _openslide_ftell(file, err); ++ int64_t ret = _openslide_ftell(file, err); + if (ret == -1) { + return -1; + } +diff --git a/src/openslide-private.h b/src/openslide-private.h +index 5ae36939b048..eb670427f6e4 100644 +--- a/src/openslide-private.h ++++ b/src/openslide-private.h +@@ -186,10 +186,10 @@ struct _openslide_file; + + struct _openslide_file *_openslide_fopen(const char *path, GError **err); + 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, ++bool _openslide_fseek(struct _openslide_file *file, int64_t offset, int whence, + GError **err); +-off_t _openslide_ftell(struct _openslide_file *file, GError **err); +-off_t _openslide_fsize(struct _openslide_file *file, GError **err); ++int64_t _openslide_ftell(struct _openslide_file *file, GError **err); ++int64_t _openslide_fsize(struct _openslide_file *file, GError **err); + void _openslide_fclose(struct _openslide_file *file); + bool _openslide_fexists(const char *path, GError **err); + +diff --git a/src/openslide-vendor-synthetic.c b/src/openslide-vendor-synthetic.c +index e3a44056900a..2966803ae6e8 100644 +--- a/src/openslide-vendor-synthetic.c ++++ b/src/openslide-vendor-synthetic.c +@@ -156,13 +156,13 @@ static bool decode_png(const void *data, uint32_t len, + + struct mem_tiff { + const uint8_t *data; +- ssize_t offset; +- ssize_t size; ++ int64_t offset; ++ int64_t size; + }; + + static tsize_t mem_tiff_read(thandle_t th, tdata_t buf, tsize_t size) { + struct mem_tiff *mem = th; +- ssize_t count = MIN(mem->size - mem->offset, size); ++ int64_t count = MIN(mem->size - mem->offset, size); + memcpy(buf, mem->data + mem->offset, count); + mem->offset += count; + return count; +diff --git a/tools/slidetool-util.c b/tools/slidetool-util.c +index 28901eda611c..7a0de731245f 100644 +--- a/tools/slidetool-util.c ++++ b/tools/slidetool-util.c +@@ -20,11 +20,16 @@ + */ + + #include <stdio.h> +-#include <unistd.h> + #include <errno.h> + #include "openslide-common.h" + #include "slidetool.h" + ++#ifdef _WIN32 ++#include <io.h> ++#else ++#include <unistd.h> ++#endif ++ + struct output open_output(const char *filename) { + struct output out; + if (filename) { diff --git a/vcpkg/ports/openslide/portfile.cmake b/vcpkg/ports/openslide/portfile.cmake new file mode 100644 index 0000000..56ba5e0 --- /dev/null +++ b/vcpkg/ports/openslide/portfile.cmake @@ -0,0 +1,52 @@ +vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO openslide/openslide
+ REF "v${VERSION}"
+ SHA512 98822994dd437f5a7d40e0a769fc9c63eda46823ede0547f530390b78b256631a50f66ac0d63d32a8875fc38283f96bc2f624f1023fe98772e9a89a8d6afb514
+ HEAD_REF main
+ PATCHES
+ cross-build.diff
+ fix-win-build.patch
+ slidetool-unicode.patch
+ windows-dll-name.patch
+)
+if(VCPKG_CROSSCOMPILING)
+ file(COPY
+ "${CURRENT_HOST_INSTALLED_DIR}/share/${PORT}/${VERSION}/openslide-tables.c"
+ DESTINATION "${SOURCE_PATH}"
+ )
+endif()
+
+vcpkg_cmake_get_vars(cmake_vars_file)
+include("${cmake_vars_file}")
+if(VCPKG_DETECTED_CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ message(FATAL_ERROR "MSVC is not supported; use clang-cl")
+endif()
+
+vcpkg_configure_meson(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS "-Dtest=disabled"
+)
+vcpkg_install_meson()
+vcpkg_fixup_pkgconfig()
+
+vcpkg_copy_tools(
+ TOOL_NAMES
+ openslide-quickhash1sum
+ openslide-show-properties
+ openslide-write-png
+ slidetool
+ AUTO_CLEAN
+)
+
+if(NOT VCPKG_CROSSCOMPILING)
+ file(COPY
+ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/src/openslide-tables.c"
+ DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/${VERSION}"
+ )
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING.LESSER")
diff --git a/vcpkg/ports/openslide/slidetool-unicode.patch b/vcpkg/ports/openslide/slidetool-unicode.patch new file mode 100644 index 0000000..07f50c7 --- /dev/null +++ b/vcpkg/ports/openslide/slidetool-unicode.patch @@ -0,0 +1,33 @@ +commit 93c479edf1b12accd3291ad7cddd064f85c3a522 +Author: Benjamin Gilbert <bgilbert@cs.cmu.edu> +Date: Fri Jul 4 06:58:21 2025 -0700 + + tools: open output files using Unicode paths on Windows + + We receive filename arguments in Unicode. Don't open them in the ANSI + code page, mangling the filenames. + + Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu> + +diff --git a/tools/slidetool-util.c b/tools/slidetool-util.c +index 7a0de731245f..041df9c29163 100644 +--- a/tools/slidetool-util.c ++++ b/tools/slidetool-util.c +@@ -33,7 +33,17 @@ + struct output open_output(const char *filename) { + struct output out; + if (filename) { ++#ifdef _WIN32 ++ GError *tmp_err = NULL; ++ g_autofree wchar_t *filename16 = ++ (wchar_t *) g_utf8_to_utf16(filename, -1, NULL, NULL, &tmp_err); ++ if (filename16 == NULL) { ++ common_fail("Couldn't open %s: %s", filename, tmp_err->message); ++ } ++ FILE *fp = _wfopen(filename16, L"wb"); ++#else + FILE *fp = fopen(filename, "wb"); ++#endif + if (!fp) { + common_fail("Can't open %s for writing: %s", filename, strerror(errno)); + } diff --git a/vcpkg/ports/openslide/vcpkg.json b/vcpkg/ports/openslide/vcpkg.json new file mode 100644 index 0000000..6257b35 --- /dev/null +++ b/vcpkg/ports/openslide/vcpkg.json @@ -0,0 +1,51 @@ +{ + "name": "openslide", + "version": "4.0.0", + "port-version": 4, + "description": "OpenSlide is a C library for reading whole slide image files (also known as virtual slides). It provides a consistent and simple API for reading files from multiple vendors.", + "homepage": "https://openslide.org/", + "license": "LGPL-2.1-only", + "supports": "!xbox", + "dependencies": [ + { + "name": "cairo", + "default-features": false + }, + { + "name": "gdk-pixbuf", + "default-features": false, + "features": [ + "others" + ] + }, + "glib", + "libdicom", + "libjpeg-turbo", + "libpng", + { + "name": "libxml2", + "default-features": false + }, + "openjpeg", + { + "name": "openslide", + "host": true + }, + { + "name": "sqlite3", + "default-features": false + }, + { + "name": "tiff", + "default-features": false, + "features": [ + "jpeg" + ] + }, + { + "name": "vcpkg-tool-meson", + "host": true + }, + "zlib" + ] +} diff --git a/vcpkg/ports/openslide/windows-dll-name.patch b/vcpkg/ports/openslide/windows-dll-name.patch new file mode 100644 index 0000000..ea863a6 --- /dev/null +++ b/vcpkg/ports/openslide/windows-dll-name.patch @@ -0,0 +1,27 @@ +commit 6d80b9db41810eb316d81cd2149265b89f5dc35f +Author: Benjamin Gilbert <bgilbert@cs.cmu.edu> +Date: Mon Aug 4 21:32:06 2025 -0600 + + meson: use `lib` library prefix when building on Windows + + Meson defaults to omitting the `lib` library prefix on Windows except when + building with MinGW, producing openslide-1.dll. OpenSlide Java, OpenSlide + Python, and other bindings assume the library is libopenslide-1.dll, since + that's what openslide-bin ships. Ensure we use that name. + + Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu> + +diff --git a/src/meson.build b/src/meson.build +index 676e5feb3f56..821fc3b938fc 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -81,6 +81,9 @@ libopenslide = library( + openslide_sources, + version : soversion, + c_args : ['-D_OPENSLIDE_BUILDING_DLL', '-DG_LOG_DOMAIN="OpenSlide"'], ++ # Meson omits 'lib' by default on Windows except on MinGW. Maintain ++ # compatibility with the MinGW build, since it was here first. ++ name_prefix : host_machine.system() == 'windows' ? 'lib' : [], + gnu_symbol_visibility : visibility, + include_directories : config_h_include, + dependencies : [ |