build_all.bat 8.22 KB
Newer Older
1
@echo off
2 3 4 5 6
@setlocal EnableDelayedExpansion

set CONTRIB_DIR=%~dp0

set platform=win32
7
set arch=x64
8
if "%1"=="uwp" (
9
    set platform=uwp
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    if "%2"=="x86" (
        set arch=x86
        goto arch_x86
    ) else if "%2"=="x64" (
        set arch=x64
        goto arch_x64
    ) else (
        goto parameterError
    )
) else if "%1"=="win32" (
    if "%2"=="x86" (
        set arch=x86
        goto arch_x86
    ) else if "%2"=="x64" (
        set arch=x64
        goto arch_x64
    ) else (
        goto parameterError
    )
) else (
    goto parameterError
)
32

33 34 35 36 37 38 39 40 41
:arch_x86
set MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=Release /p:Platform=Win32 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
if "%1"=="uwp" (
    set DAEMON_MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=ReleaseLib /p:Platform=Win32 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
    goto uwpProjs
) else if "%1"=="win32" (
    set DAEMON_MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=ReleaseLib_win32 /p:Platform=Win32 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
    goto win32Projs
)
42

43
:arch_x64
44
set MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=Release /p:Platform=x64 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
45 46 47 48 49 50 51 52 53
if "%1"=="uwp" (
    set DAEMON_MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=ReleaseLib /p:Platform=x64 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
    goto uwpProjs
) else if "%1"=="win32" (
    set DAEMON_MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=ReleaseLib_win32 /p:Platform=x64 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
    goto win32Projs
)

:uwpProjs
54 55 56 57 58 59 60 61 62 63 64 65 66 67
set TOBUILD= ^
x264=build\x264\SMP\libx264.vcxproj, ^
opus=build\opus\SMP\libopus.vcxproj, ^
ffmpeg=ffmpeg, ^
restbed=restbed, ^
jsoncpp=build\jsoncpp\makefiles\vs2017\lib_json.vcxproj, ^
argon2=build\argon2\vs2015\Argon2Ref\Argon2Ref.vcxproj, ^
gmp=build\gmp\SMP\libgmp.vcxproj, ^
iconv=build\iconv\SMP\libiconv.vcxproj, ^
zlib=build\zlib\SMP\libzlib.vcxproj, ^
nettle=build\nettle\SMP\libnettle.vcxproj, ^
hogweed=build\nettle\SMP\libhogweed.vcxproj, ^
gnutls=build\gnutls\SMP\libgnutls.vcxproj, ^
msgpack=build\msgpack-c\vs2017\msgpackc-static.vcxproj, ^
Adrien Béraud's avatar
Adrien Béraud committed
68
opendht=build\opendht\MSVC\opendht.vcxproj, ^
69
pjproject=pjproject, ^
70
pthreads=build\pthreads\MSVC\pthreads.vcxproj, ^
71 72
xml=build\pupnp\build\vs2017\ixml.vcxproj, ^
upnp=build\pupnp\build\vs2017\libupnp.vcxproj, ^
73 74 75
secp256k1=build\secp256k1\MSVC\secp256k1.vcxproj, ^
portaudio=build\portaudio\msvc\portaudio.vcxproj, ^
yaml-cpp=build\yaml-cpp\msvc\yaml-cpp.vcxproj, ^
76
goto startBuild
77

78
:win32Projs
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
set TOBUILD= ^
vpx=build\vpx\SMP\libvpx.vcxproj, ^
x264=build\x264\SMP\libx264.vcxproj, ^
opus=build\opus\SMP\libopus.vcxproj, ^
ffmpeg=ffmpeg, ^
restbed=restbed, ^
jsoncpp=build\jsoncpp\makefiles\vs2017\lib_json.vcxproj, ^
argon2=build\argon2\vs2015\Argon2Ref\Argon2Ref.vcxproj, ^
gmp=build\gmp\SMP\libgmp.vcxproj, ^
iconv=build\iconv\SMP\libiconv.vcxproj, ^
zlib=build\zlib\SMP\libzlib.vcxproj, ^
nettle=build\nettle\SMP\libnettle.vcxproj, ^
hogweed=build\nettle\SMP\libhogweed.vcxproj, ^
gnutls=build\gnutls\SMP\libgnutls.vcxproj, ^
msgpack=build\msgpack-c\vs2017\msgpackc-static.vcxproj, ^
Adrien Béraud's avatar
Adrien Béraud committed
94
opendht=build\opendht\MSVC\opendht.vcxproj, ^
95
pjproject=pjproject, ^
96
pthreads=build\pthreads\MSVC\pthreads.vcxproj, ^
97 98
xml=build\pupnp\build\vs2017\ixml.vcxproj, ^
upnp=build\pupnp\build\vs2017\libupnp.vcxproj, ^
99 100
secp256k1=build\secp256k1\MSVC\secp256k1.vcxproj, ^
portaudio=build\portaudio\msvc\portaudio.vcxproj, ^
101
yaml-cpp=build\yaml-cpp\msvc\yaml-cpp.vcxproj
102

103 104 105
goto startBuild

:startBuild
106 107 108 109 110 111 112 113 114 115 116 117 118

set PJTOBUILD= ^
pjlib_util=build\pjproject\pjlib-util\build\pjlib_util.vcxproj, ^
pjmedia=build\pjproject\pjmedia\build\pjmedia.vcxproj, ^
pjmedia_codec=build\pjproject\pjmedia\build\pjmedia_codec.vcxproj, ^
pjlib=build\pjproject\pjlib\build\pjlib.vcxproj, ^
pjsip_core=build\pjproject\pjsip\build\pjsip_core.vcxproj, ^
pjsip_simple=build\pjproject\pjsip\build\pjsip_simple.vcxproj, ^
pjsua_lib=build\pjproject\pjsip\build\pjsua_lib.vcxproj, ^
pjsua2_lib=build\pjproject\pjsip\build\pjsua2_lib.vcxproj, ^
pjsip_ua=build\pjproject\pjsip\build\pjsip_ua.vcxproj, ^
pjnath=build\pjproject\pjnath\build\pjnath.vcxproj

