-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-30687: Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat #2252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6cf00ec
8f884e6
0e911fa
6ed6279
7012dcc
6f04251
8d2d7dc
502a337
1506793
c701a70
277410d
324cc5c
bae2ad2
f169ae4
3194ce5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@rem | ||
@rem Searches for MSBuild.exe. This is the only tool we need to initiate | ||
@rem a build, so we no longer search for the full VC toolset. | ||
@rem | ||
@rem This file is supposed to modify the state of the caller (specifically | ||
@rem the MSBUILD variable), so we do not use setlocal or echo, and avoid | ||
@rem changing any other persistent state. | ||
@rem | ||
|
||
@rem No arguments provided means do full search | ||
@if '%1' EQU '' goto :begin_search | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work, or should these be double quotes? I've been bitten by trying to use single quotes in batch files a couple of times, but I'm not convinced that I actually understand the quoting rules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The quoting rules are horrible here, because I want to handle where users have done:
Which breaks in a whole lot of ridiculous ways. Using single quotes here at least handles the two sane cases without causing syntax errors. |
||
|
||
@rem One argument may be the full path. Use a goto so we don't try to | ||
@rem parse the next if statement - incorrect quoting in the multi-arg | ||
@rem case can cause us to break immediately. | ||
@if '%2' EQU '' goto :one_arg | ||
|
||
@rem Entire command line may represent the full path if quoting failed. | ||
@if exist "%*" (set MSBUILD="%*") & (set _Py_MSBuild_Source=environment) & goto :found | ||
@goto :begin_search | ||
|
||
:one_arg | ||
@if exist "%~1" (set MSBUILD="%~1") & (set _Py_MSBuild_Source=environment) & goto :found | ||
|
||
:begin_search | ||
@set MSBUILD= | ||
|
||
@rem If msbuild.exe is on the PATH, assume that the user wants that one. | ||
@where msbuild > "%TEMP%\msbuild.loc" 2> nul && set /P MSBUILD= < "%TEMP%\msbuild.loc" & del "%TEMP%\msbuild.loc" | ||
@if exist "%MSBUILD%" set MSBUILD="%MSBUILD%" & (set _Py_MSBuild_Source=PATH) & goto :found | ||
|
||
@rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there. | ||
@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32 >nul 2>nul | ||
@if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO @( | ||
@if "%%i"=="15.0" @if exist "%%k\MSBuild\15.0\Bin\msbuild.exe" @(set MSBUILD="%%k\MSBuild\15.0\Bin\msbuild.exe") | ||
) | ||
@if exist %MSBUILD% (set _Py_MSBuild_Source=Visual Studio 2017 registry) & goto :found | ||
|
||
@rem VS 2015 and earlier register MSBuild separately, so we can find it. | ||
@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath /reg:32 >nul 2>nul | ||
@if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath /reg:32') DO @( | ||
@if "%%i"=="MSBuildToolsPath" @if exist "%%k\msbuild.exe" @(set MSBUILD="%%k\msbuild.exe") | ||
) | ||
@if exist %MSBUILD% (set _Py_MSBuild_Source=registry) & goto :found | ||
|
||
|
||
@exit /b 1 | ||
|
||
:found | ||
@echo Using %MSBUILD% (found in the %_Py_MSBuild_Source%) | ||
@set _Py_MSBuild_Source= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
vs_platf
go away entirely now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sure can!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then I think the cross-compilation for PGO warning has to go away too... not sure of the full impact there yet, let me try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't; the
vs_platf
stuff just gets removed from around it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are some missing environment pieces, but I can add those into
python.bat
on build. Looks like that's how we launch for PGO build anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean about keeping the warning in there. I'll bring that back