Skip to content

Commit

Permalink
WebRTC r6818 build file for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bear101 committed Dec 1, 2024
1 parent 890597b commit 848d984
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 38 deletions.
39 changes: 22 additions & 17 deletions Library/TeamTalkLib/build/webrtc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@ include(ExternalProject)
set (TOOLCHAIN_INSTALL_PREFIX_WEBRTC ${TOOLCHAIN_INSTALL_PREFIX}/webrtc)

if (MSVC)
# WebRTC for Windows depends on "Windows 11 SDK (10.0.22621.0)". This
# can be installed from Visual Studio Installer.
#
# WebRTC for Windows depends on "C++ Clang Compiler for Windows (18.1.8)".
# This can be installed from Visual Studio Installer.

# Force C:\webrtc to avoid build errors due to long path names (MAX_PATH=260)
set (WEBRTC_FETCH_PATH C:/webrtc/${CMAKE_SYSTEM_NAME})
file(TO_NATIVE_PATH ${WEBRTC_FETCH_PATH} WEBRTC_FETCH_PATH_NATIVE)

set (WEBRTC_SOURCE_ROOT ${WEBRTC_FETCH_PATH}/src)
file(TO_NATIVE_PATH ${WEBRTC_SOURCE_ROOT} WEBRTC_SOURCE_ROOT_NATIVE)

if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
if (IS_ABSOLUTE ${TOOLCHAIN_INSTALL_PREFIX})
set (WEBRTC_INSTALL_ROOT ${TOOLCHAIN_INSTALL_PREFIX_WEBRTC}/x64)
Expand Down Expand Up @@ -50,19 +60,20 @@ if (MSVC)
ExternalProject_Get_Property(depot-tools SOURCE_DIR)
set (DEPOTTOOLS_DIR ${SOURCE_DIR})
file (TO_NATIVE_PATH ${DEPOTTOOLS_DIR} DEPOTTOOLS_DIR_NATIVE)
configure_file(${CMAKE_CURRENT_LIST_DIR}/depottools-win.bat_sample ${CMAKE_CURRENT_BINARY_DIR}/depottools-win.bat @ONLY)

if (NOT EXISTS ${WEBRTC_SOURCE_ROOT})
message (WARNING "WebRTC is not present in ${WEBRTC_SOURCE_ROOT}. Downloading... This takes a loooong time")
set (WEBRTC_FETCH_CMD1 SET DEPOT_TOOLS_WIN_TOOLCHAIN=0)
set (WEBRTC_FETCH_CMD2 SET PATH=${DEPOTTOOLS_DIR_NATIVE}$<SEMICOLON>%PATH%$<SEMICOLON>)
set (WEBRTC_FETCH_CMD3 cd ${WEBRTC_FETCH_PATH})
set (WEBRTC_FETCH_CMD4 CALL fetch --nohooks webrtc)
set (WEBRTC_FETCH_CMD5 CALL gclient sync --with_branch_heads --with_tags)
set (WEBRTC_FETCH_CMD6 cd ${WEBRTC_SOURCE_ROOT})
set (WEBRTC_FETCH_CMD7 CALL git checkout branch-heads/4332)
set (WEBRTC_FETCH_CMD8 CALL gclient sync -D)
set (WEBRTC_FETCH_CMD1 ${CMAKE_CURRENT_BINARY_DIR}/depottools-win.bat)
set (WEBRTC_FETCH_CMD2 echo "Skip WebRTC CMD")
set (WEBRTC_FETCH_CMD3 echo "Skip WebRTC CMD")
set (WEBRTC_FETCH_CMD4 echo "Skip WebRTC CMD")
set (WEBRTC_FETCH_CMD5 echo "Skip WebRTC CMD")
set (WEBRTC_FETCH_CMD6 echo "Skip WebRTC CMD")
set (WEBRTC_FETCH_CMD7 echo "Skip WebRTC CMD")
set (WEBRTC_FETCH_CMD8 echo "Skip WebRTC CMD")
set (WEBRTC_PATCH_CMD1 cd ${WEBRTC_SOURCE_ROOT})
set (WEBRTC_PATCH_CMD2 CALL git apply ${CMAKE_CURRENT_LIST_DIR}\\libteamtalk-r4332.patch)
set (WEBRTC_PATCH_CMD2 CALL git apply ${CMAKE_CURRENT_LIST_DIR}\\libteamtalk-r6818.patch)
else()
message (WARNING "WebRTC is already downloaded to ${WEBRTC_SOURCE_ROOT}. Skipping new fetch and patching")
set (WEBRTC_FETCH_CMD1 echo "Skipping WebRTC fetching")
Expand All @@ -76,11 +87,8 @@ if (MSVC)
set (WEBRTC_PATCH_CMD2 echo "Skipping WebRTC patching")
endif()

# WebRTC for Windows depends on Windows SDK v10.0.20348.0. This
# can be downloaded from Visual Studio Installer

configure_file(${CMAKE_CURRENT_LIST_DIR}/webrtc_cfg_win.bat_sample ${CMAKE_CURRENT_BINARY_DIR}/webrtc_cfg_win.bat)

