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 |
|
Andreas Traczyk | e303bc6 | 2018-12-05 11:06:31 -0500 | [diff] [blame] | 9 | set doDeps=N
|
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 10 | set doCompile=N
|
| 11 | set doBuild=N
|
| 12 |
|
| 13 | set SCRIPTNAME=%~nx0
|
| 14 |
|
| 15 | if "%1"=="compile" (
|
| 16 | set doCompile=Y
|
| 17 | ) else if "%1"=="build" (
|
| 18 | set doBuild=Y
|
Andreas Traczyk | e303bc6 | 2018-12-05 11:06:31 -0500 | [diff] [blame] | 19 | ) else if "%1"=="deps" (
|
| 20 | set doDeps=Y
|
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 21 | ) else (
|
| 22 | goto Usage
|
| 23 | )
|
| 24 |
|
| 25 | set arch=N
|
| 26 |
|
| 27 | shift
|
| 28 | :ParseArgs
|
| 29 | if "%1" == "" goto FinishedArgs
|
| 30 | if /I "%1"=="x86" (
|
| 31 | set arch=x86
|
| 32 | ) else if /I "%1"=="x64" (
|
| 33 | set arch=x64
|
| 34 | ) else (
|
| 35 | goto Usage
|
| 36 | )
|
| 37 | shift
|
| 38 | goto ParseArgs
|
| 39 |
|
| 40 | :FinishedArgs
|
| 41 | if "%arch%"=="x86" (
|
| 42 | set MSBUILD_ARGS=/nologo /p:useenv=true /p:Platform=Win32 /maxcpucount:%NUMBER_OF_PROCESSORS%
|
| 43 | ) else if "%arch%"=="x64" (
|
| 44 | set MSBUILD_ARGS=/nologo /p:useenv=true /p:Platform=x64 /maxcpucount:%NUMBER_OF_PROCESSORS%
|
| 45 | )
|
| 46 |
|
| 47 | @setlocal
|
| 48 |
|
| 49 | set VSInstallerFolder="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
|
| 50 | if %PROCESSOR_ARCHITECTURE%==x86 set VSInstallerFolder="%ProgramFiles%\Microsoft Visual Studio\Installer"
|
| 51 |
|
| 52 | pushd %VSInstallerFolder%
|
| 53 | for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
| 54 | set VSLATESTDIR=%%i
|
| 55 | )
|
| 56 | popd
|
| 57 |
|
| 58 | echo VS Installation folder: %VSLATESTDIR%
|
| 59 |
|
| 60 | if not exist "%VSLATESTDIR%\VC\Auxiliary\Build\vcvarsall.bat" (
|
| 61 | echo:
|
| 62 | echo VSInstallDir not found or not installed correctly.
|
| 63 | goto cleanup
|
| 64 | )
|
| 65 |
|
| 66 | if %PROCESSOR_ARCHITECTURE%==x86 (
|
| 67 | set Comp_x86=x86 10.0.15063.0
|
| 68 | set Comp_x64=x86_amd64 10.0.15063.0
|
| 69 | ) else (
|
| 70 | set Comp_x86=amd64_x86 10.0.15063.0
|
| 71 | set Comp_x64=amd64 10.0.15063.0
|
| 72 | )
|
| 73 |
|
| 74 | set path=%path:"=%
|
| 75 | if "%arch%"=="x86" (
|
| 76 | call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x86%
|
| 77 | ) else if "%arch%"=="x64" (
|
| 78 | call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x64%
|
| 79 | )
|
| 80 |
|
| 81 | if "%arch%" neq "N" (
|
| 82 | if "%doCompile%" neq "N" (
|
| 83 | goto compileClient
|
| 84 | ) else if "%doBuild%" neq "N" (
|
| 85 | goto buildClient
|
Andreas Traczyk | e303bc6 | 2018-12-05 11:06:31 -0500 | [diff] [blame] | 86 | ) else if "%doDeps%" neq "N" (
|
| 87 | goto buildDeps
|
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 88 | )
|
| 89 | goto :eof
|
| 90 | )
|
| 91 | goto Usage
|
| 92 |
|
Andreas Traczyk | e303bc6 | 2018-12-05 11:06:31 -0500 | [diff] [blame] | 93 | :buildDeps
|
| 94 | set TOBUILD=qrencode-win32\qrencode-win32\vc8\qrcodelib\qrcodelib.vcxproj
|
| 95 | msbuild %TOBUILD% /verbosity:normal /p:Configuration=Release-Lib %MSBUILD_ARGS%
|
| 96 | set TOBUILD=winsparkle\WinSparkle-2015.sln
|
| 97 | set WGET_CMD=wget --no-check-certificate --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=4
|
| 98 | %WGET_CMD% https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
| 99 | nuget restore %TOBUILD%
|
| 100 | msbuild %TOBUILD% /verbosity:normal /p:Configuration=Release %MSBUILD_ARGS%
|
| 101 | goto cleanup
|
| 102 |
|
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 103 | :compileClient
|
| 104 | msbuild ring-client-windows.vcxproj /verbosity:normal /p:Configuration=ReleaseCompile %MSBUILD_ARGS%
|
| 105 | goto cleanup
|
| 106 |
|
| 107 | :buildClient
|
| 108 | msbuild ring-client-windows.vcxproj /verbosity:normal /p:Configuration=Release %MSBUILD_ARGS%
|
| 109 | goto cleanup
|
| 110 |
|
| 111 | @endlocal
|
| 112 |
|
| 113 | :Usage
|
| 114 | echo:
|
| 115 | echo The correct usage is:
|
| 116 | echo:
|
| 117 | echo %0 [action] [architecture]
|
| 118 | echo:
|
| 119 | echo where
|
| 120 | echo:
|
| 121 | echo [action] is: compile ^| build
|
| 122 | echo [architecture] is: x86 ^| x64
|
| 123 | echo:
|
| 124 | echo For example:
|
| 125 | echo %0 compile x86 - compile only x86 (for CI)
|
| 126 | echo %0 build x64 - build x64 client
|
| 127 | echo:
|
| 128 | goto :eof
|
| 129 |
|
| 130 | :cleanup
|
| 131 | endlocal
|
| 132 | exit /B %ERRORLEVEL% |