119 120
@setlocal

121 122
set VSInstallerFolder="%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer"
if %PROCESSOR_ARCHITECTURE%==x86 set VSInstallerFolder="%ProgramFiles%\\Microsoft Visual Studio\\Installer"
123 124 125 126 127 128 129 130 131

pushd %VSInstallerFolder%
for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
  set VSLATESTDIR=%%i
)
popd

echo VS Installation folder: %VSLATESTDIR%

132
if not exist "%VSLATESTDIR%\\VC\\Auxiliary\\Build\\vcvarsall.bat" (
133 134 135 136 137 138
    echo:
    echo VSInstallDir not found or not installed correctly.
    goto cleanup
)

if %PROCESSOR_ARCHITECTURE%==x86 (
139 140 141 142 143 144 145
    if "%1"=="uwp" (
        set Comp_x86=x86 uwp 10.0.15063.0
        set Comp_x64=x86_amd64 uwp 10.0.15063.0
    ) else (
        set Comp_x86=x86 10.0.15063.0
        set Comp_x64=x86_amd64 10.0.15063.0
    )
146
) else (
147 148 149 150 151 152 153 154 155 156 157 158 159 160
    if "%1"=="uwp" (
        set Comp_x86=amd64_x86 uwp 10.0.15063.0
        set Comp_x64=amd64 uwp 10.0.15063.0
    ) else (
        set Comp_x86=amd64_x86 10.0.15063.0
        set Comp_x64=amd64 10.0.15063.0
    )
)

set path=%path:"=%
if "%2"=="x86" (
    call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x86%
) else if "%2"=="x64" (
    call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x64%
161 162 163 164 165 166 167 168 169 170 171
)

set MSYS2_PATH_TYPE=inherit

if not defined MSYS2_BIN (
    if exist C:\msys64\usr\bin\bash.exe set MSYS2_BIN="C:\msys64\usr\bin\bash.exe"
)
if not defined MSYS2_BIN (
    if exist C:\msys\usr\bin\bash.exe set MSYS2_BIN="C:\msys\usr\bin\bash.exe"
)

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
if /I %3 equ "" (
    goto build_all
) else (
    goto build_one
)

:build_all
set "keyname="
for %%I in (%TOBUILD%) do (
    if not defined keyname (
        set keyname=%%I
    ) else (
        echo building: !keyname!
        call :build %%I %1 %2
        set %%keyname%%=%%I
        set "keyname="
    )
)
goto cleanup

:build_one
set found="N"
set "keyname="
for %%I in (%TOBUILD%) do (
    if not defined keyname (
        set keyname=%%I
    ) else (
        if /I %3 equ !keyname! (
            echo building: !keyname!
            set found="Y"
            call :build %%I %1 %2
            goto cleanup
        )
        set %%keyname%%=%%I
        set "keyname="
    )
)
if %found%=="N" (
    echo "%3" not in listed contrib
)
goto cleanup

:parameterError
echo "parameter error"
goto cleanup

:cleanup
endlocal
@endlocal
221 222 223 224 225 226 227
if %ERRORLEVEL% geq 1 (
    echo build_all failed
    exit %ERRORLEVEL%
) else (
    echo build_all succeeded
    exit /B %ERRORLEVEL%
)
228 229 230 231 232 233

:build
if /I %1 equ ffmpeg (
    %MSYS2_BIN% --login -x %CONTRIB_DIR%src/ffmpeg/windows-configure-make.sh %2 %3
) else if /I %1 equ restbed (
    goto build_restbed %2 %3
234 235
) else if /I %1 equ pjproject (
    goto build_pjproject %2 %3
236 237
) else (
    msbuild %CONTRIB_DIR%%1 %MSBUILD_ARGS%
238
)
239 240 241
if %ERRORLEVEL% geq 1 (
    goto cleanup
)
242
goto :eof
243

244
:build_restbed
245
:: build openssl
246
cd %CONTRIB_DIR%build\restbed\dependency\openssl
247
if "%2"=="win32" (
248 249
    call perl Configure VC-WIN64A
    call ms\do_win64a
250
) else if "%2"=="uwp" (
251 252 253 254
    call perl Configure no-asm no-hw no-dso VC-WINUNIVERSAL
    call ms\do_winuniversal
    call ms\setVSvars universal10.0x64
)
255 256
call nmake -f ms\ntdll.mak
set PATH=restbed\dependency\openssl\out32dll;%PATH%
257
:: build restbed w/asio+catch
258 259 260
cd ..\..
mkdir build
cd build
261 262
setlocal
set PATH=C:\\Program Files\\CMake\\bin\\;%PATH%
263
set CMAKE_FLAGS=-DBUILD_SSL=ON -DBUILD_TESTS=OFF
264
if "%3"=="x86" (
265
    cmake %CMAKE_FLAGS% -G "Visual Studio 15 2017 Win32" ..
266
) else if "%3"=="x64" (
267
    cmake %CMAKE_FLAGS% -G "Visual Studio 15 2017 Win64" ..
268
)
269
cmake --build . --target ALL_BUILD --config Release
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
cd ..\..
goto :eof

:build_pjproject
setlocal
set "keyname="
for %%I in (%PJTOBUILD%) do (
    if not defined keyname (
        set keyname=%%I
    ) else (
        echo building: !keyname!
        call :build %%I %1 %2
        set %%keyname%%=%%I
        set "keyname="
    )
)
endlocal