build_libwebrtc_win.cmd 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. @echo off
  2. if not exist depot_tools (
  3. git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  4. )
  5. set COMMAND_DIR=%~dp0
  6. set PATH=%cd%\depot_tools;%PATH%
  7. set WEBRTC_VERSION=4515
  8. set DEPOT_TOOLS_WIN_TOOLCHAIN=0
  9. set CPPFLAGS=/WX-
  10. set GYP_GENERATORS=ninja,msvs-ninja
  11. set GYP_MSVS_VERSION=2019
  12. set OUTPUT_DIR=out
  13. set ARTIFACTS_DIR=%cd%\artifacts
  14. set PYPI_URL=https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
  15. set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
  16. if not exist src (
  17. powershell -Command "get-content depot_tools\update_depot_tools.bat | foreach-object {$_ -replace \"origin/master\",\"origin/main\"} | add-content depot_tools\update_depot_tools.bat.edited"
  18. move /Y depot_tools\update_depot_tools.bat.edited depot_tools\update_depot_tools.bat
  19. call fetch.bat --nohooks webrtc
  20. cd src
  21. call git.bat config --system core.longpaths true
  22. call git.bat checkout refs/remotes/branch-heads/%WEBRTC_VERSION%
  23. cd ..
  24. call gclient.bat sync -f
  25. )
  26. rem add jsoncpp
  27. patch -N "src\BUILD.gn" < "%COMMAND_DIR%\patches\add_jsoncpp.patch"
  28. rem install pywin32
  29. call "%cd%\depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin\python.exe" ^
  30. -m pip install pywin32 --index-url "%PYPI_URL%" --upgrade
  31. mkdir "%ARTIFACTS_DIR%\lib"
  32. setlocal enabledelayedexpansion
  33. for %%i in (x64) do (
  34. mkdir "%ARTIFACTS_DIR%/lib/%%i"
  35. for %%j in (true false) do (
  36. rem generate ninja for release
  37. call gn.bat gen %OUTPUT_DIR% --root="src" ^
  38. --args="is_debug=%%j is_clang=false target_cpu=\"%%i\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
  39. rem build
  40. ninja.exe -C %OUTPUT_DIR%
  41. set filename=
  42. if true==%%j (
  43. set filename=webrtcd.lib
  44. ) else (
  45. set filename=webrtc.lib
  46. )
  47. rem copy static library for release build
  48. copy "%OUTPUT_DIR%\obj\webrtc.lib" "%ARTIFACTS_DIR%\lib\%%i\!filename!"
  49. )
  50. )
  51. endlocal
  52. rem fix error when generate license
  53. patch -N "%cd%\src\tools_webrtc\libs\generate_licenses.py" < ^
  54. "%COMMAND_DIR%\patches\generate_licenses.patch"
  55. rem generate license
  56. call python.bat "%cd%\src\tools_webrtc\libs\generate_licenses.py" ^
  57. --target //:default %OUTPUT_DIR% %OUTPUT_DIR%
  58. rem unescape license
  59. powershell -File "%COMMAND_DIR%\Unescape.ps1" "%OUTPUT_DIR%\LICENSE.md"
  60. rem copy header
  61. xcopy src\*.h "%ARTIFACTS_DIR%\include" /C /S /I /F /H
  62. rem copy license
  63. copy "%OUTPUT_DIR%\LICENSE.md" "%ARTIFACTS_DIR%"
  64. rem create zip
  65. cd %ARTIFACTS_DIR%
  66. 7z a -tzip webrtc-win.zip *