| 1 |
@REM Copyright (c) Microsoft. All rights reserved. |
| 2 |
@REM Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
@setlocal EnableExtensions EnableDelayedExpansion |
| 5 |
@echo off |
| 6 |
|
| 7 |
set CMAKE_DIR=shared-util_Win32 |
| 8 |
set MAKE_NUGET_PKG=no |
| 9 |
set SOLUTION_NAME=azure_c_shared_utility |
| 10 |
|
| 11 |
set current-path=%~dp0 |
| 12 |
rem // remove trailing slash |
| 13 |
set current-path=%current-path:~0,-1% |
| 14 |
|
| 15 |
set build-root=%current-path%\..\.. |
| 16 |
rem // resolve to fully qualified path |
| 17 |
for %%i in ("%build-root%") do set build-root=%%~fi |
| 18 |
|
| 19 |
rem ----------------------------------------------------------------------------- |
| 20 |
rem -- parse script arguments |
| 21 |
rem ----------------------------------------------------------------------------- |
| 22 |
|
| 23 |
rem // default build options |
| 24 |
set build-clean=0 |
| 25 |
set build-config= |
| 26 |
set build-platform=Win32 |
| 27 |
|
| 28 |
:args-loop |
| 29 |
if "%1" equ "" goto args-done |
| 30 |
if "%1" equ "-c" goto arg-build-clean |
| 31 |
if "%1" equ "--clean" goto arg-build-clean |
| 32 |
if "%1" equ "--config" goto arg-build-config |
| 33 |
if "%1" equ "--platform" goto arg-build-platform |
| 34 |
if "%1" equ "--make_nuget" goto arg-build-nuget |
| 35 |
if "%1" equ "--build-root" goto arg-build-root |
| 36 |
if "%1" equ "--solution-name" goto arg-solution-name |
| 37 |
call :usage && exit /b 1 |
| 38 |
|
| 39 |
:arg-build-clean |
| 40 |
set build-clean=1 |
| 41 |
goto args-continue |
| 42 |
|
| 43 |
:arg-build-config |
| 44 |
shift |
| 45 |
if "%1" equ "" call :usage && exit /b 1 |
| 46 |
set build-config=%1 |
| 47 |
goto args-continue |
| 48 |
|
| 49 |
:arg-build-platform |
| 50 |
shift |
| 51 |
if "%1" equ "" call :usage && exit /b 1 |
| 52 |
set build-platform=%1 |
| 53 |
if %build-platform% == x64 ( |
| 54 |
set CMAKE_DIR=shared-util_x64 |
| 55 |
) else if %build-platform% == arm ( |
| 56 |
set CMAKE_DIR=shared-util_arm |
| 57 |
) |
| 58 |
goto args-continue |
| 59 |
|
| 60 |
:arg-build-nuget |
| 61 |
shift |
| 62 |
if "%1" equ "" call :usage && exit /b 1 |
| 63 |
set MAKE_NUGET_PKG=%1 |
| 64 |
goto args-continue |
| 65 |
|
| 66 |
:arg-build-root |
| 67 |
shift |
| 68 |
if "%1" equ "" call :usage && exit /b 1 |
| 69 |
set build-root=%1 |
| 70 |
goto args-continue |
| 71 |
|
| 72 |
:arg-solution-name |
| 73 |
shift |
| 74 |
if "%1" equ "" call :usage && exit /b 1 |
| 75 |
set SOLUTION_NAME=%1 |
| 76 |
goto args-continue |
| 77 |
|
| 78 |
:args-continue |
| 79 |
shift |
| 80 |
goto args-loop |
| 81 |
|
| 82 |
:args-done |
| 83 |
|
| 84 |
rem ----------------------------------------------------------------------------- |
| 85 |
rem -- build with CMAKE |
| 86 |
rem ----------------------------------------------------------------------------- |
| 87 |
|
| 88 |
echo CMAKE Output Path: %build-root%\cmake\%CMAKE_DIR% |
| 89 |
|
| 90 |
if NOT EXIST %build-root%\cmake\%CMAKE_DIR% GOTO NO_CMAKE_DIR |
| 91 |
rmdir /s/q %build-root%\cmake\%CMAKE_DIR% |
| 92 |
rem no error checking |
| 93 |
:NO_CMAKE_DIR |
| 94 |
|
| 95 |
mkdir %build-root%\cmake\%CMAKE_DIR% |
| 96 |
rem no error checking |
| 97 |
|
| 98 |
pushd %build-root%\cmake\%CMAKE_DIR% |
| 99 |
|
| 100 |
call %build-root%\jenkins\windows_c_VsDevCmd.cmd %build-platform% |
| 101 |
|
| 102 |
echo ***checking msbuild*** |
| 103 |
where /q msbuild |
| 104 |
|
| 105 |
where msbuild |
| 106 |
IF ERRORLEVEL 1 ( |
| 107 |
echo [91mERROR: msbuild not found!!![0m |
| 108 |
goto :eof |
| 109 |
) |
| 110 |
|
| 111 |
if %MAKE_NUGET_PKG% == yes ( |
| 112 |
echo ***Running CMAKE for Win32 *** |
| 113 |
cmake %build-root% |
| 114 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 115 |
popd |
| 116 |
|
| 117 |
echo *** Running CMAKE x64 *** |
| 118 |
if EXIST %build-root%\cmake\shared-util_x64 ( |
| 119 |
rmdir /s/q %build-root%\cmake\shared-util_x64 |
| 120 |
) |
| 121 |
|
| 122 |
mkdir %build-root%\cmake\shared-util_x64 |
| 123 |
pushd %build-root%\cmake\shared-util_x64 |
| 124 |
cmake %build-root% -G "Visual Studio 15 2017" -A x64 |
| 125 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 126 |
popd |
| 127 |
|
| 128 |
echo *** Running CMAKE ARM *** |
| 129 |
if EXIST %build-root%\cmake\shared-util_arm ( |
| 130 |
rmdir /s/q %build-root%\cmake\shared-util_arm |
| 131 |
) |
| 132 |
mkdir %build-root%\cmake\shared-util_arm |
| 133 |
pushd %build-root%\cmake\shared-util_arm |
| 134 |
cmake %build-root% -A ARM |
| 135 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 136 |
) else if %build-platform% == Win32 ( |
| 137 |
echo ***Running CMAKE for Win32*** |
| 138 |
cmake %build-root% -A Win32 -Drun_unittests:bool=ON -Duse_wsio:bool=ON -Drun_int_tests=ON -G %VSVERSION% |
| 139 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 140 |
) else if %build-platform% == ARM ( |
| 141 |
echo ***Running CMAKE for ARM*** |
| 142 |
cmake %build-root% -A ARM -Drun_unittests:bool=ON -Drun_int_tests=ON -G %VSVERSION% |
| 143 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 144 |
) else ( |
| 145 |
echo ***Running CMAKE for Win64*** |
| 146 |
cmake %build-root% -A x64 -Drun_unittests:bool=ON -Drun_int_tests=ON -G %VSVERSION% |
| 147 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 148 |
) |
| 149 |
|
| 150 |
if %MAKE_NUGET_PKG% == yes ( |
| 151 |
echo running Win32 Shared Util |
| 152 |
echo ***Building all configurations*** |
| 153 |
msbuild /m %build-root%\cmake\shared-util_Win32\%SOLUTION_NAME%.sln /p:Configuration=Release |
| 154 |
msbuild /m %build-root%\cmake\shared-util_Win32\%SOLUTION_NAME%.sln /p:Configuration=Debug |
| 155 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 156 |
|
| 157 |
msbuild /m %build-root%\cmake\shared-util_x64\%SOLUTION_NAME%.sln /p:Configuration=Release |
| 158 |
msbuild /m %build-root%\cmake\shared-util_x64\%SOLUTION_NAME%.sln /p:Configuration=Debug |
| 159 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 160 |
|
| 161 |
msbuild /m %build-root%\cmake\shared-util_arm\%SOLUTION_NAME%.sln /p:Configuration=Release |
| 162 |
msbuild /m %build-root%\cmake\shared-util_arm\%SOLUTION_NAME%.sln /p:Configuration=Debug |
| 163 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 164 |
) else ( |
| 165 |
if not defined build-config ( |
| 166 |
echo ***Building both configurations*** |
| 167 |
msbuild /m %SOLUTION_NAME%.sln /p:Configuration=Release |
| 168 |
msbuild /m %SOLUTION_NAME%.sln /p:Configuration=Debug |
| 169 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 170 |
) else ( |
| 171 |
echo ***Building %build-config% only*** |
| 172 |
msbuild /m %SOLUTION_NAME%.sln /p:Configuration=%build-config% |
| 173 |
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! |
| 174 |
) |
| 175 |
) |
| 176 |
|
| 177 |
popd |
| 178 |
|
| 179 |
goto :eof |
| 180 |
|
| 181 |
:usage |
| 182 |
echo build.cmd [options] |
| 183 |
echo options: |
| 184 |
echo --clean [] Cleans the project |
| 185 |
echo --config ^<value^> [Debug] build configuration (e.g. Debug, Release) |
| 186 |
echo --platform ^<value^> [Win32] build platform (e.g. Win32, x64, arm, ...) |
| 187 |
echo --make_nuget ^<value^> [no] generates the binaries to be used for nuget packaging (e.g. yes, no) |
| 188 |
goto :eof |