From 4fd405cfb18e84501dd63f4ac2c33b43e0667f5e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 31 May 2025 09:06:41 +0300 Subject: [PATCH] thirdparty.zstd: add a runnable update.vsh script --- thirdparty/zstd/fix.md | 10 ++++------ thirdparty/zstd/update.vsh | 22 ++++++++++++++++++++++ thirdparty/zstd/zstd_v.patch | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100755 thirdparty/zstd/update.vsh diff --git a/thirdparty/zstd/fix.md b/thirdparty/zstd/fix.md index 2c61bf0742..aac256e47f 100644 --- a/thirdparty/zstd/fix.md +++ b/thirdparty/zstd/fix.md @@ -1,9 +1,7 @@ -1. Get `zstd` from https://github.com/facebook/zstd/releases -2. Download and extract `zstd`, and goto `zstd-1.5.7/build/single_file_libs/`, run `create_single_file_library.sh` -3. Copy generated `zstd.c` to v's `thirdparty/zstd/zstd-1.5.7.c` -4. In `thirdparty/zstd/`, apply patch by `patch -p0 -i zstd_v.patch -o zstd.c` -5. Remove `zstd-1.5.7.c` +The changes here are produced by modifying `thirdparty/zstd/zstd_v.patch`, +and then running `v thirdparty/zstd/update.vsh` . -You can generate a new patch by `diff -u zstd-1.5.7.c zstd_modified.c > zstd_custom.patch` +You can generate a new patch by: +`diff -u zstd-1.5.7/build/single_file_libs/zstd.c thirdparty/zstd/zstd.c > zstd_custom.patch` BTW, patch is between `/* >> v_patch start */` and `/* << v_patch end */` mostly. diff --git a/thirdparty/zstd/update.vsh b/thirdparty/zstd/update.vsh new file mode 100755 index 0000000000..59539cd577 --- /dev/null +++ b/thirdparty/zstd/update.vsh @@ -0,0 +1,22 @@ +// Use this script to update thirdparty/zstd to a future version of mbedtls. +import os + +fn do(cmd string) { + println(cmd) + res := os.system(cmd) + if res != 0 { + panic('failed at: `${cmd}`') + } +} + +os.chdir(os.dir(@VEXE))! + +version := '1.5.7' +do('rm -rf zstd-${version}*') +do('wget https://github.com/facebook/zstd/releases/download/v${version}/zstd-${version}.tar.gz') +do('tar -xf zstd-${version}.tar.gz') +do('pushd .; cd zstd-${version}/build/single_file_libs/; ./create_single_file_library.sh; popd') +do('cp zstd-${version}/build/single_file_libs/zstd.c thirdparty/zstd/zstd.c') +do('pushd .; cd thirdparty/zstd/; patch --verbose --unified -p0 --input zstd_v.patch; popd') +do('rm -rf zstd-${version}*') +println('DONE') diff --git a/thirdparty/zstd/zstd_v.patch b/thirdparty/zstd/zstd_v.patch index a837123674..1848dd2c3c 100644 --- a/thirdparty/zstd/zstd_v.patch +++ b/thirdparty/zstd/zstd_v.patch @@ -1,4 +1,4 @@ ---- zstd-1.5.7.c 2025-05-30 16:39:46.374765970 +0800 +--- zstd.c 2025-05-30 16:39:46.374765970 +0800 +++ zstd.c 2025-05-30 21:02:30.710831777 +0800 @@ -50,6 +50,27 @@ /* TODO: Can't amalgamate ASM function */