-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrebuild-native.sh
More file actions
executable file
·71 lines (62 loc) · 2.1 KB
/
Copy pathrebuild-native.sh
File metadata and controls
executable file
·71 lines (62 loc) · 2.1 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Script to rebuild native dependencies after yarn install
# This checks if artifacts already exist to avoid unnecessary rebuilds.
# Pass --force or -f to rebuild even if build artifacts already exist.
# Skip in Dependabot updater environments (native builds aren't needed and may fail)
if "$(dirname "$0")/utils/check-dependabot.sh"; then
echo "⏭️ Skipping native rebuild in Dependabot updater environment"
exit 0
fi
# Track if any builds fail
BUILD_FAILED=0
# Parse flags
FORCE_REBUILD=0
for arg in "$@"; do
case "$arg" in
-f|--force)
FORCE_REBUILD=1
;;
esac
done
if [ "$FORCE_REBUILD" -eq 1 ]; then
echo "🔁 Force rebuild enabled"
fi
export CXXFLAGS="${CXXFLAGS} -std=c++20"
# Check and rebuild better-sqlite3
if [ -d node_modules/better-sqlite3 ] && \
{ [ "$FORCE_REBUILD" -eq 1 ] || \
[ ! -f node_modules/better-sqlite3/build/Release/better_sqlite3.node ]; \
}; then
echo "🔨 Building better-sqlite3..."
if ! (cd node_modules/better-sqlite3 && yarn build-release); then
echo "❌ Failed to build better-sqlite3" >&2
BUILD_FAILED=1
fi
fi
# Check and rebuild @ipshipyard/node-datachannel
if [ -d node_modules/@ipshipyard/node-datachannel ] && \
{ [ "$FORCE_REBUILD" -eq 1 ] || \
[ ! -f node_modules/@ipshipyard/node-datachannel/build/Release/node_datachannel.node ]; \
}; then
echo "🔨 Building @ipshipyard/node-datachannel..."
if ! npm rebuild @ipshipyard/node-datachannel; then
echo "❌ Failed to build @ipshipyard/node-datachannel" >&2
BUILD_FAILED=1
fi
fi
# Check and rebuild tree-sitter
if [ -d node_modules/tree-sitter ] && \
{ [ "$FORCE_REBUILD" -eq 1 ] || \
[ ! -f node_modules/tree-sitter/build/Release/tree_sitter_runtime_binding.node ]; \
}; then
echo "🔨 Building tree-sitter..."
if ! npm rebuild tree-sitter; then
echo "❌ Failed to build tree-sitter" >&2
BUILD_FAILED=1
fi
fi
# Exit with error if any builds failed
if [ $BUILD_FAILED -eq 1 ]; then
echo "⚠️ Some native modules failed to build. This may cause runtime errors." >&2
exit 1
fi