Repository navigation
Expand file tree
/
Copy pathbuild.bat
More file actions
147 lines (137 loc) · 7.5 KB
/
Copy pathbuild.bat
File metadata and controls
147 lines (137 loc) · 7.5 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@echo off
setlocal enabledelayedexpansion
set "ROOT=%~dp0"
cd /d "%ROOT%"
rem --- Locate Visual Studio via vswhere -------------------------------------
rem NOTE 1: VS 18 (2026) is on a prerelease channel, so we need -all -prerelease.
rem -latest does NOT find it on this machine.
rem NOTE 2: we capture vswhere output via a temp file. A `for /f in (...)` over a
rem quoted path that contains "(x86)" breaks cmd parsing, so we avoid it.
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (echo [build] vswhere.exe not found & exit /b 1)
set "VSPATH="
"%VSWHERE%" -all -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath > "%TEMP%\_wind_vspath.txt"
set /p VSPATH=<"%TEMP%\_wind_vspath.txt"
del "%TEMP%\_wind_vspath.txt" >nul 2>&1
if "%VSPATH%"=="" (echo [build] VC tools not found. Install "Desktop development with C++". & exit /b 1)
rem vcvars64.bat emits a harmless internal "vswhere not recognized" on this box;
rem suppress its output and rely on the errorlevel + the cl check below.
call "%VSPATH%\VC\Auxiliary\Build\vcvars64.bat" >nul 2>&1
if errorlevel 1 (echo [build] vcvars64.bat failed & exit /b 1)
cd /d "%ROOT%"
if /i "%1"=="test" goto :test
if /i "%1"=="check" goto :check
if /i "%1"=="uiaccess" goto :uiaccess
if /i "%1"=="config" goto :config
if /i "%1"=="installer" goto :installer
if /i "%1"=="tray" goto :tray
rem --- App build (normal: uiAccess=false, runs from anywhere) ----------------
rem Compile the app-icon resource (rc.exe ships with the Windows SDK, on PATH via vcvars).
rc /nologo /fo "%ROOT%src\wind.res" "%ROOT%src\wind.rc"
if errorlevel 1 (echo [build] rc.exe failed & exit /b 1)
cl /nologo /std:c++17 /EHsc /O2 /W4 /Zi /DUNICODE /D_UNICODE ^
src\*.cpp src\config_ui\ini_edit.cpp src\wind.res ^
/Fe:Wind.exe ^
/link Magnification.lib Dwmapi.lib user32.lib shell32.lib gdi32.lib Dbghelp.lib ^
d3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib windowscodecs.lib ole32.lib oleaut32.lib uuid.lib advapi32.lib ^
/MANIFEST:EMBED /MANIFESTUAC:NO /MANIFESTINPUT:Wind.manifest /SUBSYSTEM:WINDOWS ^
/DEBUG /OPT:REF /OPT:ICF
if errorlevel 1 exit /b 1
call :tray_exe
exit /b %errorlevel%
rem --- UIAccess build (uiAccess=true: must be signed + run from Program Files) -
rem Embeds Wind.uiaccess.manifest so the overlay CAN use a high z-band (opt-in zorderBand=16)
rem to cover the Start menu / taskbar / tray. Shipped default is 0 - see issue #162.
rem Deploy via tools\uiaccess_setup.ps1.
:uiaccess
rc /nologo /fo "%ROOT%src\wind.res" "%ROOT%src\wind.rc"
if errorlevel 1 (echo [build] rc.exe failed & exit /b 1)
cl /nologo /std:c++17 /EHsc /O2 /W4 /Zi /DUNICODE /D_UNICODE /DWIND_UIACCESS ^
src\*.cpp src\config_ui\ini_edit.cpp src\wind.res ^
/Fe:Wind.exe ^
/link Magnification.lib Dwmapi.lib user32.lib shell32.lib gdi32.lib Dbghelp.lib ^
d3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib windowscodecs.lib ole32.lib oleaut32.lib uuid.lib advapi32.lib ^
/MANIFEST:EMBED /MANIFESTUAC:NO /MANIFESTINPUT:Wind.uiaccess.manifest /SUBSYSTEM:WINDOWS ^
/DEBUG /OPT:REF /OPT:ICF
if errorlevel 1 exit /b 1
call :tray_exe
exit /b %errorlevel%
rem --- Tray helper (WindTray.exe, issue #291). ALWAYS the plain manifest (asInvoker, NO uiAccess):
rem a UIAccess process's menu stacks above the cursor and the Snipping Tool overlay, which is the
rem whole reason the tray lives in its own process. Built by the app and uiaccess targets too.
:tray
call :tray_exe
exit /b %errorlevel%
:tray_exe
rc /nologo /fo "%ROOT%src\tray_app\wind_tray.res" "%ROOT%src\tray_app\wind_tray.rc"
if errorlevel 1 (echo [build] rc.exe failed for WindTray & exit /b 1)
rem Objects go to src\tray_app\ so the shared sources never overwrite Wind.exe's .obj files.
cl /nologo /std:c++17 /EHsc /O2 /W4 /Zi /DUNICODE /D_UNICODE ^
/Fo"%ROOT%src\tray_app\\" /Fd"%ROOT%WindTray.pdb" ^
src\tray_app\*.cpp src\tray_items.cpp src\profiles.cpp src\config.cpp src\logging.cpp src\config_ui\ini_edit.cpp ^
src\tray_app\wind_tray.res ^
/Fe:WindTray.exe ^
/link user32.lib shell32.lib gdi32.lib Dwmapi.lib Dbghelp.lib shlwapi.lib ole32.lib version.lib ^
advapi32.lib ntdll.lib ^
/MANIFEST:EMBED /MANIFESTUAC:NO /MANIFESTINPUT:Wind.manifest /SUBSYSTEM:WINDOWS ^
/DEBUG /OPT:REF /OPT:ICF
exit /b %errorlevel%
rem --- Config UI host (WindConfig.exe). Builds the Svelte UI first if it exists. ----
:config
if exist "%ROOT%ui\package.json" (
pushd "%ROOT%ui"
rem Explicit errorlevel checks: "call npm ... || (...)" does not reliably see npm.cmd's exit code,
rem and a failed UI build once shipped a stale ui\dist (#347).
if not exist node_modules call npm install
if errorlevel 1 (popd & echo [build] npm install failed & exit /b 1)
call npm run build
if errorlevel 1 (popd & echo [build] ui build failed & exit /b 1)
if not exist dist\index.html (popd & echo [build] ui build produced no dist\index.html & exit /b 1)
popd
)
rem Same app-icon resource as Wind.exe (rc.exe ships with the Windows SDK, on PATH via vcvars).
rc /nologo /fo "%ROOT%src\wind.res" "%ROOT%src\wind.rc"
if errorlevel 1 (echo [build] rc.exe failed & exit /b 1)
cl /nologo /std:c++17 /EHsc /O2 /W4 /DUNICODE /D_UNICODE ^
/I third_party\webview2\include ^
src\config_ui\main.cpp src\config_ui\ini_edit.cpp src\profiles.cpp src\config.cpp src\logging.cpp src\wind.res ^
/Fe:WindConfig.exe ^
/link third_party\webview2\x64\WebView2LoaderStatic.lib ^
user32.lib shell32.lib shlwapi.lib ole32.lib version.lib advapi32.lib ntdll.lib Dwmapi.lib /SUBSYSTEM:WINDOWS
exit /b %errorlevel%
rem --- Test build (pure-logic sources only; no <windows.h>) -----------------
:test
rem /wd5285 silences a known doctest 2.4.11 header warning under MSVC /W4.
cl /nologo /std:c++17 /EHsc /W4 /wd5285 /DWIND_TESTS /I third_party ^
tests\*.cpp ^
src\transform.cpp src\zoom_controller.cpp src\config.cpp src\profiles.cpp src\cursor_mapper.cpp src\lock_detector.cpp src\cursor_lock.cpp src\mouse_ballistics.cpp src\crosshair.cpp src\config_ui\ini_edit.cpp src\logging.cpp src\tray_items.cpp src\hitch_record.cpp ^
/Fe:wind_tests.exe
if errorlevel 1 exit /b 1
"%ROOT%wind_tests.exe"
exit /b %errorlevel%
rem --- Compile-only check (no link; verifies all sources compile) -----------
:check
cl /nologo /std:c++17 /EHsc /W4 /DUNICODE /D_UNICODE /c src\*.cpp
if errorlevel 1 exit /b 1
rem WindTray.exe sources (issue #291); own object dir, its main.cpp would overwrite Wind's main.obj.
cl /nologo /std:c++17 /EHsc /W4 /DUNICODE /D_UNICODE /c /Fo"%ROOT%src\tray_app\\" src\tray_app\*.cpp
exit /b %errorlevel%
rem --- Installer (needs NSIS; winget install NSIS.NSIS) ---------------------
:installer
set "MAKENSIS=%ProgramFiles(x86)%\NSIS\makensis.exe"
if not exist "%MAKENSIS%" set "MAKENSIS=%ProgramFiles%\NSIS\makensis.exe"
if not exist "%MAKENSIS%" (
echo [build] NSIS not found. Install it with: winget install NSIS.NSIS
exit /b 1
)
if not exist "%ROOT%dist" mkdir "%ROOT%dist"
rem /WX so a warning is a build failure. NSIS already aborts on a missing File source,
rem but it only WARNS about things like an unreferenced define or a shadowed function,
rem and in an installer those are how a page ends up wired to nothing.
"%MAKENSIS%" /WX /V2 "%ROOT%installer\wind.nsi"
if errorlevel 1 exit /b 1
rem The gate checks what a compile cannot: that every rectangle the pages read was
rem generated, and that a silent install/uninstall round-trips. Elevated-only parts
rem skip themselves from an ordinary shell.
powershell -NoProfile -ExecutionPolicy Bypass -File "%ROOT%tools\installer_check.ps1"
exit /b %errorlevel%