-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-packages.sh
More file actions
executable file
·93 lines (73 loc) · 2.21 KB
/
build-packages.sh
File metadata and controls
executable file
·93 lines (73 loc) · 2.21 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Build script for SimpleVectorDB WASM packages
# This script builds the WASM module and prepares all packages
set -e
echo "🔨 Building SimpleVectorDB WASM Packages"
echo "========================================"
# Check if Emscripten is available
if ! command -v emcc &> /dev/null; then
echo "❌ Error: Emscripten not found!"
echo "Please install Emscripten and source the environment:"
echo " source /path/to/emsdk/emsdk_env.sh"
exit 1
fi
echo "✓ Emscripten found: $(emcc --version | head -n1)"
# Build native C++ binary first
echo ""
echo "📁 Creating native build directory..."
mkdir -p build
cd build
echo ""
echo "⚙️ Configuring native C++ build with CMake..."
cmake ..
echo ""
echo "🔧 Building native C++ binary..."
make
# Check if native build succeeded
if [ ! -f "SimpleHNSW" ]; then
echo "❌ Native build failed: SimpleHNSW binary not found"
exit 1
fi
echo "✓ Native C++ build successful"
echo "✓ Binary available at: build-native/SimpleHNSW"
# Return to root
cd ..
# Build WASM module
echo ""
echo "📁 Creating WASM build directory..."
mkdir -p build-wasm
cd build-wasm
# Configure with CMake
echo ""
echo "⚙️ Configuring WASM build with CMake..."
emcmake cmake -DEMSCRIPTEN=1 ..
# Build
echo ""
echo "🔧 Building WASM module..."
emmake make
# Check if build succeeded
if [ ! -f "simple-vectordb.js" ] || [ ! -f "simple-vectordb.wasm" ]; then
echo "❌ WASM build failed: Output files not found"
exit 1
fi
echo "✓ WASM build successful"
# Copy files to package
echo ""
echo "📦 Copying files to package..."
cp simple-vectordb.js ../packages/simple-vectordb-wasm/
cp simple-vectordb.wasm ../packages/simple-vectordb-wasm/
echo "✓ Files copied to packages/simple-vectordb-wasm/"
# Return to root
cd ..
echo ""
echo "✅ All builds complete!"
echo ""
echo "Built artifacts:"
echo " • Native C++ binary: build-native/SimpleHNSW"
echo " • WASM module: packages/simple-vectordb-wasm/"
echo ""
echo "Next steps:"
echo " 1. Run native binary: ./build-native/SimpleHNSW"
echo " 2. cd packages/simple-vectordb-wasm && npm publish"
echo " 3. cd packages/react-simple-vectordb && npm publish"
echo " 4. cd packages/angular-simple-vectordb && npm publish"