-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
90 lines (76 loc) · 3.79 KB
/
build.bat
File metadata and controls
90 lines (76 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@echo off
setlocal enabledelayedexpansion
:: Anchor everything to the folder this batch file lives in
pushd "%~dp0"
set ROOT=%CD%
title SpaceMouse Pilot — Build
echo.
echo ============================================
echo SpaceMouse Pilot — Build Script
echo Root: %ROOT%
echo ============================================
echo.
:: ── version ───────────────────────────────────────────────────────────────────
for /f %%v in ('python -c "from src.version import VERSION; print(VERSION)"') do set SPACEMOUSE_VERSION=%%v
if "%SPACEMOUSE_VERSION%"=="" (
echo ERROR: Could not read version from src\version.py
goto :fail
)
echo [version] %SPACEMOUSE_VERSION%
echo [1/5] Checking Python...
python --version >nul 2>&1
if errorlevel 1 (
echo ERROR: Python not found. Install 3.10+ from https://www.python.org/
goto :fail
)
:: ── 2. Dependencies ───────────────────────────────────────────────────────────
echo [2/5] Installing / updating Python packages...
python -m pip install --upgrade pip --quiet
python -m pip install -r "%ROOT%\requirements.txt" --quiet
python -m pip install pyinstaller --quiet
if errorlevel 1 ( echo ERROR: pip install failed. & goto :fail )
:: ── 2.5 hidapi.dll ────────────────────────────────────────────────────────────
echo [2.5/5] Ensuring hidapi.dll...
python "%ROOT%\tools\fetch_hidapi.py"
if errorlevel 1 ( echo ERROR: Failed to fetch hidapi.dll. & goto :fail )
:: ── 3. Icon ───────────────────────────────────────────────────────────────────
echo [3/5] Generating icon...
python "%ROOT%\tools\generate_icon.py"
if errorlevel 1 ( echo ERROR: Icon generation failed. & goto :fail )
:: ── 4. PyInstaller ────────────────────────────────────────────────────────────
echo [4/5] Bundling with PyInstaller...
if exist "%ROOT%\dist\SpaceMousePilot" rmdir /s /q "%ROOT%\dist\SpaceMousePilot"
python -m PyInstaller "%ROOT%\spacemouse_pilot.spec" --noconfirm
if errorlevel 1 ( echo ERROR: PyInstaller failed. Check output above. & goto :fail )
:: ── 5. Inno Setup ─────────────────────────────────────────────────────────────
echo [5/5] Compiling installer...
set ISCC=
if exist "%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe" set "ISCC=%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe"
if exist "%ProgramFiles%\Inno Setup 6\ISCC.exe" set "ISCC=%ProgramFiles%\Inno Setup 6\ISCC.exe"
if "%ISCC%"=="" (
echo WARNING: Inno Setup not found — skipping installer step.
echo Download from https://jrsoftware.org/isinfo.php
goto :done
)
mkdir "%ROOT%\dist\installer" 2>nul
"%ISCC%" "%ROOT%\installer\spacemouse_pilot.iss"
if errorlevel 1 ( echo ERROR: Inno Setup compilation failed. & goto :fail )
:done
echo.
echo ============================================
echo Build complete!
echo.
echo EXE: %ROOT%\dist\SpaceMousePilot\SpaceMousePilot.exe
if exist "%ROOT%\dist\installer" echo Installer: %ROOT%\dist\installer\SpaceMousePilot_Setup_%SPACEMOUSE_VERSION%.exe
echo ============================================
echo.
popd
pause
exit /b 0
:fail
echo.
echo Build failed. See errors above.
echo.
popd
pause
exit /b 1