Files
Aethera/web_server/cmake/build_webrtc.ps1
T
2026-08-23 12:58:44 +08:00

162 lines
2.1 KiB
PowerShell

$ErrorActionPreference = "Stop"
$ROOT = "D:\ae\cached_external_library\win_webrtc"
$DEPOT_TOOLS = "$ROOT\depot_tools"
$WEBRTC_ROOT = "$ROOT\src"
$OUT_DIR = "out\release"
Write-Host "=============================="
Write-Host "WebRTC Build"
Write-Host "ROOT=$ROOT"
Write-Host "=============================="
#
# Load VS2022 environment
#
$VS_DEV_CMD = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
if (!(Test-Path $VS_DEV_CMD))
{
throw "Cannot find VS2022 VsDevCmd.bat"
}
Write-Host "Loading VS2022 environment..."
cmd.exe /c "`"$VS_DEV_CMD`" -host_arch=x64 -arch=x64 && set" |
ForEach-Object {
if ($_ -match "^(.*?)=(.*)$")
{
$name = $matches[1]
$value = $matches[2]
Set-Item "env:$name" $value
}
}
#
# Create root
#
if (!(Test-Path $ROOT))
{
New-Item `
-ItemType Directory `
-Path $ROOT `
| Out-Null
}
#
# depot_tools
#
if (!(Test-Path $DEPOT_TOOLS))
{
Write-Host "Cloning depot_tools..."
git clone `
https://chromium.googlesource.com/chromium/tools/depot_tools.git `
$DEPOT_TOOLS
}
$env:PATH = "$DEPOT_TOOLS;$env:PATH"
Write-Host "Checking depot_tools..."
where.exe gclient
#
# Fetch WebRTC
#
if (!(Test-Path $WEBRTC_ROOT))
{
Write-Host "Fetching WebRTC..."
Set-Location $ROOT
fetch --nohooks webrtc
}
else
{
Write-Host "WebRTC source exists, skip fetch"
}
Set-Location $WEBRTC_ROOT
#
# Sync dependencies
#
Write-Host "Sync dependencies..."
gclient sync
#
# Run hooks
#
Write-Host "Run hooks..."
gclient runhooks
#
# Generate build files
#
Write-Host "Generate Ninja build..."
gn gen $OUT_DIR --args='
is_debug=false
is_component_build=false
target_cpu="x64"
rtc_build_examples=false
rtc_build_tools=false
rtc_include_tests=false
use_rtti=true
symbol_level=0
'
#
# Build
#
Write-Host "Build WebRTC..."
ninja -C $OUT_DIR
Write-Host ""
Write-Host "=============================="
Write-Host "WebRTC build finished"
Write-Host "Output:"
Write-Host "$WEBRTC_ROOT\$OUT_DIR"
Write-Host "=============================="