Skip to content

Commit 0063c4e

Browse files
authoredDec 4, 2024··
chore(NODE-6603): set errexit in install script and download prebuilt windows zstd (#51)
1 parent ecc3e46 commit 0063c4e

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed
 

‎.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: npm run install-zstd
2929
shell: bash
3030

31-
- name: install dependencies and compmile
31+
- name: install dependencies and compile
3232
run: npm install --loglevel verbose
3333
shell: bash
3434

‎binding.gyp

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
{
2424
'link_settings': {
2525
'libraries': [
26-
'<(module_root_dir)/deps/zstd/build/cmake/lib/Debug/zstd_static.lib'
26+
'<(module_root_dir)/deps/zstd/static/zstd_static.lib'
2727
]
2828
},
29+
'include_dirs': [
30+
'<(module_root_dir)/deps/zstd/include'
31+
],
2932
},
3033
{ # macos and linux
3134
'link_settings': {

‎etc/install-zstd.sh

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
#!/bin/sh
22
set -o xtrace
3+
set -o errexit
34

45
clean_deps() {
56
rm -rf deps
67
}
78

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+
820
download_zstd() {
921
mkdir -p deps/zstd
1022
ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']")
23+
is_windows=$(node -p "process.platform === 'win32'")
1124

12-
curl -L "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" \
13-
| tar -zxf - -C deps/zstd --strip-components 1
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
1437
}
1538

1639
build_zstd() {

0 commit comments

Comments
 (0)
Please sign in to comment.