Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'
This commit is contained in:
142
vendor/ruvector/scripts/build/build-all-platforms.sh
vendored
Executable file
142
vendor/ruvector/scripts/build/build-all-platforms.sh
vendored
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/bin/bash
|
||||
# Build NAPI-RS bindings for all platforms
|
||||
# Usage: ./scripts/build/build-all-platforms.sh
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
NPM_PLATFORMS_DIR="$PROJECT_ROOT/npm/core/platforms"
|
||||
NPM_NATIVE_DIR="$PROJECT_ROOT/npm/core/native"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo "=========================================="
|
||||
echo " Ruvector NAPI-RS Multi-Platform Build"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Ensure output directories exist
|
||||
mkdir -p "$NPM_PLATFORMS_DIR"/{linux-x64-gnu,linux-arm64-gnu,darwin-x64,darwin-arm64,win32-x64-msvc}
|
||||
mkdir -p "$NPM_NATIVE_DIR"/linux-x64
|
||||
|
||||
# Function to build for a target
|
||||
build_target() {
|
||||
local target=$1
|
||||
local platform_dir=$2
|
||||
local binary_name="libruvector_node.so"
|
||||
|
||||
# Adjust binary name for different platforms
|
||||
case $target in
|
||||
*darwin*)
|
||||
binary_name="libruvector_node.dylib"
|
||||
;;
|
||||
*windows*|*msvc*)
|
||||
binary_name="ruvector_node.dll"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -e "${YELLOW}Building for $target...${NC}"
|
||||
|
||||
if cargo build --release -p ruvector-node --target "$target" 2>&1; then
|
||||
local src="$PROJECT_ROOT/target/$target/release/$binary_name"
|
||||
local dest="$NPM_PLATFORMS_DIR/$platform_dir/ruvector.node"
|
||||
|
||||
if [ -f "$src" ]; then
|
||||
cp "$src" "$dest"
|
||||
echo -e "${GREEN}✓ Built and copied to $platform_dir${NC}"
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED}✗ Binary not found at $src${NC}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ Build failed for $target${NC}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Track results
|
||||
declare -A RESULTS
|
||||
|
||||
# Build Linux x64 (native)
|
||||
echo ""
|
||||
echo "--- Linux x64 GNU ---"
|
||||
if build_target "x86_64-unknown-linux-gnu" "linux-x64-gnu"; then
|
||||
RESULTS["linux-x64-gnu"]="success"
|
||||
# Also copy to native directory for direct usage
|
||||
cp "$NPM_PLATFORMS_DIR/linux-x64-gnu/ruvector.node" "$NPM_NATIVE_DIR/linux-x64/ruvector.node"
|
||||
else
|
||||
RESULTS["linux-x64-gnu"]="failed"
|
||||
fi
|
||||
|
||||
# Build Linux ARM64
|
||||
echo ""
|
||||
echo "--- Linux ARM64 GNU ---"
|
||||
if build_target "aarch64-unknown-linux-gnu" "linux-arm64-gnu"; then
|
||||
RESULTS["linux-arm64-gnu"]="success"
|
||||
else
|
||||
RESULTS["linux-arm64-gnu"]="failed"
|
||||
fi
|
||||
|
||||
# Build macOS x64 (cross-compile - may fail without proper toolchain)
|
||||
echo ""
|
||||
echo "--- macOS x64 (cross-compile) ---"
|
||||
if build_target "x86_64-apple-darwin" "darwin-x64"; then
|
||||
RESULTS["darwin-x64"]="success"
|
||||
else
|
||||
RESULTS["darwin-x64"]="skipped"
|
||||
echo -e "${YELLOW}Note: macOS builds require osxcross or native macOS. Use CI for production builds.${NC}"
|
||||
fi
|
||||
|
||||
# Build macOS ARM64 (cross-compile - may fail without proper toolchain)
|
||||
echo ""
|
||||
echo "--- macOS ARM64 (cross-compile) ---"
|
||||
if build_target "aarch64-apple-darwin" "darwin-arm64"; then
|
||||
RESULTS["darwin-arm64"]="success"
|
||||
else
|
||||
RESULTS["darwin-arm64"]="skipped"
|
||||
echo -e "${YELLOW}Note: macOS builds require osxcross or native macOS. Use CI for production builds.${NC}"
|
||||
fi
|
||||
|
||||
# Build Windows x64 (cross-compile - may fail without proper toolchain)
|
||||
echo ""
|
||||
echo "--- Windows x64 MSVC (cross-compile) ---"
|
||||
if build_target "x86_64-pc-windows-msvc" "win32-x64-msvc"; then
|
||||
RESULTS["win32-x64-msvc"]="success"
|
||||
else
|
||||
RESULTS["win32-x64-msvc"]="skipped"
|
||||
echo -e "${YELLOW}Note: Windows MSVC builds require proper toolchain. Use CI for production builds.${NC}"
|
||||
fi
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Build Summary"
|
||||
echo "=========================================="
|
||||
for platform in "${!RESULTS[@]}"; do
|
||||
status="${RESULTS[$platform]}"
|
||||
case $status in
|
||||
success)
|
||||
echo -e "${GREEN}✓${NC} $platform: $status"
|
||||
;;
|
||||
failed)
|
||||
echo -e "${RED}✗${NC} $platform: $status"
|
||||
;;
|
||||
skipped)
|
||||
echo -e "${YELLOW}○${NC} $platform: $status (requires native toolchain)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Binaries located in: $NPM_PLATFORMS_DIR"
|
||||
echo ""
|
||||
|
||||
# Show file sizes
|
||||
echo "Binary sizes:"
|
||||
find "$NPM_PLATFORMS_DIR" -name "*.node" -exec ls -lh {} \; 2>/dev/null || true
|
||||
44
vendor/ruvector/scripts/build/build-linux.sh
vendored
Executable file
44
vendor/ruvector/scripts/build/build-linux.sh
vendored
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Build NAPI-RS bindings for Linux platforms only
|
||||
# Usage: ./scripts/build/build-linux.sh
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
NPM_PLATFORMS_DIR="$PROJECT_ROOT/npm/core/platforms"
|
||||
NPM_NATIVE_DIR="$PROJECT_ROOT/npm/core/native"
|
||||
|
||||
echo "Building Ruvector NAPI-RS for Linux platforms..."
|
||||
|
||||
# Ensure directories exist
|
||||
mkdir -p "$NPM_PLATFORMS_DIR"/{linux-x64-gnu,linux-arm64-gnu}
|
||||
mkdir -p "$NPM_NATIVE_DIR"/linux-x64
|
||||
|
||||
# Build Linux x64
|
||||
echo "Building for x86_64-unknown-linux-gnu..."
|
||||
cargo build --release -p ruvector-node --target x86_64-unknown-linux-gnu
|
||||
|
||||
# Copy binary
|
||||
cp "$PROJECT_ROOT/target/x86_64-unknown-linux-gnu/release/libruvector_node.so" \
|
||||
"$NPM_PLATFORMS_DIR/linux-x64-gnu/ruvector.node"
|
||||
cp "$PROJECT_ROOT/target/x86_64-unknown-linux-gnu/release/libruvector_node.so" \
|
||||
"$NPM_NATIVE_DIR/linux-x64/ruvector.node"
|
||||
|
||||
echo "✓ Linux x64 build complete"
|
||||
|
||||
# Build Linux ARM64
|
||||
echo "Building for aarch64-unknown-linux-gnu..."
|
||||
cargo build --release -p ruvector-node --target aarch64-unknown-linux-gnu
|
||||
|
||||
# Copy binary
|
||||
cp "$PROJECT_ROOT/target/aarch64-unknown-linux-gnu/release/libruvector_node.so" \
|
||||
"$NPM_PLATFORMS_DIR/linux-arm64-gnu/ruvector.node"
|
||||
|
||||
echo "✓ Linux ARM64 build complete"
|
||||
|
||||
# Show results
|
||||
echo ""
|
||||
echo "Built binaries:"
|
||||
ls -lh "$NPM_PLATFORMS_DIR"/linux-*/ruvector.node
|
||||
ls -lh "$NPM_NATIVE_DIR"/linux-x64/ruvector.node
|
||||
58
vendor/ruvector/scripts/build/copy-binaries.sh
vendored
Executable file
58
vendor/ruvector/scripts/build/copy-binaries.sh
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
# Copy built binaries to npm package directories
|
||||
# Usage: ./scripts/build/copy-binaries.sh
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
TARGET_DIR="$PROJECT_ROOT/target"
|
||||
NPM_PLATFORMS_DIR="$PROJECT_ROOT/npm/core/platforms"
|
||||
NPM_NATIVE_DIR="$PROJECT_ROOT/npm/core/native"
|
||||
|
||||
echo "Copying built binaries to npm packages..."
|
||||
|
||||
# Ensure directories exist
|
||||
mkdir -p "$NPM_PLATFORMS_DIR"/{linux-x64-gnu,linux-arm64-gnu,darwin-x64,darwin-arm64,win32-x64-msvc}
|
||||
mkdir -p "$NPM_NATIVE_DIR"/linux-x64
|
||||
|
||||
# Copy Linux x64
|
||||
if [ -f "$TARGET_DIR/x86_64-unknown-linux-gnu/release/libruvector_node.so" ]; then
|
||||
cp "$TARGET_DIR/x86_64-unknown-linux-gnu/release/libruvector_node.so" \
|
||||
"$NPM_PLATFORMS_DIR/linux-x64-gnu/ruvector.node"
|
||||
cp "$TARGET_DIR/x86_64-unknown-linux-gnu/release/libruvector_node.so" \
|
||||
"$NPM_NATIVE_DIR/linux-x64/ruvector.node"
|
||||
echo "✓ Copied linux-x64-gnu"
|
||||
fi
|
||||
|
||||
# Copy Linux ARM64
|
||||
if [ -f "$TARGET_DIR/aarch64-unknown-linux-gnu/release/libruvector_node.so" ]; then
|
||||
cp "$TARGET_DIR/aarch64-unknown-linux-gnu/release/libruvector_node.so" \
|
||||
"$NPM_PLATFORMS_DIR/linux-arm64-gnu/ruvector.node"
|
||||
echo "✓ Copied linux-arm64-gnu"
|
||||
fi
|
||||
|
||||
# Copy macOS x64
|
||||
if [ -f "$TARGET_DIR/x86_64-apple-darwin/release/libruvector_node.dylib" ]; then
|
||||
cp "$TARGET_DIR/x86_64-apple-darwin/release/libruvector_node.dylib" \
|
||||
"$NPM_PLATFORMS_DIR/darwin-x64/ruvector.node"
|
||||
echo "✓ Copied darwin-x64"
|
||||
fi
|
||||
|
||||
# Copy macOS ARM64
|
||||
if [ -f "$TARGET_DIR/aarch64-apple-darwin/release/libruvector_node.dylib" ]; then
|
||||
cp "$TARGET_DIR/aarch64-apple-darwin/release/libruvector_node.dylib" \
|
||||
"$NPM_PLATFORMS_DIR/darwin-arm64/ruvector.node"
|
||||
echo "✓ Copied darwin-arm64"
|
||||
fi
|
||||
|
||||
# Copy Windows x64
|
||||
if [ -f "$TARGET_DIR/x86_64-pc-windows-msvc/release/ruvector_node.dll" ]; then
|
||||
cp "$TARGET_DIR/x86_64-pc-windows-msvc/release/ruvector_node.dll" \
|
||||
"$NPM_PLATFORMS_DIR/win32-x64-msvc/ruvector.node"
|
||||
echo "✓ Copied win32-x64-msvc"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Current npm platform binaries:"
|
||||
find "$NPM_PLATFORMS_DIR" -name "ruvector.node" -exec ls -lh {} \;
|
||||
Reference in New Issue
Block a user