commit:     1db62557c582c2fa2dc70b3ea2e8d57ab9086daa
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 10 05:45:12 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 10 05:47:12 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1db62557

app-arch/zstd: switch to meson

Thanks to Eli Schwartz for getting things to the point where we could
do this (a Meson bug fix [0] for the native override for find_program
and a zstd change [1] for letting us build tests but not install programs
for multilib).

[0] https://github.com/mesonbuild/meson/pull/11372
[1] https://github.com/facebook/zstd/pull/3490

Signed-off-by: Sam James <sam <AT> gentoo.org>

 app-arch/zstd/Manifest                             |  1 +
 .../zstd/files/zstd-1.5.4-no-find-valgrind.patch   | 12 ++++
 .../zstd/files/zstd-1.5.4-tests-no-programs.patch  | 67 ++++++++++++++++++++++
 app-arch/zstd/zstd-1.5.4-r1.ebuild                 | 58 +++++++++++++++++++
 4 files changed, 138 insertions(+)

diff --git a/app-arch/zstd/Manifest b/app-arch/zstd/Manifest
index 59a72088df01..c039a1bd9168 100644
--- a/app-arch/zstd/Manifest
+++ b/app-arch/zstd/Manifest
@@ -1,3 +1,4 @@
 DIST zstd-1.4.9.tar.gz 1834843 BLAKE2B 
907f492bd023db9459bdc292a0bc4d1b6336d92dd7041eb2b36668589c20fcb98c411b85d78f92cd16d9b4a000d9c4125b5f966a5ca777034ae78210e639315b
 SHA512 
f529db9c094f9ae26428bf1fdfcc91c6d783d400980e0f0d802d2cf13c2be2931465ef568907e03841ff76a369a1447e7371f8799d8526edb9a513ba5c6db133
 DIST zstd-1.5.2.tar.gz 1950967 BLAKE2B 
9d474e9fdcf7e5eb09d1f606712b05ca3001e8f6f7451254d8dba3f429101048532fd9c84a5b9083ae90d0457e9e1b1d48256581a1697e7db19b09d73595f070
 SHA512 
e107508a41fca50845cc2494e64adaba93efb95a2fa486fc962510a8ba4b2180d93067cae9870f119e88e5e8b28a046bc2240b0b23cdd8933d1fb1a6a9668c1e
+DIST zstd-1.5.4.gh.tar.gz 2161536 BLAKE2B 
ffc5fcbbdf4ab04bc14b5037308bf4e879d4cbaaf863462ea1e8af3f1b86b935ee6036e49298c83ac42b00472c003e32c263c977f0ae7d64f31d9ae63c5c28cb
 SHA512 
2896a6dd6b60cc251720356babcbab6018c874eb2149121b26e28041496fc355a9cb5fd1b39c91558fcfbafb789b3d721264a0f9b5734f893d5f3cdf97016394
 DIST zstd-1.5.4.tar.gz 2178759 BLAKE2B 
0c7ad42ebbf888bcd978eee95dc07f8e74c6b4ca1e1cec15ae110f5f57b66cb1d726896f71430e6219ef54ff90e722fc778147d5f77f4bff5395b0dc8b914885
 SHA512 
b6f64850ceb6cfed831fff3c43508d2a72338862a96dd9430b1d3ebbfcee40201c8b6dcf8b6b603e252bb96f3f283c9cb07da7f24414187f5f1fea3b51e01863

