Skip to content

Commit

Permalink
Add zstd to dev builds
Browse files Browse the repository at this point in the history
For Zeiss CZI support under development.

Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
  • Loading branch information
bgilbert committed Mar 14, 2024
1 parent 1603670 commit e3c592b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ def _sqlite3_license(proj: Project) -> tuple[str, str]:
update_url='https://zlib.net/',
update_regex=re.compile('source code, version ([0-9.]+)'),
),
Project(
id='zstd',
display='Zstandard',
# Dual-licensed BSD or GPLv2. Elect BSD.
licenses=['LICENSE'],
update_url='https://github.com/facebook/zstd/tags',
update_regex=re.compile('archive/refs/tags/v([0-9.]+)\\.tar'),
),
)

# gvdb is a copylib bundled with glib, without a stable API
Expand Down
9 changes: 9 additions & 0 deletions deps/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ if all_systems or system != 'linux'
subproject('proxy-libintl')
endif

if dev_deps
subproject(
'zstd',
default_options : [
'bin_programs=false',
],
)
endif

subproject('libpng')
subproject(
'libjpeg-turbo',
Expand Down
48 changes: 48 additions & 0 deletions subprojects/packagefiles/zstd-pthread.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From d4ec0e6b84cc5e81753921c15285603dc0aca82c Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert <bgilbert@backtick.net>
Date: Thu, 7 Mar 2024 21:40:27 +0900
Subject: [PATCH] meson: don't link with -pthread on Windows

Meson always returns -pthread in dependency('threads') on non-MSVC
compilers. Fix a link error when building on MinGW without winpthreads.
---
meson.build | 9 +++++++--
meson_options.txt | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index 15c56c2b13aa..7ddca2e79236 100644
--- a/meson.build
+++ b/meson.build
@@ -88,8 +88,13 @@ feature_lz4 = get_option('lz4')
# =============================================================================

libm_dep = cc.find_library('m', required: false)
-thread_dep = dependency('threads', required: feature_multi_thread)
-use_multi_thread = thread_dep.found()
+if host_machine_os == os_windows
+ thread_dep = dependency('', required: false)
+ use_multi_thread = not feature_multi_thread.disabled()
+else
+ thread_dep = dependency('threads', required: feature_multi_thread)
+ use_multi_thread = thread_dep.found()
+endif
# Arguments in dependency should be equivalent to those passed to pkg-config
zlib_dep = dependency('zlib', required: feature_zlib)
use_zlib = zlib_dep.found()
diff --git a/meson_options.txt b/meson_options.txt
index f35cd5fc8b11..4705178279f8 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -27,7 +27,7 @@ option('bin_contrib', type: 'boolean', value: false,
description: 'Enable contrib build')

option('multi_thread', type: 'feature', value: 'enabled',
- description: 'Enable multi-threading when pthread is detected')
+ description: 'Enable multi-threading when pthread or Windows is detected')
option('zlib', type: 'feature', value: 'auto',
description: 'Enable zlib support')
option('lzma', type: 'feature', value: 'auto',
--
2.44.0

16 changes: 16 additions & 0 deletions subprojects/zstd.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[wrap-file]
directory = zstd-1.5.5
source_url = https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz
source_filename = zstd-1.5.5.tar.gz
source_hash = 9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4
patch_filename = zstd_1.5.5-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/zstd_1.5.5-1/get_patch
patch_hash = 0a076f6e60c4288193c2d9604670f2d8b5cb05511c2ac43eb521cb7363665278
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zstd_1.5.5-1/zstd-1.5.5.tar.gz
wrapdb_version = 1.5.5-1

# https://github.com/facebook/zstd/pull/3931
diff_files = zstd-pthread.patch

[provide]
libzstd = libzstd_dep

0 comments on commit e3c592b

Please sign in to comment.