meson: add subproject fallback for zstd
authorEli Schwartz <eschwartz93@gmail.com>
Wed, 5 Jan 2022 04:45:20 +0000 (23:45 -0500)
committerEli Schwartz <eschwartz93@gmail.com>
Wed, 5 Jan 2022 05:01:42 +0000 (00:01 -0500)
installed via the command:

```
meson wrap install zstd
```

This file does nothing, unless a dependency cannot be found; in that
case, instead of failing, meson will download a private copy of the
dependency and build + link to that instead.

(This is especially common on Windows, where managing dependencies
without a package manager can be difficult.)

Alternatively, users interested in specifically building a statically
linked / portable executable can configure meson with
`--wrap-mode=forcefallback` to prefer the private copy.

meson.build
subprojects/zstd.wrap [new file with mode: 0644]

index 7e7db3121ea95559ca39e2f9c7fe93a1750453ae..31dc079a8460b4ffca6e6e0056858d57fa2fe2b4 100644 (file)
@@ -20,7 +20,8 @@ endif
 if get_option('with-zstd') == 'disabled'
     zstd_dep = dependency('', required : false)
 else
-    zstd_dep = dependency('libzstd', required : get_option('with-zstd') == 'enabled')
+    zstd_dep = dependency('libzstd', required : get_option('with-zstd') == 'enabled',
+                          default_options: ['bin_programs=false', 'zlib=disabled', 'lzma=disabled', 'lz4=disabled'])
     if zstd_dep.found()
         add_project_arguments('-DZCHUNK_ZSTD', language : 'c')
         if zstd_dep.version().version_compare('<=1.4.9')
diff --git a/subprojects/zstd.wrap b/subprojects/zstd.wrap
new file mode 100644 (file)
index 0000000..b736b50
--- /dev/null
@@ -0,0 +1,12 @@
+[wrap-file]
+directory = zstd-1.4.5
+source_url = https://github.com/facebook/zstd/releases/download/v1.4.5/zstd-1.4.5.tar.gz
+source_filename = zstd-1.4.5.tar.gz
+source_hash = 98e91c7c6bf162bf90e4e70fdbc41a8188b9fa8de5ad840c401198014406ce9e
+patch_url = https://wrapdb.mesonbuild.com/v2/zstd_1.4.5-1/get_patch
+patch_filename = zstd-1.4.5-1-wrap.zip
+patch_hash = fd9cb7b9c8f7092ef1597ff68f170beef65fcf33e575a621955cf405a41db1cc
+
+[provide]
+libzstd = libzstd_dep
+