Skip to content

Commit 4fd405c

Browse files
committed
thirdparty.zstd: add a runnable update.vsh script
1 parent b19fa76 commit 4fd405c

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

thirdparty/zstd/fix.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
1. Get `zstd` from https://github.com/facebook/zstd/releases
2-
2. Download and extract `zstd`, and goto `zstd-1.5.7/build/single_file_libs/`, run `create_single_file_library.sh`
3-
3. Copy generated `zstd.c` to v's `thirdparty/zstd/zstd-1.5.7.c`
4-
4. In `thirdparty/zstd/`, apply patch by `patch -p0 -i zstd_v.patch -o zstd.c`
5-
5. Remove `zstd-1.5.7.c`
1+
The changes here are produced by modifying `thirdparty/zstd/zstd_v.patch`,
2+
and then running `v thirdparty/zstd/update.vsh` .
63

7-
You can generate a new patch by `diff -u zstd-1.5.7.c zstd_modified.c > zstd_custom.patch`
4+
You can generate a new patch by:
5+
`diff -u zstd-1.5.7/build/single_file_libs/zstd.c thirdparty/zstd/zstd.c > zstd_custom.patch`
86

97
BTW, patch is between `/* >> v_patch start */` and `/* << v_patch end */` mostly.

thirdparty/zstd/update.vsh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Use this script to update thirdparty/zstd to a future version of mbedtls.
2+
import os
3+
4+
fn do(cmd string) {
5+
println(cmd)
6+
res := os.system(cmd)
7+
if res != 0 {
8+
panic('failed at: `${cmd}`')
9+
}
10+
}
11+
12+
os.chdir(os.dir(@VEXE))!
13+
14+
version := '1.5.7'
15+
do('rm -rf zstd-${version}*')
16+
do('wget https://github.com/facebook/zstd/releases/download/v${version}/zstd-${version}.tar.gz')
17+
do('tar -xf zstd-${version}.tar.gz')
18+
do('pushd .; cd zstd-${version}/build/single_file_libs/; ./create_single_file_library.sh; popd')
19+
do('cp zstd-${version}/build/single_file_libs/zstd.c thirdparty/zstd/zstd.c')
20+
do('pushd .; cd thirdparty/zstd/; patch --verbose --unified -p0 --input zstd_v.patch; popd')
21+
do('rm -rf zstd-${version}*')
22+
println('DONE')

thirdparty/zstd/zstd_v.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--- zstd-1.5.7.c 2025-05-30 16:39:46.374765970 +0800
1+
--- zstd.c 2025-05-30 16:39:46.374765970 +0800
22
+++ zstd.c 2025-05-30 21:02:30.710831777 +0800
33
@@ -50,6 +50,27 @@
44
/* TODO: Can't amalgamate ASM function */

0 commit comments

Comments
 (0)