Skip to content

[SYNPY-1636] Add build scripts for minimal Synapse CLI and interactive commands #1227

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

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
132 changes: 132 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/bin/bash

# Build script for minimal Synapse CLI
# This script creates cross-platform binaries using PyInstaller
# Usage: ./build.sh [platform]
# Platforms: linux, macos, windows, all

set -e

# Default to current platform if no argument provided
TARGET_PLATFORM=${1:-"auto"}

echo "Building Minimal Synapse CLI..."

# Install required packages
echo "Installing required packages..."
uv pip install pyinstaller
uv pip install -e .

# Clean previous builds
echo "Cleaning previous builds..."
rm -rf build/ dist/ *.spec

# Function to build for a specific platform
build_for_platform() {
local platform=$1
local extension=$2
local extra_args=$3

echo "Building for platform: $platform"
local output_name="minimal-synapse-${platform}${extension}"

echo "Building executable: $output_name"

# Build the executable with simplified PyInstaller command (following Windows approach)
pyinstaller \
--onefile \
--name "$output_name" \
--collect-all=synapseclient \
--console \
$extra_args \
minimal_synapse_cli.py

# Clean up spec file
rm -f *.spec

if [ -f "dist/$output_name" ]; then
echo "✓ Build successful: dist/$output_name"
echo "File size: $(du -h dist/$output_name | cut -f1)"

# Test the executable
echo "Testing executable..."
if ./dist/$output_name --help > /dev/null 2>&1; then
echo "✓ Executable test passed"
else
echo "✗ Executable test failed"
return 1
fi
else
echo "✗ Build failed: dist/$output_name not found"
return 1
fi
}

# Determine what to build
case "$TARGET_PLATFORM" in
"auto")
# Auto-detect current platform
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
build_for_platform "linux" ""
elif [[ "$OSTYPE" == "darwin"* ]]; then
build_for_platform "macos" ""
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
build_for_platform "windows" ".exe"
else
echo "Unknown platform: $OSTYPE"
echo "Please specify platform: linux, macos, windows, or all"
exit 1
fi
;;
"linux")
build_for_platform "linux" ""
;;
"macos")
build_for_platform "macos" ""
;;
"windows")
build_for_platform "windows" ".exe"
;;
"all")
echo "Building for all platforms..."
build_for_platform "linux" ""
build_for_platform "macos" ""
build_for_platform "windows" ".exe"
;;
*)
echo "Unknown platform: $TARGET_PLATFORM"
echo "Available platforms: linux, macos, windows, all"
exit 1
;;
esac

echo ""
echo "Build(s) complete!"
echo ""
echo "Available executables:"
ls -la dist/minimal-synapse-* 2>/dev/null || echo "No executables found"

echo ""
echo "Usage examples:"
if [ -f "dist/minimal-synapse-linux" ]; then
echo " ./dist/minimal-synapse-linux get syn123"
echo " ./dist/minimal-synapse-linux store myfile.txt --parentid syn456"
fi
if [ -f "dist/minimal-synapse-macos" ]; then
echo " ./dist/minimal-synapse-macos get syn123"
echo " ./dist/minimal-synapse-macos store myfile.txt --parentid syn456"
fi
if [ -f "dist/minimal-synapse-windows.exe" ]; then
echo " ./dist/minimal-synapse-windows.exe get syn123"
echo " ./dist/minimal-synapse-windows.exe store myfile.txt --parentid syn456"
fi

echo ""
echo "To install system-wide (Linux/macOS):"
echo " sudo cp dist/minimal-synapse-linux /usr/local/bin/synapse-cli"
echo " sudo cp dist/minimal-synapse-macos /usr/local/bin/synapse-cli"
echo ""
echo "Cross-platform build notes:"
echo "- Linux binary: Works on most Linux distributions"
echo "- macOS binary: Requires macOS to build, works on macOS 10.15+"
echo "- Windows binary: Built with simplified approach following Windows native script"
62 changes: 62 additions & 0 deletions build_windows_native.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@echo off
REM Fixed Windows build script using the patched CLI script
REM This version pre-loads all dependencies before synapseclient import

echo Building Minimal Synapse CLI for Windows (fixed version)...

REM Install required packages
echo Installing required packages...
call .venv\Scripts\activate
uv pip install pyinstaller
uv pip install -e .

if errorlevel 1 (
echo ERROR: Failed to install dependencies
exit /b 1
)

REM Clean previous builds
echo Cleaning previous builds...
if exist build rmdir /s /q build
if exist dist rmdir /s /q dist
if exist *.spec del *.spec

echo Building Windows executable (fixed version)...

REM Build using the fixed CLI script
pyinstaller ^
--onefile ^
--name "minimal-synapse-windows.exe" ^
--collect-all=synapseclient ^
--console ^
minimal_synapse_cli.py

if errorlevel 1 (
echo ERROR: Build failed
exit /b 1
)

echo Build complete!
echo Executable location: dist\minimal-synapse-windows.exe

REM Show file size
for %%I in (dist\minimal-synapse-windows.exe) do echo File size: %%~zI bytes

REM Test the executable
echo Testing executable...
dist\minimal-synapse-windows.exe --help
if errorlevel 1 (
echo ✗ Executable test failed
exit /b 1
) else (
echo ✓ Executable test passed
)

echo.
echo SUCCESS: Fixed Windows executable built!
echo.
echo Usage:
echo dist\minimal-synapse-windows.exe get syn123
echo dist\minimal-synapse-windows.exe store myfile.txt --parentid syn456

pause
Loading
Loading