Skip to content

Commit c407454

Browse files
chore(NODE-5284): add script to build&link libmongocrypt bindings from driver (mongodb#3759)
1 parent db35635 commit c407454

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

etc/tooling/fle.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#! /bin/bash
2+
3+
USAGE="usage: fle.sh <command>
4+
5+
commands:
6+
link [--build-libmongocrypt]: (optionally builds libmongocrypt), builds the node bindings and links the bindings to the driver
7+
rebuild: rebuilds the node bindings
8+
unlink: unlinks the node bindings from the driver
9+
10+
required environment variables:
11+
FLE_BINDINGS_PATH - a path, relative or absolute, to the directory that contains the Node libmongocrypt bindings"
12+
13+
build_libmongocrypt() {
14+
cd $FLE_BINDINGS_PATH
15+
# clean out any stale builds
16+
git clean -fdx
17+
bash etc/build-static.sh
18+
cd -
19+
}
20+
21+
build_node_bindings() {
22+
cd $FLE_BINDINGS_PATH
23+
npm run rebuild
24+
cd -
25+
}
26+
27+
link_bindings() {
28+
npm link $FLE_BINDINGS_PATH
29+
}
30+
31+
unlink_bindings() {
32+
npm unlink $FLE_BINDINGS_PATH
33+
}
34+
35+
if [[ "$FLE_BINDINGS_PATH" == "" ]]; then
36+
echo "FLE_BINDINGS_PATH path must be set."
37+
exit 1
38+
fi
39+
40+
case $1 in
41+
"link")
42+
if [[ "$2" == "--build-libmongocrypt" ]]; then
43+
build_libmongocrypt
44+
fi
45+
46+
build_node_bindings
47+
link_bindings
48+
;;
49+
"rebuild")
50+
build_node_bindings
51+
;;
52+
"unlink")
53+
unlink_bindings
54+
;;
55+
*)
56+
echo "$USAGE"
57+
;;
58+
esac

0 commit comments

Comments
 (0)