159 lines
3.4 KiB
Batchfile
159 lines
3.4 KiB
Batchfile
@echo off
|
|
REM PSK-Proxy-Tunnel Build Script for Windows
|
|
REM This script builds single executable binaries for Windows
|
|
|
|
setlocal enabledelayedexpansion
|
|
|
|
REM Colors for output (Windows 10+ supports ANSI colors)
|
|
set "RED=[91m"
|
|
set "GREEN=[92m"
|
|
set "YELLOW=[93m"
|
|
set "BLUE=[94m"
|
|
set "NC=[0m"
|
|
|
|
REM Function to print colored output
|
|
:print_status
|
|
echo %BLUE%[INFO]%NC% %~1
|
|
goto :eof
|
|
|
|
:print_success
|
|
echo %GREEN%[SUCCESS]%NC% %~1
|
|
goto :eof
|
|
|
|
:print_warning
|
|
echo %YELLOW%[WARNING]%NC% %~1
|
|
goto :eof
|
|
|
|
:print_error
|
|
echo %RED%[ERROR]%NC% %~1
|
|
goto :eof
|
|
|
|
REM Function to check if command exists
|
|
:command_exists
|
|
where %1 >nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
exit /b 0
|
|
) else (
|
|
exit /b 1
|
|
)
|
|
|
|
REM Function to show help
|
|
:show_help
|
|
echo PSK-Proxy-Tunnel Build Script for Windows
|
|
echo.
|
|
echo Usage: %0 [OPTIONS]
|
|
echo.
|
|
echo Options:
|
|
echo --windows Build for Windows (default)
|
|
echo --all Build for all platforms
|
|
echo --clean Clean build artifacts
|
|
echo --help Show this help message
|
|
echo.
|
|
echo Examples:
|
|
echo %0 --windows Build for Windows only
|
|
echo %0 --all Build for all platforms
|
|
echo %0 --clean Clean build artifacts
|
|
echo.
|
|
goto :eof
|
|
|
|
REM Function to clean build artifacts
|
|
:clean_build
|
|
call :print_status "Cleaning build artifacts..."
|
|
call npm run clean
|
|
if %errorlevel% equ 0 (
|
|
call :print_success "Build artifacts cleaned"
|
|
) else (
|
|
call :print_error "Failed to clean build artifacts"
|
|
)
|
|
goto :eof
|
|
|
|
REM Function to build for Windows
|
|
:build_windows
|
|
call :print_status "Building for Windows..."
|
|
call npm run prebuild
|
|
call npm run build:windows
|
|
if %errorlevel% equ 0 (
|
|
call :print_success "Build completed for Windows"
|
|
) else (
|
|
call :print_error "Build failed for Windows"
|
|
)
|
|
goto :eof
|
|
|
|
REM Function to build for all platforms
|
|
:build_all
|
|
call :print_status "Building for all platforms..."
|
|
call npm run build
|
|
if %errorlevel% equ 0 (
|
|
call :print_success "Build completed for all platforms"
|
|
) else (
|
|
call :print_error "Build failed for all platforms"
|
|
)
|
|
goto :eof
|
|
|
|
REM Main script logic
|
|
:main
|
|
REM Check if we're in the right directory
|
|
if not exist "package.json" (
|
|
call :print_error "package.json not found. Please run this script from the project root directory."
|
|
exit /b 1
|
|
)
|
|
|
|
REM Check if Node.js is installed
|
|
call :command_exists node
|
|
if %errorlevel% neq 0 (
|
|
call :print_error "Node.js is not installed. Please install Node.js first."
|
|
exit /b 1
|
|
)
|
|
|
|
REM Check if npm is installed
|
|
call :command_exists npm
|
|
if %errorlevel% neq 0 (
|
|
call :print_error "npm is not installed. Please install npm first."
|
|
exit /b 1
|
|
)
|
|
|
|
REM Install dependencies if node_modules doesn't exist
|
|
if not exist "node_modules" (
|
|
call :print_status "Installing dependencies..."
|
|
call npm install
|
|
if %errorlevel% equ 0 (
|
|
call :print_success "Dependencies installed"
|
|
) else (
|
|
call :print_error "Failed to install dependencies"
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
REM Parse command line arguments
|
|
if "%1"=="" (
|
|
REM No arguments provided, build for Windows
|
|
call :build_windows
|
|
goto :eof
|
|
)
|
|
|
|
:parse_args
|
|
if "%1"=="--windows" (
|
|
call :build_windows
|
|
shift
|
|
goto :parse_args
|
|
) else if "%1"=="--all" (
|
|
call :build_all
|
|
shift
|
|
goto :parse_args
|
|
) else if "%1"=="--clean" (
|
|
call :clean_build
|
|
shift
|
|
goto :parse_args
|
|
) else if "%1"=="--help" (
|
|
call :show_help
|
|
exit /b 0
|
|
) else if "%1"=="" (
|
|
goto :eof
|
|
) else (
|
|
call :print_error "Unknown option: %1"
|
|
call :show_help
|
|
exit /b 1
|
|
)
|
|
|
|
goto :parse_args
|