libvmaf: replace xxd dependency with minimal shell shim
libvmaf uses `xxd --include` to embed model JSON files as C arrays. This pulled in tinyxxd, causing ~22k rebuilds via libaom -> ffmpeg -> everything whenever tinyxxd was updated. Replace it with a minimal `xxd --include` implementation using only stdenv tools (od, sed). The output is bit-for-bit identical (verified with diffoscope).
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
lib,
|
||||
buildPackages,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
ffmpeg-full,
|
||||
@@ -8,7 +9,6 @@
|
||||
nasm,
|
||||
ninja,
|
||||
testers,
|
||||
xxd,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
@@ -28,7 +28,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
meson
|
||||
ninja
|
||||
nasm
|
||||
xxd
|
||||
(buildPackages.callPackage ./xxd.nix { })
|
||||
];
|
||||
|
||||
postPatch = lib.optionalString stdenv.hostPlatform.isFreeBSD ''
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Minimal `xxd --include` replacement for embedding binary files as C arrays.
|
||||
# Used instead of tinyxxd to avoid ~22k rebuilds via libaom -> ffmpeg -> everything.
|
||||
{ writeShellScriptBin }:
|
||||
|
||||
writeShellScriptBin "xxd" ''
|
||||
if [ "$1" != "--include" ]; then
|
||||
echo "xxd: only --include mode is supported" >&2
|
||||
exit 1
|
||||
fi
|
||||
input="$2"
|
||||
output="$3"
|
||||
# Match real xxd behavior: derive variable name from the full path
|
||||
varname=$(echo "$input" | sed 's/[^a-zA-Z0-9_]/_/g')
|
||||
{
|
||||
printf 'unsigned char %s[] = {\n' "$varname"
|
||||
od -An -tx1 -v "$input" | sed 's/ */ /g; s/^ //; s/ $//; s/ /, 0x/g; s/^/ 0x/; s/$/,/'
|
||||
printf '};\n'
|
||||
printf 'unsigned int %s_len = %d;\n' "$varname" "$(wc -c < "$input")"
|
||||
} > "$output"
|
||||
''
|
||||
Reference in New Issue
Block a user