-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathbuild-windows.bat
More file actions
229 lines (204 loc) · 8.43 KB
/
build-windows.bat
File metadata and controls
229 lines (204 loc) · 8.43 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
@echo off
setlocal enabledelayedexpansion
echo.
echo =======================================
echo Probe Windows Build Script
echo =======================================
echo.
set "BUILD_LOG=%TEMP%\probe-build-windows.log"
echo Probe Windows Build Started at %date% %time% > "%BUILD_LOG%"
:: Set script directory and repo root
set "SCRIPT_DIR=%~dp0"
set "REPO_ROOT=%SCRIPT_DIR%"
cd /d "%REPO_ROOT%"
echo [1/5] Checking prerequisites...
echo [1/5] Checking prerequisites... >> "%BUILD_LOG%"
:: Check for Rust installation
echo - Checking for Rust installation...
where /q rustc
if %ERRORLEVEL% neq 0 (
echo [ERROR] Rust is not installed or not in PATH >> "%BUILD_LOG%"
echo [ERROR] Rust is not installed or not in PATH.
echo Please install Rust from https://www.rust-lang.org/tools/install
echo Run the following command in your browser:
echo https://static.rust-lang.org/rustup/rustup-init.exe
exit /b 1
) else (
rustc --version >> "%BUILD_LOG%" 2>&1
echo - Rust is installed: !ERRORLEVEL!
)
:: Check for MSYS2 installation
echo - Checking for MSYS2 installation...
if exist "C:\msys64\usr\bin\bash.exe" (
echo - MSYS2 is installed.
echo MSYS2 is installed >> "%BUILD_LOG%"
) else (
echo - [WARNING] MSYS2 does not appear to be installed at the default location.
echo - This is required for GCC compiler toolchain.
echo - Install MSYS2 using Windows Package Manager:
echo - winget install MSYS2.MSYS2
echo - Then install MinGW toolchain by running:
echo - pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
echo - And add C:\msys64\ucrt64\bin to your PATH
echo MSYS2 might not be installed >> "%BUILD_LOG%"
)
:: Check if GCC is available
echo - Checking for GCC compiler...
where /q gcc
if %ERRORLEVEL% neq 0 (
echo - [WARNING] GCC compiler not found in PATH.
echo - If you encounter build errors related to 'gcc.exe', you will need to:
echo - 1. Ensure MSYS2 is installed: winget install MSYS2.MSYS2
echo - 2. Open MSYS2 MSYS shell from Start Menu
echo - 3. Run: pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
echo - 4. Add C:\msys64\ucrt64\bin to your system PATH
echo GCC not found in PATH >> "%BUILD_LOG%"
) else (
gcc --version >> "%BUILD_LOG%" 2>&1
echo - GCC compiler found: !ERRORLEVEL!
)
:: Check for Visual Studio Build Tools
echo - Checking for Visual Studio 2022 C++ Build Tools...
reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "17.0" >nul 2>&1
set VS2022_INSTALLED=%ERRORLEVEL%
reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7" /v "17.0" >nul 2>&1
set VS2022_INSTALLED_WOW=%ERRORLEVEL%
reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7" /v "17.0" >nul 2>&1
set VS2022_VC_INSTALLED=%ERRORLEVEL%
if %VS2022_INSTALLED% equ 0 (
echo - Visual Studio 2022 is installed.
echo VS2022 is installed >> "%BUILD_LOG%"
) else if %VS2022_INSTALLED_WOW% equ 0 (
echo - Visual Studio 2022 is installed (WOW64).
echo VS2022 is installed (WOW64) >> "%BUILD_LOG%"
) else if %VS2022_VC_INSTALLED% equ 0 (
echo - Visual Studio 2022 C++ components are installed.
echo VS2022 C++ components are installed >> "%BUILD_LOG%"
) else (
echo - [WARNING] Visual Studio 2022 Build Tools might not be installed.
echo - This could cause compilation issues with some dependencies.
echo - Download and install Build Tools from:
echo - https://visualstudio.microsoft.com/visual-cpp-build-tools/
echo - Be sure to select "Desktop development with C++" workload.
echo VS2022 Build Tools might not be installed >> "%BUILD_LOG%"
)
:: Check for MSVC installation
echo - Checking for Microsoft Visual C++ Redistributable...
reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" /v Version >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo - Microsoft Visual C++ Redistributable is installed.
echo MSVC is installed >> "%BUILD_LOG%"
) else (
reg query "HKLM\SOFTWARE\Classes\Installer\Dependencies\VC,redist.x64,amd64,14.29,bundle" /v Version >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo - Microsoft Visual C++ Redistributable is installed.
echo MSVC is installed (alternate registry key) >> "%BUILD_LOG%"
) else (
echo - [WARNING] Microsoft Visual C++ Redistributable might not be installed.
echo - The build can proceed, but the binary may not run without installing:
echo - https://aka.ms/vs/17/release/vc_redist.x64.exe
echo MSVC might not be installed, but continuing build >> "%BUILD_LOG%"
)
)
echo.
echo [2/5] Cleaning previous build...
echo [2/5] Cleaning previous build... >> "%BUILD_LOG%"
cargo clean
if %ERRORLEVEL% neq 0 (
echo [ERROR] Failed to clean project >> "%BUILD_LOG%"
echo [ERROR] Failed to clean project. See build log for details: "%BUILD_LOG%"
exit /b 1
)
echo.
echo [3/5] Building Probe with Windows-optimized settings...
echo [3/5] Building Probe with Windows-optimized settings... >> "%BUILD_LOG%"
echo - This may take a few minutes...
echo.
:: Build with release settings
cargo build --release >> "%BUILD_LOG%" 2>&1
set BUILD_ERROR=%ERRORLEVEL%
if %BUILD_ERROR% neq 0 (
echo [ERROR] Build failed with code %BUILD_ERROR%. >> "%BUILD_LOG%"
echo [ERROR] Build failed with code %BUILD_ERROR%.
:: Check for specific error patterns in the log
findstr /C:"failed to find tool \"gcc.exe\"" "%BUILD_LOG%" >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo.
echo [ERROR DETAILS] Missing GCC compiler.
echo.
echo This error occurs because the C/C++ compiler toolchain is missing.
echo To fix this:
echo.
echo 1. Install MSYS2 using Windows Package Manager:
echo winget install MSYS2.MSYS2
echo.
echo 2. Open the "MSYS2 MSYS2" shortcut from the Start Menu
echo.
echo 3. Install the MinGW-w64 toolchain by running:
echo pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
echo.
echo 4. Add the compiler to your PATH:
echo - Open Windows Settings ^> System ^> About ^> Advanced system settings
echo - Click on "Environment Variables"
echo - Edit the "Path" variable under either User or System variables
echo - Add C:\msys64\ucrt64\bin to the list
echo - Click OK and close all dialogs
echo.
echo 5. Restart your terminal/PowerShell and run this script again
echo.
) else (
findstr /C:"requires nightly" "%BUILD_LOG%" >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo [ERROR DETAILS] This project requires the nightly Rust toolchain.
echo To fix this, run:
echo.
echo rustup install nightly
echo rustup default nightly
echo.
echo Then run this script again.
) else (
echo See build log for details: "%BUILD_LOG%"
)
)
exit /b 1
)
echo.
echo [4/5] Verifying build...
echo [4/5] Verifying build... >> "%BUILD_LOG%"
:: Check if executable exists
if not exist "target\release\probe.exe" (
echo [ERROR] Build completed but executable not found >> "%BUILD_LOG%"
echo [ERROR] Build completed but executable not found at target\release\probe.exe
exit /b 1
)
echo - Executable created successfully at target\release\probe.exe
echo - Executable created successfully >> "%BUILD_LOG%"
echo.
echo [5/5] Testing executable...
echo [5/5] Testing executable... >> "%BUILD_LOG%"
:: Test if executable runs
target\release\probe.exe --help > nul 2>&1
if %ERRORLEVEL% neq 0 (
echo [WARNING] Executable built but test run failed. You may need to install: >> "%BUILD_LOG%"
echo [WARNING] Executable built but test run failed.
echo This may be due to missing Microsoft Visual C++ Redistributable.
echo Please install it from: https://aka.ms/vs/17/release/vc_redist.x64.exe
) else (
echo - Executable test successful
echo - Executable test successful >> "%BUILD_LOG%"
)
echo.
echo =======================================
echo Build completed successfully!
echo =======================================
echo.
echo The probe executable is available at:
echo %REPO_ROOT%target\release\probe.exe
echo.
echo Build log saved to: "%BUILD_LOG%"
echo.
echo Next steps:
echo - Run: .\target\release\probe.exe search "query" path\to\search
echo - Start MCP server: cd mcp ^&^& npm run build ^&^& node build\index.js
echo.
endlocal