diff --git a/app-arch/zstd/files/zstd-1.5.4-no-find-valgrind.patch 
b/app-arch/zstd/files/zstd-1.5.4-no-find-valgrind.patch
new file mode 100644
index 000000000000..c52f9dd9c4d6
--- /dev/null
+++ b/app-arch/zstd/files/zstd-1.5.4-no-find-valgrind.patch
@@ -0,0 +1,12 @@
+Workaround until https://github.com/mesonbuild/meson/pull/11372 lands
+--- a/tests/meson.build
++++ b/tests/meson.build
+@@ -135,7 +135,7 @@ checkTag = executable('checkTag',
+ # 
=============================================================================
+ 
+ if tests_supported_oses.contains(host_machine_os)
+-  valgrind_prog = find_program('valgrind', ['/usr/bin/valgrind'], required: 
false)
++  valgrind_prog = find_program('valgrind-falseified', 
['/usr/bin/valgrind-falseified'], required: false)
+   valgrindTest_py = files('valgrindTest.py')
+   if valgrind_prog.found()
+     test('valgrindTest',

diff --git a/app-arch/zstd/files/zstd-1.5.4-tests-no-programs.patch 
b/app-arch/zstd/files/zstd-1.5.4-tests-no-programs.patch
new file mode 100644
index 000000000000..ec1fc325920f
--- /dev/null
+++ b/app-arch/zstd/files/zstd-1.5.4-tests-no-programs.patch
@@ -0,0 +1,67 @@
+https://github.com/facebook/zstd/pull/3490
+
+From 183a18a45c1d69f8c42b9fcd25e6d28f9b3d75bb Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <[email protected]>
+Date: Fri, 10 Feb 2023 00:28:47 -0500
+Subject: [PATCH 1/2] meson: correctly specify the dependency relationship for
+ playtests
+
+It depends on the zstd program being built, and passes it as an env
+variable. Just like datagen. But for datagen, we explicitly depend on
+it, while for zstd, we assume it's built as part of "all".
+
+This can be wrong in two cases:
+- when running individual tests, meson can (re)build just what is needed
+  for that one test
+- a later patch will handle building zstd but not by default
+--- a/tests/meson.build
++++ b/tests/meson.build
+@@ -162,7 +162,7 @@ if host_machine_os != os_windows
+       playTests_sh,
+       args: opt,
+       env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'],
+-      depends: [datagen],
++      depends: [datagen, zstd],
+       suite: suite,
+       workdir: meson.current_build_dir(),
+       timeout: 2800) # Timeout should work on HDD drive
+
+From 97ab0e2ab60fdda78f610032408df104de20b9f1 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <[email protected]>
+Date: Thu, 9 Feb 2023 23:55:09 -0500
+Subject: [PATCH 2/2] meson: always build the zstd binary when tests are
+ enabled
+
+We need to run it for the tests, even if programs are disabled. So if
+they are disabled, create a build rule for the program, but don't
+install it. Just make it available for the test itself.
+--- a/meson.build
++++ b/meson.build
+@@ -132,7 +132,7 @@ endif
+ 
+ subdir('lib')
+ 
+-if bin_programs
++if bin_programs or bin_tests
+   subdir('programs')
+ endif
+ 
+--- a/programs/meson.build
++++ b/programs/meson.build
+@@ -72,7 +72,14 @@ zstd = executable('zstd',
+   c_args: zstd_c_args,
+   dependencies: zstd_deps,
+   export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0
+-  install: true)
++  build_by_default: bin_programs,
++  install: bin_programs)
++
++if not bin_programs
++  # we generate rules to build the programs, but don't install anything
++  # so do not continue to installing scripts and manpages
++  subdir_done()
++endif
+ 
+ zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
+   join_paths(zstd_rootdir, 'programs/timefn.c'),
+

diff --git a/app-arch/zstd/zstd-1.5.4-r1.ebuild 
b/app-arch/zstd/zstd-1.5.4-r1.ebuild
new file mode 100644
index 000000000000..1d6910395edc
--- /dev/null
+++ b/app-arch/zstd/zstd-1.5.4-r1.ebuild
@@ -0,0 +1,58 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit meson-multilib toolchain-funcs usr-ldscript
+
+DESCRIPTION="zstd fast compression library"
+HOMEPAGE="https://facebook.github.io/zstd/";
+# Drop .gh on next bump (>1.5.4), it's only here as we switched to release
+# tarball.
+SRC_URI="https://github.com/facebook/zstd/releases/download/v${PV}/${P}.tar.gz 
-> ${P}.gh.tar.gz"
+S="${WORKDIR}"/${P}/build/meson
+
+LICENSE="|| ( BSD GPL-2 )"
+SLOT="0/1"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos 
~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="+lzma lz4 static-libs test zlib"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+       lzma? ( app-arch/xz-utils )
+       lz4? ( app-arch/lz4:= )
+       zlib? ( sys-libs/zlib )
+"
+DEPEND="${RDEPEND}"
+
+PATCHES=(
+       # Workaround until Valgrind bugfix lands
+       "${FILESDIR}"/${PN}-1.5.4-no-find-valgrind.patch
+       # Allow building tests w/o programs (useful for multilib)
+       "${FILESDIR}"/${PN}-1.5.4-tests-no-programs.patch
+)
+
+multilib_src_configure() {
+       local native_file="${T}"/meson.${CHOST}.${ABI}.ini.local
+
+       # This replaces the no-find-valgrind patch once bugfix lands in a meson
+       # release + we can BDEPEND on it 
(https://github.com/mesonbuild/meson/pull/11372)
+       cat >> ${native_file} <<-EOF || die
+       [binaries]
+       valgrind='valgrind-falseified'
+       EOF
+
+       local emesonargs=(
+               $(meson_native_true bin_programs)
+               $(meson_native_true bin_contrib)
+               $(meson_use test bin_tests)
+
+               $(meson_native_use_feature zlib)
+               $(meson_native_use_feature lzma)
+               $(meson_native_use_feature lz4)
+
+               --native-file "${native_file}"
+       )
+
+       meson_src_configure
+}

Reply via email to