Skip to content

Commit

Permalink
Windows batch files
Browse files Browse the repository at this point in the history
- Update to correctly locate the installed version of Visual Studio - minimum version VS 2015
- For Windows 10 the supplied msbuild/csc does not correctly compile the c# v6 code that is used in the Openmetaverse libraries
  • Loading branch information
greythane committed Aug 15, 2019
1 parent 648ca5d commit c8d2341
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 52 deletions.
86 changes: 71 additions & 15 deletions coverity_build.bat
Expand Up @@ -13,7 +13,7 @@ rem to the system and build requirements. Adjust as appropriate
rem
rem This file is assumed to be in the top level WhiteCore-Dev directory
rem
rem greythane (Rowan Deppeler) - May 2016
rem greythane (Rowan Deppeler) - August 2019
rem

echo ========================================
Expand All @@ -24,10 +24,10 @@ rem ## Default "configuration" choice ((release, (debug)
set configuration=debug

rem ## Default Visual Studio edition
set vstudio=2013
set vstudio=2015

rem ## Default Framework
set framework=4_5
set framework=4_7_2

rem ## End user selections ##

Expand All @@ -36,22 +36,78 @@ set bits=x86
if exist "%PROGRAMFILES(X86)%" (set bits=x64)

echo Creating solution
Prebuild.exe /target vs2013 /targetframework v%framework% /conditionals ISWIN;NET_%framework%
Prebuild.exe /target vs2015 /targetframework v%framework% /conditionals ISWIN;NET_%framework%

echo Setting up for build
set fpath=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild
if %bits%==x64 set args=/p:Platform=x64
if %bits%==x86 set args=/p:Platform=x86
if %configuration%==release set cfg=/p:Configuration=Release
if %configuration%==debug set cfg=/p:Configuration=Debug
set filename=Compile.WhiteCore.bat
echo %fpath% WhiteCore.sln %args% %cfg% > %filename% /p:DefineConstants="ISWIN;NET_%framework%
set FileName=Compile.WhiteCore.bat
setlocal ENABLEEXTENSIONS
set VALUE_NAME=MSBuildToolsPath
rem try find vs2017
if "%PROCESSOR_ARCHITECTURE%"=="x86" set PROGRAMS=%ProgramFiles%
if defined ProgramFiles(x86) set PROGRAMS=%ProgramFiles(x86)%

echo Let's do it...
..\cov-analysis\bin\cov-build.exe --dir cov-int Compile.WhiteCore.bat
for %%e in (Enterprise Professional Community) do (

echo Zip entire cov-int directory and upload to Coverity
echo Coverity build Finished
if exist "%PROGRAMS%\Microsoft Visual Studio\2017\%%e\MSBuild\15.0\Bin\MSBuild.exe" (
set fpath="%PROGRAMS%\Microsoft Visual Studio\2017\%%e\MSBuild\15.0\Bin\"
goto :found
)

if exist "%PROGRAMS%\Microsoft Visual Studio\2019\%%e\MSBuild\Current\Bin\MSBuild.exe" (
set fpath="%PROGRAMS%\Microsoft Visual Studio\2019\%%e\MSBuild\Current\Bin\"
goto :found
)
)

rem We have to use grep or find to locate the correct line, because reg query spits
rem out 4 lines before Windows 7 but 2 lines after Windows 7.
rem We use grep if it's on the path; otherwise we use the built-in find command
rem from Windows. (We must use grep on Cygwin because it overrides the "find" command.)

for %%X in (grep.exe) do (set FOUNDGREP=%%~$PATH:X)
if defined FOUNDGREP (
set FINDCMD=grep
) else (
set FINDCMD=find
)

