Created
July 23, 2020 09:54
-
-
Save wheresjames/8cc7cb4e33ea64b752279dcb800f57ae to your computer and use it in GitHub Desktop.
Build Webrtc for WinRT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal ENABLEDELAYEDEXPANSION | |
set p1=%1 | |
if "!p1!"=="" set "p1=x64" | |
REM #---------------------------------------------------------------- | |
REM # https://github.com/microsoft/winrtc | |
REM #---------------------------------------------------------------- | |
REM # RUN | |
REM # buildrtc.bat x64|x86 | |
REM # curl -s https:// | cmd | |
REM # INCLUDE | |
REM # .\source\src;.\source\src\third_party\abseil-cpp;.\source\src\third_party\libyuv\include | |
REM # DEFINE | |
REM # USE_AURA=1;_HAS_EXCEPTIONS=0;__STD_C;_CRT_RAND_S;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;_ATL_NO_OPENGL;_WINDOWS;CERT_CHAIN_PARA_HAS_EXTRA_FIELDS;PSAPI_VERSION=2;WIN32;_SECURE_ATL;WINUWP;__WRL_NO_DEFAULT_LIB__;WINAPI_FAMILY=WINAPI_FAMILY_PC_APP;WIN10=_WIN32_WINNT_WIN10;WIN32_LEAN_AND_MEAN;NOMINMAX;_UNICODE;UNICODE;NTDDI_VERSION=NTDDI_WIN10_RS2;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NDEBUG;NVALGRIND;DYNAMIC_ANNOTATIONS_ENABLED=0;WEBRTC_ENABLE_PROTOBUF=0;WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE;RTC_ENABLE_VP9;HAVE_SCTP;WEBRTC_LIBRARY_IMPL;WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0;WEBRTC_WIN;ABSL_ALLOCATOR_NOTHROW=1;HAVE_SCTP;WEBRTC_VIDEO_CAPTURE_WINRT | |
REM # LINK | |
REM # .\build\obj | |
REM # webrtc.lib | |
REM # IGNORE | |
REM # libcmt(d) | |
REM #---------------------------------------------------------------- | |
REM # Program | |
REM #---------------------------------------------------------------- | |
call :main | |
exit /b | |
:main | |
REM # ----------------------------------------------------------- | |
REM # Setup | |
set BUILDTYPE=!p1! | |
if "!BUILDTYPE!" == "x64" ( | |
set "VSINIT=vcvars64.bat" | |
) else ( | |
if "!BUILDTYPE!" == "x86" ( | |
set "VSINIT=vcvars32.bat" | |
) else ( | |
echo "[ERROR] Invalid build type : !BUILDTYPE!" | |
echo "[USAGE] buildrtc.bat (x64|x86)" | |
exit /b | |
) | |
) | |
set "VSPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build" | |
if NOT EXIST "!VSPATH!" ( | |
echo "Visual studio does not seem to exist at the path" | |
echo "-> !VSPATH!" | |
echo "Do you need to install it, otherwise, edit this batch file and enter the correct path" | |
exit /b | |
) | |
FOR /F "tokens=*" %%v in ('cd') do (set WD=%%v) | |
set "TOOLS=!WD!\tools" | |
set "SRCDIR=!WD!\source" | |
set "BUILDDIR=!WD!\build\!BUILDTYPE!" | |
echo . | |
echo "------------------------------------------------------------" | |
echo "- INITIAL DIR : !WD!" | |
echo "- TOOLS DIR : !TOOLS!" | |
echo "- SOURCE DIR : !SRCDIR!" | |
echo "- BUILD DIR : !BUILDDIR!" | |
echo "------------------------------------------------------------" | |
echo . | |
REM # ----------------------------------------------------------- | |
REM # Download tools | |
IF NOT EXIST "!TOOLS!" CALL :downloadTools | |
REM # ----------------------------------------------------------- | |
REM # Configure | |
set "PATH=!TOOLS!\depot_tools\;!PATH!" | |
set DEPOT_TOOLS_WIN_TOOLCHAIN=0 | |
set GYP_MSVS_VERSION=2019 | |
set WEBRTCM84_ROOT="!SRCDIR!/src" | |
call git config --global user.email "user.email.com" | |
call git config --global user.name "User Name" | |
call "!VSPATH!\!VSINIT!" | |
if errorlevel 1 call :exitWithError "Visual studio setup failed, is visual studio installed?" | |
echo . | |
REM # ----------------------------------------------------------- | |
REM # Download code | |
IF NOT EXIST "!SRCDIR!" CALL :downloadWebrtc | |
REM # ----------------------------------------------------------- | |
REM # Build | |
IF NOT EXIST "!BUILDDIR!" CALL :buildWebrtc | |
exit /b 0 | |
REM #---------------------------------------------------------------- | |
REM # Functions | |
REM #---------------------------------------------------------------- | |
:downloadTools | |
echo " ---------- Downloading Tools... ----------" | |
echo . | |
call :createDir "!TOOLS!" | |
cd "!TOOLS!" | |
call curl https://storage.googleapis.com/chrome-infra/depot_tools.zip --output depot_tools.zip | |
call :createDir "!TOOLS!\depot_tools" | |
call tar -xf depot_tools.zip -C "!TOOLS!\depot_tools" | |
call del depot_tools.zip | |
exit /b 0 | |
:downloadWebrtc | |
echo " ---------- Downloading WebRTC Code... ----------" | |
echo . | |
call git clone https://github.com/microsoft/winrtc.git "!SRCDIR!" | |
cd "!SRCDIR!" | |
call gclient | |
call fetch --nohooks webrtc | |
cd "!SRCDIR!\src" | |
call git checkout branch-heads/4147 | |
call gclient sync -D -r branch-heads/4147 | |
cd "!SRCDIR!" | |
call "!SRCDIR!"\patches_for_WebRTC_org\m84\patchWebRTCM84.cmd | |
exit /b 0 | |
:buildWebrtc | |
echo " ---------- Build WebRTC Code... ----------" | |
echo . | |
call :createDir "!BUILDDIR!" | |
cd "!SRCDIR!\src" | |
call gn gen --ide=vs2019 !BUILDDIR! --filters=//:webrtc "--args=is_debug=false use_lld=false is_clang=false rtc_include_tests=false rtc_build_tools=false rtc_win_video_capture_winrt=true target_os=\"winuwp\" rtc_build_examples=false rtc_win_use_mf_h264=true enable_libaom=false rtc_enable_protobuf=false" | |
call gn args --list !BUILDDIR! | |
call ninja -C !BUILDDIR! | |
exit /b 0 | |
:exitWithError | |
echo %1 | |
exit /b | |
:createDir | |
IF NOT EXIST "%1" ( | |
mkdir %1 | |
if errorlevel 1 call :exitWithError "Failed to create directory: %1" | |
) | |
exit /b 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment