Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
95 changes: 95 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
@echo off
setlocal EnableDelayedExpansion
cd /d "%~dp0"

REM ─────────────────────────────────────────────────────────────────────────────
REM ScrcpyGUI — Windows build script
REM Requires: Node.js, npm, Rust (rustup), Tauri CLI (installed via npm)
REM Usage: double-click this file, or run it from any terminal.
REM ─────────────────────────────────────────────────────────────────────────────

REM ── 1. Inject Cargo into PATH for this session ───────────────────────────────
set "CARGO_BIN=%USERPROFILE%\.cargo\bin"
if exist "%CARGO_BIN%\cargo.exe" (
set "PATH=%CARGO_BIN%;%PATH%"
) else (
echo.
echo ERROR: Rust ^(cargo.exe^) was not found.
echo Expected location: %CARGO_BIN%
echo Install Rust from: https://rustup.rs
echo After installing, re-run this script.
echo.
pause
exit /b 1
)

REM ── 2. Verify required tools are reachable ───────────────────────────────────
echo Checking prerequisites...
for %%T in (node npm cargo) do (
where %%T >nul 2>&1
if !ERRORLEVEL! neq 0 (
echo [FAIL] %%T not found in PATH.
echo Install %%T and restart your terminal, then re-run this script.
pause
exit /b 1
)
echo [OK] %%T
)

REM ── 3. Install npm dependencies ──────────────────────────────────────────────
echo.
echo npm install...
call npm install
if !ERRORLEVEL! neq 0 (
echo.
echo ERROR: npm install failed ^(exit code !ERRORLEVEL!^).
pause
exit /b !ERRORLEVEL!
)

REM ── 4. Build with Tauri ───────────────────────────────────────────────────────
REM NOTE: Tauri's beforeBuildCommand in tauri.conf.json already runs
REM "npm run build" ^(tsc + Vite^) internally — no need to call it separately.
REM NOTE: First Rust compilation can take 5-15 minutes.
echo.
echo npm run tauri build...
echo ^(First Rust compilation may take 5-15 minutes — please wait.^)
echo.
call npm run tauri build
if !ERRORLEVEL! neq 0 (
echo.
echo ERROR: Tauri build failed ^(exit code !ERRORLEVEL!^).
echo Scroll up to read the Rust/Tauri compiler error.
pause
exit /b !ERRORLEVEL!
)

REM ── 5. Locate installer artifacts ────────────────────────────────────────────
set "NSIS_DIR=src-tauri\target\release\bundle\nsis"
set "MSI_DIR=src-tauri\target\release\bundle\msi"
set "FOUND=0"
echo.
echo Build succeeded. Checking for installer artifacts...

if exist "%NSIS_DIR%\*.exe" (
echo.
echo [NSIS installer]
for %%F in ("%NSIS_DIR%\*.exe") do echo %%~nxF --^> %NSIS_DIR%\%%~nxF
set "FOUND=1"
)
if exist "%MSI_DIR%\*.msi" (
echo.
echo [MSI installer]
for %%F in ("%MSI_DIR%\*.msi") do echo %%~nxF --^> %MSI_DIR%\%%~nxF
set "FOUND=1"
)
if "!FOUND!"=="0" (
echo No installer bundle found. Tauri may require NSIS or WiX Toolset.
echo - NSIS ^(free^): https://nsis.sourceforge.io/Download
echo - WiX Toolset ^(free^): https://wixtoolset.org/
echo.
echo Raw portable binary: src-tauri\target\release\scrcpy-gui-v4.exe
)