rem try vs2015
FOR /F "usebackq tokens=1-3" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v %VALUE_NAME% 2^>nul ^| %FINDCMD% "%VALUE_NAME%"`) DO (
set fpath=%%C
goto :found
)

echo msbuild for at least VS2015 not found, please install a (Community) edition of VS2019, VS2017 or VS2015
echo Not creating %FileName%

if exist %FileName% (
del %FileName%
)
goto :done

:found
echo Found msbuild at %fpath%
echo Creating build files
rem @echo %fpath%\msbuild opensim.sln > compile.bat

if %bits%==x64 (
set args=/p:Platform=x64
)
if %bits%==x86 (
set args=/p:Platform=x86
)
if %configuration%==release set cfg=/p:Configuration=Release
if %configuration%==debug set cfg=/p:Configuration=Debug

echo Creating %FileName%
echo %fpath%\msbuild WhiteCore.sln %args% %cfg% > %FileName% /p:DefineConstants="ISWIN;NET_%framework%

echo Let's do it...
..\cov-analysis\bin\cov-build.exe --dir cov-int Compile.WhiteCore.bat

echo Zip entire cov-int directory and upload to Coverity
echo Coverity build Finished

:done
set /p nothing= Enter to continue
exit
125 changes: 88 additions & 37 deletions runprebuild.bat
Expand Up @@ -15,7 +15,7 @@ rem ## Default "run compile batch" choice (y(es),n(o))
set compile_at_end=y

rem ## Default Visual Studio edition
set vstudio=2010
set vstudio=2015

rem ## Default Framework
set framework=4_0
Expand All @@ -26,14 +26,18 @@ set bits=x86
if exist "%PROGRAMFILES(X86)%" (set bits=x64)
if %bits% == x64 (
echo Found 64bit architecture
set args=/p:Platform=x64
)
if %bits% == x86 (
echo Found 32 bit architecture
set args=/p:Platform=x86
)

rem ## Determine native framework
:CheckOS
set framework=4_5
if %framework%==4_5 set %vstudio%=2012

for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
if %version% == 10.0 (
set framework=4_7_2
Expand Down Expand Up @@ -62,7 +66,7 @@ if %version% == 5.2 (
)
if %version% == 5.1 (
set framework=3_5
echo hmmm... Windows XP
echo hmmm... mutter, mutter Windows XP
)

rem ## If not requested, skip the prompting
Expand Down Expand Up @@ -104,56 +108,103 @@ echo "%configuration%" isn't a valid choice!
goto configuration

:framework
set /p framework="Choose your .NET framework (4_0, 4_5, 4.6)? [%framework%]: "
if %framework%==4_0 goto final
if %framework%==4_5 goto final
if %framework%==4_6 goto final
set /p framework="Choose your .NET framework (4.0, 4.5, 4.6, 4.7)? [%framework%]: "
if %framework%==4.0 goto final
if %framework%==4.5 goto final
if %framework%==4.6 goto final
if %framework%==4.7 goto final
echo "%framework%" isn't a valid choice!
goto framework

:final
echo.
echo Configuring for %bits% architecture using %framework% .NET framework
echo.
echo.

if exist Compile.*.bat (
echo Deleting previous compile batch file...
echo.
del Compile.*.bat
)
if %framework%==4_5 set %vstudio%=2012

echo Calling Prebuild for target %vstudio% with framework %framework%...
Prebuild.exe /target vs%vstudio% /targetframework v%framework% /conditionals ISWIN;NET_%framework%

echo.
echo Creating compile batch file for your convenience...
if %bits%==x64 (
set args=/p:Platform=x64
set fpath=%SystemDrive%\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\msbuild
)
if %bits%==x86 (
set args=/p:Platform=x86
set fpath=%SystemDrive%\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild
)
if %configuration%==r (
set cfg=/p:Configuration=Release
set configuration=release
echo Setting up for build
set FileName=Compile.WhiteCore.bat
setlocal ENABLEEXTENSIONS
set VALUE_NAME=MSBuildToolsPath
rem try find vs2019,20177
if "%PROCESSOR_ARCHITECTURE%"=="x86" set PROGRAMS=%ProgramFiles%
if defined ProgramFiles(x86) set PROGRAMS=%ProgramFiles(x86)%

for %%e in (Enterprise Professional Community) do (

if exist "%PROGRAMS%\Microsoft Visual Studio\2017\%%e\MSBuild\15.0\Bin\MSBuild.exe" (
set fpath="%PROGRAMS%\Microsoft Visual Studio\2017\%%e\MSBuild\15.0\Bin\"
rem set vstudio=2017
goto :found
)

if exist "%PROGRAMS%\Microsoft Visual Studio\2019\%%e\MSBuild\Current\Bin\MSBuild.exe" (
set fpath="%PROGRAMS%\Microsoft Visual Studio\2019\%%e\MSBuild\Current\Bin\"
rem set vstudio=2019
goto :found
)
)
if %configuration%==d (
set cfg=/p:Configuration=Debug
set configuration=debug

rem We have to use grep or find to locate the correct line, because reg query spits
rem out 4 lines before Windows 7 but 2 lines after Windows 7.
rem We use grep if it's on the path; otherwise we use the built-in find command
rem from Windows. (We must use grep on Cygwin because it overrides the "find" command.)

for %%X in (grep.exe) do (set FOUNDGREP=%%~$PATH:X)
if defined FOUNDGREP (
set FINDCMD=grep
) else (
set FINDCMD=find
)
if %configuration%==release set cfg=/p:Configuration=Release
if %configuration%==debug set cfg=/p:Configuration=Debug
set filename=Compile.VS%vstudio%.net%framework%.%bits%.%configuration%.bat

echo %fpath% WhiteCore.sln %args% %cfg% > %filename% /p:DefineConstants="ISWIN"
rem try vs2015
FOR /F "usebackq tokens=1-3" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v %VALUE_NAME% 2^>nul ^| %FINDCMD% "%VALUE_NAME%"`) DO (
set fpath=%%C
goto :found
)

echo.
set /p compile_at_end="Done, %filename% created. Compile now? (y,n) [%compile_at_end%]"
if %compile_at_end%==y (
%filename%
pause
echo msbuild for at least VS2015 not found, please install a (Community) edition of VS2019, VS2017 or VS2015
echo Not creating %FileName%
if exist %FileName% (
del %FileName%
)
goto :done

:found
echo Creating solution
echo Calling Prebuild for target VS%vstudio% with framework %framework%...
Prebuild.exe /target vs%vstudio% /targetframework v%framework% /conditionals ISWIN;NET_%framework%
echo.
echo Found msbuild at %fpath%
echo.
echo Configuring for %bits% architecture using %framework% .NET framework
echo.
echo.
set /p nothing= Enter to continue

echo Creating build files

if %configuration%==r (
set cfg=/p:Configuration=Release
set configuration=release
)
if %configuration%==d (
set cfg=/p:Configuration=Debug
set configuration=debug
)
if %configuration%==release set cfg=/p:Configuration=Release
if %configuration%==debug set cfg=/p:Configuration=Debug

echo Creating %FileName%
echo %fpath%\msbuild WhiteCore.sln %args% %cfg% > %FileName% /p:DefineConstants="ISWIN;NET_%framework%

echo.
set /p compile_at_end="Done, %FileName% created. Compile now? (y,n) [%compile_at_end%]"
if %compile_at_end%==y (
%FileName%
pause
)

0 comments on commit c8d2341

Please sign in to comment.