Improve error message when cl.exe is missing on Windows (#21120)

This commit is contained in:
Samrendra Pratap Singh 2025-04-01 04:45:15 +05:30 committed by GitHub
parent bd670444c7
commit 869266c2ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -120,6 +120,12 @@ private const(char)[] cppCommand()
VSOptions vsopt;
vsopt.initialize();
const path = vsopt.compilerPath(target.isX86_64);
//if the path to cl.exe is found, check if cl.exe is in the path.
if(FileName.exists(path) != 1)
{
error(Loc.initial, "cl.exe not found. Please ensure that Visual Studio Build Tools are installed and properly configured.");
fatal();
}
return toDString(path);
}
// Perhaps we are cross-compiling.

View file

@ -191,7 +191,7 @@ extern(C++) struct VSOptions
* Params:
* x64 = target architecture (x86 if false)
* Returns:
* absolute path to cl.exe, just "cl.exe" if not found
* absolute path to cl.exe, and just "cl.exe" if not found
*/
const(char)* compilerPath(bool x64)
{