Skip to content

Commit

Permalink
Build script fixes:
Browse files Browse the repository at this point in the history
- ensure all variables are defined, supports Mesa quick rebuilds;
- properly load VS2015 fallback environment with VS2017. It was working just because we were lucky.
  • Loading branch information
prodea2 committed Mar 25, 2017
1 parent 5bd88bb commit d62bec5
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions buildscript/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
@if %abi%==x64 set minabi=64
@set vsenv=%ProgramFiles%
@if NOT "%ProgramW6432%"=="" set vsenv=%vsenv% (x86)
@set vsenv=%vsenv%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars%minabi%.bat
@if EXIST "%vsenv%" @set toolchain=Visual Studio 15 2017
@if NOT EXIST "%vsenv%" @set toolchain=Visual Studio 14
@if NOT EXIST "%vsenv%" @set vsenv=%VS140COMNTOOLS%..\..\VC\bin\vcvars%minabi%.bat
@set vsenv15=%vsenv%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars%minabi%.bat
@if EXIST "%vsenv15%" @set toolchain=Visual Studio 15 2017
@if NOT EXIST "%vsenv15%" @set toolchain=Visual Studio 14
@set vsenv14=%VS140COMNTOOLS%..\..\VC\bin\vcvars%minabi%.bat
@if %abi%==x64 @set toolchain=%toolchain% Win64
@set gcc=%mesa%mingw-w64-%abi%\mingw%minabi%\bin
@set vsenvloaded=0
Expand All @@ -27,6 +27,8 @@
@RD /S /Q cmake-%abi%
@md cmake-%abi%
@cd cmake-%abi%
@if EXIST "%vsenv15%" set vsenv=%vsenv15%
@if NOT EXIST "%vsenv15%" set vsenv=%vsenv14%
@set vsenvloaded=1
@call "%vsenv%"
@set PATH=%mesa%cmake\%abi%\bin\;%PATH%
Expand Down Expand Up @@ -59,16 +61,17 @@
@cd "%mesa%mesa"
@RD /S /Q build\windows-%longabi%
@set /p openswr=Do you want to build OpenSWR drivers? (y=yes):
@set buildswr=
@if /i %openswr%==y @set buildswr=swr=1
@set buildswr=0
@if /i %openswr%==y @set buildswr=1
@set mingw=n
@set mingwtest=0
@if EXIST "%gcc%" @set mingwtest=1
@if %dxtnbuilt%==0 set PATH=%gcc%\;%PATH%
@set msys2=%mesa%msys64\msys2_shell.cmd
@if EXIST "%msys2%" @set mingwtest=%mingwtest%2
@rem if %mingwtest%==12 @set /p mingw=Do you want to build with MinGW-W64 instead of Visual Studio (y=yes):
@set buildmingw=
@set mesatoolchain=default
@set restartcond=0
@set PATH=%mesa%Python\%abi%\;%mesa%Python\%abi%\Scripts\;%mesa%flexbison\;%mesa%m4\%abi%\usr\bin\;%PATH%
@pip install -U mako
@pip freeze > requirements.txt
Expand All @@ -77,7 +80,7 @@
@if /i NOT %mingw%==y GOTO build_with_vs

:build_with_mingw
@set buildmingw=toolchain=crossmingw
@set mesatoolchain=crossmingw
@copy "%gcc%\%altabi%-w64-mingw32-gcc-ar.exe" "%gcc%\%altabi%-w64-mingw32-ar.exe"
@copy "%gcc%\%altabi%-w64-mingw32-gcc-ranlib.exe" "%gcc%\%altabi%-w64-mingw32-ranlib.exe"
@call "%msys2%" -use-full-path
Expand All @@ -91,12 +94,20 @@ pip freeze > requirements.txt
pip install -r requirements.txt --upgrade
cd $mesa
cd mesa
scons build=release platform=windows machine=x86 toolchain=crossmingw libgl-gdi
@GOTO exit
@GOTO build_mesa_exec

:build_with_vs
@if %vsenvloaded%==0 call "%vsenv%"
@cmd /k "scons build=release platform=windows machine=%longabi% %buildmingw% %buildswr% libgl-gdi"
@if %vsenvloaded%==0 call "%vsenv14%"
@if %vsenvloaded%==1 @set restartcond=1
@if EXIST "%vsenv15%" @set restartcond=%restartcond%2
@if %restartcond%==12 (
@echo "A Visual Studio build environment is already loaded. The script will now restart to flush loaded environment.
@pause
@GOTO exit
)

:build_mesa_exec
@cmd /k "scons build=release platform=windows machine=%longabi% toolchain=%mesatoolchain% swr=%buildswr% libgl-gdi"

:exit
exit

0 comments on commit d62bec5

Please sign in to comment.