Skip to content

Commit 3529562

Browse files
committed
Add build scripts for minimal Synapse CLI and interactive commands
1 parent 02d3b38 commit 3529562

File tree

3 files changed

+598
-0
lines changed

3 files changed

+598
-0
lines changed

build.sh

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/bash
2+
3+
# Build script for minimal Synapse CLI
4+
# This script creates cross-platform binaries using PyInstaller
5+
# Usage: ./build.sh [platform]
6+
# Platforms: linux, macos, windows, all
7+
8+
set -e
9+
10+
# Default to current platform if no argument provided
11+
TARGET_PLATFORM=${1:-"auto"}
12+
13+
echo "Building Minimal Synapse CLI..."
14+
15+
# Install required packages
16+
echo "Installing required packages..."
17+
uv pip install pyinstaller
18+
uv pip install -e .
19+
20+
# Clean previous builds
21+
echo "Cleaning previous builds..."
22+
rm -rf build/ dist/ *.spec
23+
24+
# Function to build for a specific platform
25+
build_for_platform() {
26+
local platform=$1
27+
local extension=$2
28+
local extra_args=$3
29+
30+
echo "Building for platform: $platform"
31+
local output_name="minimal-synapse-${platform}${extension}"
32+
33+
echo "Building executable: $output_name"
34+
35+
# Build the executable with simplified PyInstaller command (following Windows approach)
36+
pyinstaller \
37+
--onefile \
38+
--name "$output_name" \
39+
--collect-all=synapseclient \
40+
--console \
41+
$extra_args \
42+
minimal_synapse_cli.py
43+
44+
# Clean up spec file
45+
rm -f *.spec
46+
47+
if [ -f "dist/$output_name" ]; then
48+
echo "✓ Build successful: dist/$output_name"
49+
echo "File size: $(du -h dist/$output_name | cut -f1)"
50+
51+
# Test the executable
52+
echo "Testing executable..."
53+
if ./dist/$output_name --help > /dev/null 2>&1; then
54+
echo "✓ Executable test passed"
55+
else
56+
echo "✗ Executable test failed"
57+
return 1
58+
fi
59+
else
60+
echo "✗ Build failed: dist/$output_name not found"
61+
return 1
62+
fi
63+
}
64+
65+
# Determine what to build
66+
case "$TARGET_PLATFORM" in
67+
"auto")
68+
# Auto-detect current platform
69+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
70+
build_for_platform "linux" ""
71+
elif [[ "$OSTYPE" == "darwin"* ]]; then
72+
build_for_platform "macos" ""
73+
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
74+
build_for_platform "windows" ".exe"
75+
else
76+
echo "Unknown platform: $OSTYPE"
77+
echo "Please specify platform: linux, macos, windows, or all"
78+
exit 1
79+
fi
80+
;;
81+
"linux")
82+
build_for_platform "linux" ""
83+
;;
84+
"macos")
85+
build_for_platform "macos" ""
86+
;;
87+
"windows")
88+
build_for_platform "windows" ".exe"
89+
;;
90+
"all")
91+
echo "Building for all platforms..."
92+
build_for_platform "linux" ""
93+
build_for_platform "macos" ""
94+
build_for_platform "windows" ".exe"
95+
;;
96+
*)
97+
echo "Unknown platform: $TARGET_PLATFORM"
98+
echo "Available platforms: linux, macos, windows, all"
99+
exit 1
100+
;;
101+
esac
102+
103+
echo ""
104+
echo "Build(s) complete!"
105+
echo ""
106+
echo "Available executables:"
107+
ls -la dist/minimal-synapse-* 2>/dev/null || echo "No executables found"
108+
109+
echo ""
110+
echo "Usage examples:"
111+
if [ -f "dist/minimal-synapse-linux" ]; then
112+
echo " ./dist/minimal-synapse-linux get syn123"
113+
echo " ./dist/minimal-synapse-linux store myfile.txt --parentid syn456"
114+
fi
115+
if [ -f "dist/minimal-synapse-macos" ]; then
116+
echo " ./dist/minimal-synapse-macos get syn123"
117+
echo " ./dist/minimal-synapse-macos store myfile.txt --parentid syn456"
118+
fi
119+
if [ -f "dist/minimal-synapse-windows.exe" ]; then
120+
echo " ./dist/minimal-synapse-windows.exe get syn123"
121+
echo " ./dist/minimal-synapse-windows.exe store myfile.txt --parentid syn456"
122+
fi
123+
124+
echo ""
125+
echo "To install system-wide (Linux/macOS):"
126+
echo " sudo cp dist/minimal-synapse-linux /usr/local/bin/synapse-cli"
127+
echo " sudo cp dist/minimal-synapse-macos /usr/local/bin/synapse-cli"
128+
echo ""
129+
echo "Cross-platform build notes:"
130+
echo "- Linux binary: Works on most Linux distributions"
131+
echo "- macOS binary: Requires macOS to build, works on macOS 10.15+"
132+
echo "- Windows binary: Built with simplified approach following Windows native script"

build_windows_native.bat

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@echo off
2+
REM Fixed Windows build script using the patched CLI script
3+
REM This version pre-loads all dependencies before synapseclient import
4+
5+
echo Building Minimal Synapse CLI for Windows (fixed version)...
6+
7+
REM Install required packages
8+
echo Installing required packages...
9+
call .venv\Scripts\activate
10+
uv pip install pyinstaller
11+
uv pip install -e .
12+
13+
if errorlevel 1 (
14+
echo ERROR: Failed to install dependencies
15+
exit /b 1
16+
)
17+
18+
REM Clean previous builds
19+
echo Cleaning previous builds...
20+
if exist build rmdir /s /q build
21+
if exist dist rmdir /s /q dist
22+
if exist *.spec del *.spec
23+
24+
echo Building Windows executable (fixed version)...
25+
26+
REM Build using the fixed CLI script
27+
pyinstaller ^
28+
--onefile ^
29+
--name "minimal-synapse-windows.exe" ^
30+
--collect-all=synapseclient ^
31+
--console ^
32+
minimal_synapse_cli.py
33+
34+
if errorlevel 1 (
35+
echo ERROR: Build failed
36+
exit /b 1
37+
)
38+
39+
echo Build complete!
40+
echo Executable location: dist\minimal-synapse-windows.exe
41+
42+
REM Show file size
43+
for %%I in (dist\minimal-synapse-windows.exe) do echo File size: %%~zI bytes
44+
45+
REM Test the executable
46+
echo Testing executable...
47+
dist\minimal-synapse-windows.exe --help
48+
if errorlevel 1 (
49+
echo ✗ Executable test failed
50+
exit /b 1
51+
) else (
52+
echo ✓ Executable test passed
53+
)
54+
55+
echo.
56+
echo SUCCESS: Fixed Windows executable built!
57+
echo.
58+
echo Usage:
59+
echo dist\minimal-synapse-windows.exe get syn123
60+
echo dist\minimal-synapse-windows.exe store myfile.txt --parentid syn456
61+
62+
pause

0 commit comments

Comments
 (0)