Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame^] | 1 | :: Ring - native Windows client project build script
|
| 2 |
|
| 3 | @echo off
|
| 4 | setlocal
|
| 5 |
|
| 6 | if "%1" == "/?" goto Usage
|
| 7 | if "%~1" == "" goto Usage
|
| 8 |
|
| 9 | set doCompile=N
|
| 10 | set doBuild=N
|
| 11 |
|
| 12 | set SCRIPTNAME=%~nx0
|
| 13 |
|
| 14 | if "%1"=="compile" (
|
| 15 | set doCompile=Y
|
| 16 | ) else if "%1"=="build" (
|
| 17 | set doBuild=Y
|
| 18 | ) else (
|
| 19 | goto Usage
|
| 20 | )
|
| 21 |
|
| 22 | set arch=N
|
| 23 |
|
| 24 | shift
|
| 25 | :ParseArgs
|
| 26 | if "%1" == "" goto FinishedArgs
|
| 27 | if /I "%1"=="x86" (
|
| 28 | set arch=x86
|
| 29 | ) else if /I "%1"=="x64" (
|
| 30 | set arch=x64
|
| 31 | ) else (
|
| 32 | goto Usage
|
| 33 | )
|
| 34 | shift
|
| 35 | goto ParseArgs
|
| 36 |
|
| 37 | :FinishedArgs
|
| 38 | if "%arch%"=="x86" (
|
| 39 | set MSBUILD_ARGS=/nologo /p:useenv=true /p:Platform=Win32 /maxcpucount:%NUMBER_OF_PROCESSORS%
|
| 40 | ) else if "%arch%"=="x64" (
|
| 41 | set MSBUILD_ARGS=/nologo /p:useenv=true /p:Platform=x64 /maxcpucount:%NUMBER_OF_PROCESSORS%
|
| 42 | )
|
| 43 |
|
| 44 | @setlocal
|
| 45 |
|
| 46 | set VSInstallerFolder="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
|
| 47 | if %PROCESSOR_ARCHITECTURE%==x86 set VSInstallerFolder="%ProgramFiles%\Microsoft Visual Studio\Installer"
|
| 48 |
|
| 49 | pushd %VSInstallerFolder%
|
| 50 | for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
| 51 | set VSLATESTDIR=%%i
|
| 52 | )
|
| 53 | popd
|
| 54 |
|
| 55 | echo VS Installation folder: %VSLATESTDIR%
|
| 56 |
|
| 57 | if not exist "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" (
|
| 58 | echo:
|
| 59 | echo VSInstallDir not found or not installed correctly.
|
| 60 | goto cleanup
|
| 61 | )
|
| 62 |
|
| 63 | if %PROCESSOR_ARCHITECTURE%==x86 (
|
| 64 | set Comp_x86=x86 10.0.15063.0
|
| 65 | set Comp_x64=x86_amd64 10.0.15063.0
|
| 66 | ) else (
|
| 67 | set Comp_x86=amd64_x86 10.0.15063.0
|
| 68 | set Comp_x64=amd64 10.0.15063.0
|
| 69 | )
|
| 70 |
|
| 71 | set path=%path:"=%
|
| 72 | if "%arch%"=="x86" (
|
| 73 | call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x86%
|
| 74 | ) else if "%arch%"=="x64" (
|
| 75 | call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x64%
|
| 76 | )
|
| 77 |
|
| 78 | if "%arch%" neq "N" (
|
| 79 | if "%doCompile%" neq "N" (
|
| 80 | goto compileClient
|
| 81 | ) else if "%doBuild%" neq "N" (
|
| 82 | goto buildClient
|
| 83 | )
|
| 84 | goto :eof
|
| 85 | )
|
| 86 | goto Usage
|
| 87 |
|
| 88 | :compileClient
|
| 89 | msbuild ring-client-windows.vcxproj /verbosity:normal /p:Configuration=ReleaseCompile %MSBUILD_ARGS%
|
| 90 | goto cleanup
|
| 91 |
|
| 92 | :buildClient
|
| 93 | msbuild ring-client-windows.vcxproj /verbosity:normal /p:Configuration=Release %MSBUILD_ARGS%
|
| 94 | goto cleanup
|
| 95 |
|
| 96 | @endlocal
|
| 97 |
|
| 98 | :Usage
|
| 99 | echo:
|
| 100 | echo The correct usage is:
|
| 101 | echo:
|
| 102 | echo %0 [action] [architecture]
|
| 103 | echo:
|
| 104 | echo where
|
| 105 | echo:
|
| 106 | echo [action] is: compile ^| build
|
| 107 | echo [architecture] is: x86 ^| x64
|
| 108 | echo:
|
| 109 | echo For example:
|
| 110 | echo %0 compile x86 - compile only x86 (for CI)
|
| 111 | echo %0 build x64 - build x64 client
|
| 112 | echo:
|
| 113 | goto :eof
|
| 114 |
|
| 115 | :cleanup
|
| 116 | endlocal
|
| 117 | exit /B %ERRORLEVEL% |