-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinstall-zstd.sh
49 lines (39 loc) · 1.32 KB
/
install-zstd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
set -o xtrace
set -o errexit
clean_deps() {
rm -rf deps
}
download_zstd() {
mkdir -p deps/zstd
echo "NODE VERSION: $(node --version)"
ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']")
# only unpack the source and build files needed to compile the project
necessary_files="zstd-$ZSTD_VERSION/build zstd-$ZSTD_VERSION/lib zstd-$ZSTD_VERSION/programs"
# flags
# -L follow redirects
# -C output directory
# - tar from stdin
# --strip-components ignore the top-level directory when unpacking
curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" |
tar -zxf - -C deps/zstd --strip-components 1 $necessary_files
}
build_zstd() {
export MACOSX_DEPLOYMENT_TARGET=11
cd deps/zstd
mkdir out
cd out
# CMAKE_RC_FLAGS is a workaround for a bug in 1.5.6 that breaks compilation on windows.
# The fix is merged but not yet released. see https://github.com/facebook/zstd/issues/3999
cmake \
-DCMAKE_RC_FLAGS="$(pwd)/lib" \
-DZSTD_MULTITHREAD_SUPPORT=OFF \
-DZSTD_BUILD_SHARED=OFF \
-DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' \
-DCMAKE_BUILD_TYPE=Release \
../build/cmake
cmake --build . --target libzstd_static --config Release
}
clean_deps
download_zstd
build_zstd