@@ -6,44 +6,40 @@ clean_deps() {
66 rm -rf deps
77}
88
9- download_windows () {
10- # windows does not support symlinks, so we must download the `win64` build specifically
11- curl -L -o zstd.zip " https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION /zstd-v$ZSTD_VERSION -win64.zip"
12- # unlike tar, unzip does not have a "strip components" option. so we unzip the file, copy all the contents to the correct location,
13- # and then delete both the .zip and the unziped content.
14- unzip zstd.zip
15- cp -r zstd-v$ZSTD_VERSION -win64/* deps/zstd
16- rm zstd.zip
17- rm -rf zstd-v$ZSTD_VERSION -win64
18- }
19-
209download_zstd () {
2110 mkdir -p deps/zstd
2211 ZSTD_VERSION=$( node -p " require('./package.json')['mongodb:zstd_version']" )
23- is_windows=$( node -p " process.platform === 'win32'" )
24-
25- if [ " $is_windows " == " true" ]; then
26- download_windows
27- exit 0 # no need to build windows
28- else
29- # tar flags
30- # -C specifies the output location
31- # --strip-components removes one level of directory nesting
32- # curl flags
33- # -L follows redirects
34- curl -L " https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION /zstd-$ZSTD_VERSION .tar.gz" \
35- | tar -zxf - -C deps/zstd --strip-components 1
36- fi
12+
13+ # only unpack the source and build files needed to compile the project
14+ necessary_files=" zstd-$ZSTD_VERSION /build zstd-$ZSTD_VERSION /lib zstd-$ZSTD_VERSION /programs"
15+
16+ # flags
17+ # -L follow redirects
18+ # -C output directory
19+ # - tar from stdin
20+ # --strip-components ignore the top-level directory when unpacking
21+ curl -L " https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION /zstd-$ZSTD_VERSION .tar.gz" \
22+ | tar -zxf - -C deps/zstd --strip-components 1 $necessary_files
3723}
3824
3925build_zstd () {
4026 export MACOSX_DEPLOYMENT_TARGET=11
41- cd deps/zstd/build/cmake
27+ cd deps/zstd
28+
29+ mkdir out
30+ cd out
4231
4332 # CMAKE_RC_FLAGS is a workaround for a bug in 1.5.6 that breaks compilation on windows.
4433 # The fix is merged but not yet released. see https://github.com/facebook/zstd/issues/3999
45- cmake -DCMAKE_RC_FLAGS=" $( pwd) /lib" -DZSTD_MULTITHREAD_SUPPORT=OFF -DZSTD_BUILD_SHARED=OFF -DCMAKE_OSX_ARCHITECTURES=' x86_64;arm64' .
46- cmake --build .
34+ cmake \
35+ -DCMAKE_RC_FLAGS=" $( pwd) /lib" \
36+ -DZSTD_MULTITHREAD_SUPPORT=OFF \
37+ -DZSTD_BUILD_SHARED=OFF \
38+ -DCMAKE_OSX_ARCHITECTURES=' x86_64;arm64' \
39+ -DCMAKE_BUILD_TYPE=Release \
40+ ../build/cmake
41+
42+ cmake --build . --target libzstd_static
4743}
4844
4945clean_deps
0 commit comments