ExternalProject_Add(webrtc-src
DOWNLOAD_COMMAND ${WEBRTC_FETCH_CMD1}
COMMAND ${WEBRTC_FETCH_CMD2}
Expand All @@ -97,7 +105,7 @@ if (MSVC)
CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/webrtc_cfg_win.bat
COMMAND cd ${WEBRTC_SOURCE_ROOT}
COMMAND CALL gn gen <INSTALL_DIR>\\lib\\debug
COMMAND CALL gn gen <INSTALL_DIR>\\lib\\release
COMMAND CALL gn gen <INSTALL_DIR>\\lib\\release
BUILD_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/webrtc_cfg_win.bat
COMMAND CALL ninja -v -C <INSTALL_DIR>\\lib\\debug teamtalk
COMMAND CALL ninja -v -C <INSTALL_DIR>\\lib\\release teamtalk
Expand All @@ -111,7 +119,6 @@ if (MSVC)
)

file(MAKE_DIRECTORY ${WEBRTC_INSTALL_ROOT}/include)
file(MAKE_DIRECTORY ${WEBRTC_INSTALL_ROOT}/include/modules/audio_processing/include)
file(MAKE_DIRECTORY ${WEBRTC_INSTALL_ROOT}/include/third_party/abseil-cpp)
endif()

Expand All @@ -122,7 +129,6 @@ if (MSVC)
endif()
target_include_directories (webrtc INTERFACE
${WEBRTC_INSTALL_ROOT}/include
${WEBRTC_INSTALL_ROOT}/include/modules/audio_processing/include
${WEBRTC_INSTALL_ROOT}/include/third_party/abseil-cpp)
set_target_properties(webrtc PROPERTIES
IMPORTED_LOCATION_DEBUG ${WEBRTC_INSTALL_ROOT}/lib/debug/obj/modules/audio_processing/teamtalk.lib
Expand All @@ -134,7 +140,6 @@ if (MSVC)
endif()
target_include_directories (webrtc INTERFACE
${WEBRTC_INSTALL_ROOT}/include
${WEBRTC_INSTALL_ROOT}/include/modules/audio_processing/include
${WEBRTC_INSTALL_ROOT}/include/third_party/abseil-cpp)
set_target_properties(webrtc PROPERTIES
IMPORTED_LOCATION_DEBUG ${WEBRTC_INSTALL_ROOT}/lib/debug/obj/modules/audio_processing/teamtalk.lib
Expand Down
16 changes: 0 additions & 16 deletions Library/TeamTalkLib/build/webrtc/README.md

This file was deleted.

7 changes: 5 additions & 2 deletions Library/TeamTalkLib/build/webrtc/args.gn_win_debug
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
enable_iterator_debugging=true
is_clang=false
is_clang=true
is_debug=true
libsrtp_build_boringssl=false
libsrtp_ssl_root=""
rtc_build_examples=false
rtc_build_libvpx=false
rtc_build_ssl=false
Expand All @@ -12,6 +14,7 @@ rtc_exclude_field_trial_default=true
rtc_include_opus=false
rtc_include_tests=false
rtc_libvpx_build_vp9=false
rtc_ssl_root="@OPENSSL_DIR@/include"
rtc_ssl_root=""
target_cpu="@WEBRTC_ARCH@"
use_custom_libcxx=false
use_lld=false
5 changes: 3 additions & 2 deletions Library/TeamTalkLib/build/webrtc/args.gn_win_release
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
is_clang=false
is_clang=true
is_debug=false
libsrtp_build_boringssl=false
rtc_build_examples=false
rtc_build_libvpx=false
rtc_build_ssl=false
Expand All @@ -11,6 +12,6 @@ rtc_exclude_field_trial_default=true
rtc_include_opus=false
rtc_include_tests=false
rtc_libvpx_build_vp9=false
rtc_ssl_root="@OPENSSL_DIR@/include"
target_cpu="@WEBRTC_ARCH@"
use_custom_libcxx=false
use_lld=false
24 changes: 24 additions & 0 deletions Library/TeamTalkLib/build/webrtc/depottools-win.bat_sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
IF NOT "%ERRORLEVEL%" == "0" GOTO fail
SET PATH=%PATH%;@DEPOTTOOLS_DIR_NATIVE@
IF NOT "%ERRORLEVEL%" == "0" GOTO fail
CD @WEBRTC_FETCH_PATH_NATIVE@
IF NOT "%ERRORLEVEL%" == "0" GOTO fail
fetch.bat --nohooks webrtc
IF NOT "%ERRORLEVEL%" == "0" GOTO fail
gclient sync --with_branch_heads --with_tags
IF NOT "%ERRORLEVEL%" == "0" GOTO fail

cd @WEBRTC_SOURCE_ROOT_NATIVE@
IF NOT "%ERRORLEVEL%" == "0" GOTO fail
git checkout branch-heads/6818
IF NOT "%ERRORLEVEL%" == "0" GOTO fail
gclient sync -D
IF NOT "%ERRORLEVEL%" == "0" GOTO fail

@ECHO Finished fetching WebRTC

EXIT /B 0

:fail
EXIT /B 1
2 changes: 1 addition & 1 deletion Library/TeamTalkLib/build/webrtc/webrtc_cfg_win.bat_sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
SET PATH=@DEPOTTOOLS_DIR_NATIVE@;%PATH%
SET PATH=%PATH%;@DEPOTTOOLS_DIR_NATIVE@

0 comments on commit 848d984

Please sign in to comment.