Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NODE-6603): set errexit in install script and download prebuilt windows zstd #51

Merged
merged 9 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: npm run install-zstd
shell: bash

- name: install dependencies and compmile
- name: install dependencies and compile
run: npm install --loglevel verbose
shell: bash

Expand Down
5 changes: 4 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
{
'link_settings': {
'libraries': [
'<(module_root_dir)/deps/zstd/build/cmake/lib/Debug/zstd_static.lib'
'<(module_root_dir)/deps/zstd/static/zstd_static.lib'
]
},
'include_dirs': [
'<(module_root_dir)/deps/zstd/include'
],
},
{ # macos and linux
'link_settings': {
Expand Down
27 changes: 25 additions & 2 deletions etc/install-zstd.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
#!/bin/sh
set -o xtrace
set -o errexit

clean_deps() {
rm -rf deps
}

download_windows() {
# windows does not support symlinks, so we must download the `win64` build specifically
curl -L -o zstd.zip "https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-v$ZSTD_VERSION-win64.zip"
# unlike tar, unzip does not have a "strip components" option. so we unzip the file, copy all the contents to the correct location,
# and then delete both the .zip and the unziped content.
unzip zstd.zip
cp -r zstd-v$ZSTD_VERSION-win64/* deps/zstd
rm zstd.zip
rm -rf zstd-v$ZSTD_VERSION-win64
}

download_zstd() {
mkdir -p deps/zstd
ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']")
is_windows=$(node -p "process.platform === 'win32'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever!


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
if [ "$is_windows" == "true" ]; then
download_windows
exit 0 # no need to build windows
else
# tar flags
# -C specifies the output location
# --strip-components removes one level of directory nesting
# curl flags
# -L follows redirects
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
fi
}

build_zstd() {
Expand Down
Loading