diff --git a/README.md b/README.md index a379ac7..6a3c311 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,7 @@ You can pass WebRTC version (branch) to script to fetch specific version. ``` git clone https://github.com/UltraCoderRU/libwebrtc.git cd libwebrtc - -# Linux -./sync.sh [WEBRTC_VERSION] - -# Windows -sync.bat [WEBRTC_VERSION] +python3 sync.py [WEBRTC_VERSION] ``` ## Compiling @@ -76,23 +71,14 @@ Create an output directory, browse inside it, then run CMake to configure projec ``` mkdir build cd build - -# Linux: -cmake -DCMAKE_BUILD_TYPE= -DCMAKE_INSTALL_PREFIX= .. - -# Windows -cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX= .. +cmake -G Ninja -DCMAKE_BUILD_TYPE= -DCMAKE_INSTALL_PREFIX= .. ``` After configuration build library using standard CMake commands. ``` -# Linux: cmake --build . -sudo cmake --build . --target install - -# Windows: -cmake --build . --config --target INSTALL +cmake --install . ``` The library will be located inside the `lib` subdirectory of the ``. diff --git a/sync.bat b/sync.bat deleted file mode 100644 index 61945de..0000000 --- a/sync.bat +++ /dev/null @@ -1,62 +0,0 @@ -@echo off - -REM To determine last stable WebRTC revision, -REM see https://chromiumdash.appspot.com/branches -REM and https://chromiumdash.appspot.com/schedule -set WEBRTC_REVISION=4280 - -set DEPOT_TOOLS_COMPATIBLE_REVISION=a964ca1296b - -if not "%1"=="" set WEBRTC_REVISION="%1" - -set REPO_ROOT=%~dp0 - -cd "%REPO_ROOT%" -if not exist "depot_tools" ( - echo Cloning Depot Tools... - git.exe clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - cd "%REPO_ROOT%\depot_tools" - python.exe update_depot_tools_toggle.py --disable -) - -set PATH=%REPO_ROOT%depot_tools;%PATH% -set DEPOT_TOOLS_WIN_TOOLCHAIN=0 - -if not exist "%REPO_ROOT%\webrtc" ( - echo "Updating Depot Tools to the latest revision..." - cd "%REPO_ROOT%\depot_tools" - git.exe checkout -q -f main - git.exe pull - - echo Cloning WebRTC... - mkdir "%REPO_ROOT%\webrtc" - cd "%REPO_ROOT%\webrtc" - fetch --nohooks webrtc - cd "%REPO_ROOT%\webrtc\src" - call gclient sync --nohooks --with_branch_heads -) - -REM Latest Depot Tools versions are not compatible -REM with old WebRTC versions, so we peek revision -REM from around the same time as the WebRTC and -REM forbid gclient to auto-update Depot Tools. -cd "%REPO_ROOT%\webrtc\src" -FOR /F "tokens=*" %%g IN ("git.exe log -n 1 --pretty=format:%ci \"branch-heads/%WEBRTC_REVISION%\"") do (SET LAST_WEBRTC_COMMIT_DATE=%%g) -cd "%REPO_ROOT%\depot_tools" -FOR /F "tokens=*" %%g IN ("git rev-list -n 1 --before=\"%LAST_WEBRTC_COMMIT_DATE%\" main") do (SET DEPOT_TOOLS_COMPATIBLE_REVISION=%%g) -echo "Updating Depot Tools to a compatible revision %DEPOT_TOOLS_COMPATIBLE_REVISION%..." -git.exe checkout -q -f %DEPOT_TOOLS_COMPATIBLE_REVISION% - -echo Updating WebRTC to version %WEBRTC_REVISION%... -cd %REPO_ROOT%\webrtc\src -call gclient sync --with_branch_heads --reset -git.exe fetch -git.exe checkout -f -B %WEBRTC_REVISION% branch-heads/%WEBRTC_REVISION% -call gclient sync --force -D --reset - -cd %REPO_ROOT% - - -echo Updating Depot Tools... -cd %REPO_ROOT%\depot_tools -call update_depot_tools.bat \ No newline at end of file diff --git a/sync.py b/sync.py new file mode 100755 index 0000000..7ae427e --- /dev/null +++ b/sync.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess +from pathlib import Path + + +def execute(command: str): + subprocess.run(command, shell=True, check=True) + + +def get_output(command: str): + return subprocess.run(command, capture_output=True, shell=True, check=True).stdout.decode() + + +# To determine last stable WebRTC revision, +# see https://chromiumdash.appspot.com/branches +# and https://chromiumdash.appspot.com/schedule +WEBRTC_REVISION = 4692 + +if len(sys.argv) == 2: + WEBRTC_REVISION = sys.argv[1] + +REPO_ROOT = Path(__file__).resolve().parent +DEPOT_TOOLS_DIR = REPO_ROOT / 'depot_tools' +WEBRTC_DIR = REPO_ROOT / 'webrtc' +SRC_DIR = WEBRTC_DIR / 'src' + +os.environ['PATH'] = '{}{}{}'.format(DEPOT_TOOLS_DIR, os.pathsep, os.environ['PATH']) +if sys.platform == 'win32': + os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0' + +os.chdir(REPO_ROOT) +if not os.path.isdir(DEPOT_TOOLS_DIR): + print('Cloning Depot Tools...') + execute('git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git') + os.chdir(DEPOT_TOOLS_DIR) + + if sys.platform == 'win32': + execute('gclient --version') + execute('where python') + + execute('python update_depot_tools_toggle.py --disable') +else: + print('Updating Depot Tools to the latest revision...') + os.chdir(DEPOT_TOOLS_DIR) + execute('git checkout -q -f main') + execute('git pull -q') + +if not os.path.isdir(WEBRTC_DIR): + print('Cloning WebRTC...') + os.mkdir(WEBRTC_DIR) + os.chdir(WEBRTC_DIR) + execute('fetch --nohooks webrtc') + os.chdir(SRC_DIR) + execute('gclient sync --with_branch_heads --nohooks') +else: + print('Updating WebRTC branches info...') + os.chdir(SRC_DIR) + execute('gclient sync --with_branch_heads --nohooks') + +# Latest Depot Tools versions are not compatible +# with old WebRTC versions, so we peek revision +# from around the same time as the WebRTC and +# forbid gclient to auto-update Depot Tools. +os.chdir(SRC_DIR) +LAST_WEBRTC_COMMIT_DATE = get_output('git log -n 1 --pretty=format:%ci branch-heads/{}'.format(WEBRTC_REVISION)).strip() +os.chdir(DEPOT_TOOLS_DIR) +DEPOT_TOOLS_COMPATIBLE_REVISION = get_output('git rev-list -n 1 --before="{}" main'.format(LAST_WEBRTC_COMMIT_DATE)).strip() +print('Updating Depot Tools to a compatible revision {}...'.format(DEPOT_TOOLS_COMPATIBLE_REVISION)) +execute('git checkout -f {}'.format(DEPOT_TOOLS_COMPATIBLE_REVISION)) + +print('Updating WebRTC to version {}...'.format(WEBRTC_REVISION)) +os.chdir(SRC_DIR) +execute('git clean -ffd') +execute('git checkout -q -B {} branch-heads/{}'.format(WEBRTC_REVISION, WEBRTC_REVISION)) +execute('gclient sync --force -D --reset') diff --git a/sync.sh b/sync.sh deleted file mode 100755 index 4b9975f..0000000 --- a/sync.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -set -e - -# To determine last stable WebRTC revision, -# see https://chromiumdash.appspot.com/branches -# and https://chromiumdash.appspot.com/schedule -WEBRTC_REVISION=4692 - -if [ $# -eq 1 ]; then - WEBRTC_REVISION=$1 -fi - -REPO_ROOT=$(dirname $(readlink -f $0)) - -cd ${REPO_ROOT} -if [ ! -d depot_tools ]; -then - echo "Cloning Depot Tools..." - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - cd ${REPO_ROOT}/depot_tools - python update_depot_tools_toggle.py --disable -else - echo "Updating Depot Tools to the latest revision..." - cd ${REPO_ROOT}/depot_tools - git checkout -q -f main - git pull -fi - -export PATH=${REPO_ROOT}/depot_tools:$PATH - -if [ ! -d ${REPO_ROOT}/webrtc ]; -then - echo "Cloning WebRTC..." - mkdir ${REPO_ROOT}/webrtc - cd ${REPO_ROOT}/webrtc - fetch --nohooks webrtc - cd ${REPO_ROOT}/webrtc/src - gclient sync --nohooks --with_branch_heads -else - echo "Updating WebRTC branches info..." - gclient sync --nohooks --with_branch_heads -fi - -# Latest Depot Tools versions are not compatible -# with old WebRTC versions, so we peek revision -# from around the same time as the WebRTC and -# forbid gclient to auto-update Depot Tools. -cd ${REPO_ROOT}/webrtc/src -LAST_WEBRTC_COMMIT_DATE=$(git log -n 1 --pretty=format:%ci "branch-heads/${WEBRTC_REVISION}") -cd ${REPO_ROOT}/depot_tools -DEPOT_TOOLS_COMPATIBLE_REVISION=$(git rev-list -n 1 --before="$LAST_WEBRTC_COMMIT_DATE" main) -echo "Updating Depot Tools to a compatible revision ${DEPOT_TOOLS_COMPATIBLE_REVISION}..." -git checkout -q -f ${DEPOT_TOOLS_COMPATIBLE_REVISION} - -echo "Updating WebRTC to version ${WEBRTC_REVISION}..." -cd ${REPO_ROOT}/webrtc/src -git clean -ffd -git checkout -B ${WEBRTC_REVISION} branch-heads/${WEBRTC_REVISION} -gclient sync --force -D --reset