echo.
pause
115 changes: 115 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#Requires -Version 5.1
<#
.SYNOPSIS
Builds ScrcpyGUI via Tauri and produces a Windows installer bundle.
.DESCRIPTION
- Ensures Rust/Cargo is on PATH (rustup default location).
- Validates node, npm, and cargo before starting.
- Runs: npm install → npm run tauri build
(Tauri's beforeBuildCommand in tauri.conf.json runs the Vite frontend build automatically.)
- Saves full output to build.log in the project root.
- Pauses with a clear message on any failure.
#>

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

# ── Paths ─────────────────────────────────────────────────────────────────────
$Root = $PSScriptRoot
$LogFile = Join-Path $Root 'build.log'
$BundleDir = Join-Path $Root 'src-tauri\target\release\bundle\windows'

# ── Logging ───────────────────────────────────────────────────────────────────
'' | Set-Content $LogFile # truncate / create
function Log {
param([string]$Msg, [ConsoleColor]$Color = 'Cyan')
$line = "[$(Get-Date -Format 'HH:mm:ss')] $Msg"
Write-Host $line -ForegroundColor $Color
Add-Content -Path $LogFile -Value $line
}

function Fail {
param([string]$Msg)
Log "ERROR: $Msg" -Color Red
Log "Full log saved to: $LogFile" -Color Yellow
Write-Host ''
Write-Host 'Press Enter to close...' -ForegroundColor Yellow
$null = Read-Host
exit 1
}

# ── Ensure Cargo is on PATH ───────────────────────────────────────────────────
$CargoBin = Join-Path $env:USERPROFILE '.cargo\bin'
if (Test-Path (Join-Path $CargoBin 'cargo.exe')) {
if ($env:PATH -notlike "*$CargoBin*") {
$env:PATH = "$CargoBin;$env:PATH"
Log "Added $CargoBin to PATH for this session."
}
} else {
Fail "Rust/Cargo not found at $CargoBin.`nInstall Rust from: https://rustup.rs"
}

# ── Verify required tools ─────────────────────────────────────────────────────
Log '── Checking prerequisites ──────────────────────────────────────'
foreach ($tool in @('node', 'npm', 'cargo')) {
$cmd = Get-Command $tool -ErrorAction SilentlyContinue
if ($cmd) {
$ver = & $tool --version 2>&1
Log " $tool → $($cmd.Source) ($($ver -replace "`n",''))"
} else {
Fail "$tool not found in PATH. Ensure it is installed and restart VS Code."
}
}

# ── Change into project root ──────────────────────────────────────────────────
Set-Location $Root

# ── npm install ───────────────────────────────────────────────────────────────
Log ''
Log '── npm install ─────────────────────────────────────────────────'
& npm install 2>&1 | Tee-Object -FilePath $LogFile -Append
if ($LASTEXITCODE -ne 0) {
Fail "npm install failed (exit code $LASTEXITCODE). See $LogFile for details."
}

# ── Tauri build ───────────────────────────────────────────────────────────────
# Tauri's beforeBuildCommand ("npm run build") runs tsc + vite automatically.
# No need to run "npm run build" separately.
Log ''
Log '── npm run tauri build ──────────────────────────────────────────'
Log ' (this compiles Rust + bundles the frontend — first run takes 5-15 min)'
& npm run tauri build 2>&1 | Tee-Object -FilePath $LogFile -Append
if ($LASTEXITCODE -ne 0) {
Fail "tauri build failed (exit code $LASTEXITCODE). See $LogFile for details."
}

# ── Locate artifacts ──────────────────────────────────────────────────────────
Log ''
Log '── Build complete — locating installer artifacts ────────────────' -Color Green

if (Test-Path $BundleDir) {
$exes = @(Get-ChildItem $BundleDir -Filter '*.exe' -ErrorAction SilentlyContinue)
$msis = @(Get-ChildItem $BundleDir -Filter '*.msi' -ErrorAction SilentlyContinue)

if ($exes.Count -gt 0) {
Log " Installer EXE(s) in $BundleDir :" -Color Green
$exes | ForEach-Object { Log " $($_.Name) ($([math]::Round($_.Length/1MB,1)) MB)" -Color Green }
}
if ($msis.Count -gt 0) {
Log " MSI(s) in $BundleDir :" -Color Green
$msis | ForEach-Object { Log " $($_.Name) ($([math]::Round($_.Length/1MB,1)) MB)" -Color Green }
}
if ($exes.Count -eq 0 -and $msis.Count -eq 0) {
Log " No installer found in $BundleDir" -Color Yellow
Log " The app binary is at: src-tauri\target\release\scrcpy-gui-v4.exe" -Color Yellow
}
} else {
Log " Bundle directory not found: $BundleDir" -Color Yellow
Log " The app binary may be at: src-tauri\target\release\scrcpy-gui-v4.exe" -Color Yellow
}

Log ''
Log "Full build log saved to: $LogFile" -Color Green
Write-Host ''
Write-Host 'Press Enter to close...' -ForegroundColor Cyan
$null = Read-Host
15 changes: 15 additions & 0 deletions build_Portable.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off
REM Build ScrcpyGUI and generate a Windows executable bundle.
cd /d "%~dp0"

echo Installing npm dependencies...
call npm install
if errorlevel 1 exit /b %errorlevel%

echo Building the application with Tauri...
call npm run tauri build
if errorlevel 1 exit /b %errorlevel%

echo Build complete.
echo Output bundle should be available under src-tauri\target\release\bundle\windows
pause
14 changes: 7 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@

desktopItems = [
(pkgs.makeDesktopItem {
name = "scrcpy-gui-v3";
exec = "scrcpy-gui-v3";
icon = "scrcpy-gui-v3";
name = "scrcpy-gui-v4";
exec = "scrcpy-gui-v4";
icon = "scrcpy-gui-v4";
desktopName = "ScrcpyGUI";
comment = "A modern GUI for Scrcpy written in React and Rust";
categories = [
Expand All @@ -97,15 +97,15 @@
postInstall = ''
# Install the standard sized icons
for size in 32 64 128; do
install -Dm644 icons/''${size}x''${size}.png $out/share/icons/hicolor/''${size}x''${size}/apps/scrcpy-gui-v3.png
install -Dm644 icons/''${size}x''${size}.png $out/share/icons/hicolor/''${size}x''${size}/apps/scrcpy-gui-v4.png
done

# Install high-resolution icons for GNOME/modern desktops
install -Dm644 icons/128x128@2x.png $out/share/icons/hicolor/256x256/apps/scrcpy-gui-v3.png
install -Dm644 icons/icon.png $out/share/icons/hicolor/512x512/apps/scrcpy-gui-v3.png
install -Dm644 icons/128x128@2x.png $out/share/icons/hicolor/256x256/apps/scrcpy-gui-v4.png
install -Dm644 icons/icon.png $out/share/icons/hicolor/512x512/apps/scrcpy-gui-v4.png

# Install a fallback pixmap just in case
install -Dm644 icons/icon.png $out/share/pixmaps/scrcpy-gui-v3.png
install -Dm644 icons/icon.png $out/share/pixmaps/scrcpy-gui-v4.png
'';

preFixup = ''
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "scrcpy-gui-v3",
"name": "scrcpy-gui-v4",
"private": true,
"version": "4.0.1",
"type": "module",
Expand Down
Loading