Switch to AppRTC provided by webrtc/src.

This uses the simpler extraction script and packaging method developed in https://webrtc.googlesource.com/src/+/1d7392a45c95794b385f6a7c3a9dfa5428c4bbed

https://chromium-review.googlesource.com/c/chromium/src/+/992320 updates the paths

Bug: webrtc:7602

Change-Id: Ia10eb621a8903e2193621a624de14958d22a06ad
Reviewed-on: https://webrtc-review.googlesource.com/66463
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
diff --git a/DEPS b/DEPS
index ebd6820..8a394a3 100644
--- a/DEPS
+++ b/DEPS
@@ -1,47 +1,12 @@
 # DEPS file that pulls down dependencies that are needed to build and
 # execute WebRTC specific tests from a Chromium checkout.
 
-vars = {
-  'git_url':
-     'https://chromium.googlesource.com'
-}
-
-deps = {
-  'webrtc.DEPS/third_party/requests/':
-    Var('git_url') + '/external/github.com/kennethreitz/requests.git@2128321b85dfd969498e5d1636dcc3c4a27917ba'
-}
-
 hooks = [
   {
     "pattern": ".",
     "action" : ["python",
-                "webrtc.DEPS/download_apprtc_appengine_and_mercurial.py",
-                "webrtc.DEPS"],
-  },
-  {
-    "pattern": ".",
-    "action" : ["python",
-                "webrtc.DEPS/download_golang.py",
-                "webrtc.DEPS"],
-  },
-  {
-    # "Build" AppRTC, i.e. move it to the out/ dir where the browser test
-    # can find it. This is only done on runhooks.
-    "pattern": ".",
-    "action" : ["python",
-                "webrtc.DEPS/copy_apprtc.py"],
-  },
-  {
-    # Build Mercurial which is needed by the golang toolchain.
-    "pattern": ".",
-    "action" : ["python",
-                "webrtc.DEPS/build_mercurial_local.py"],
-  },
-  {
-    # Build AppRTC Collider using the golang toolchain.
-    "pattern": ".",
-    "action" : ["python",
-                "webrtc.DEPS/build_apprtc_collider.py"],
+                "src/third_party/webrtc/rtc_tools/testing/setup_apprtc.py",
+                "src/out"],
   },
   {
     # Download media files and tools used by the webrtc quality browser tests,
diff --git a/build_apprtc_collider.py b/build_apprtc_collider.py
deleted file mode 100755
index 95ae532..0000000
--- a/build_apprtc_collider.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/python
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Builds the AppRTC collider using the golang toolchain.
-
-The golang toolchain is downloaded by download_golang.py. We use that here
-to build the AppRTC collider server.
-"""
-
-import os
-import shutil
-import subprocess
-import sys
-import tempfile
-
-import utils
-
-
-def main():
-  apprtc_dir = os.path.join('apprtc', 'src')
-  golang_workspace = os.path.join('src', 'out', 'go-workspace')
-  utils.RemoveDirectory(golang_workspace)
-
-  golang_workspace_src = os.path.join(golang_workspace, 'src')
-
-  collider_dir = os.path.join(apprtc_dir, 'collider')
-  shutil.copytree(collider_dir, golang_workspace_src,
-                  ignore=shutil.ignore_patterns('.svn', '.git'))
-
-  golang_binary = 'go%s' % ('.exe' if utils.GetPlatform() == 'win' else '')
-  golang_path = os.path.join('go', 'bin', golang_binary)
-
-  golang_env = os.environ.copy()
-  golang_env['GOROOT'] = os.path.abspath('go')
-  golang_env['GOPATH'] = os.path.abspath(golang_workspace)
-  golang_env['PATH'] += os.pathsep + os.path.abspath('mercurial')
-  subprocess.check_call([golang_path, 'get', 'collidermain'],
-                        env=golang_env)
-  subprocess.check_call([golang_path, 'build', 'collidermain'],
-                        env=golang_env)
-
-  # Delete everything in the workspace except the build artifacts.
-  go_bin_dir = os.path.join(golang_workspace, 'bin')
-  tmp_dir = tempfile.mkdtemp()
-  shutil.move(go_bin_dir, tmp_dir)
-  utils.RemoveDirectory(golang_workspace)
-  os.makedirs(golang_workspace)
-  shutil.move(os.path.join(tmp_dir, 'bin'), go_bin_dir)
-  os.rmdir(tmp_dir)
-
-if __name__ == '__main__':
-  sys.exit(main())
-
diff --git a/build_mercurial_local.py b/build_mercurial_local.py
deleted file mode 100755
index 3170641..0000000
--- a/build_mercurial_local.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/python
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Builds a local mercurial (hg) copy.
-
-This is used by the go toolchain.
-"""
-
-import os
-import shutil
-import subprocess
-import sys
-
-import utils
-
-
-def main():
-  if not os.path.exists('mercurial'):
-    return 'Expected mercurial at %s.' % os.path.abspath('mercurial')
-
-  os.chdir('mercurial')
-
-  if utils.GetPlatform() == 'win':
-    subprocess.check_call(['python', 'setup.py', '--pure', 'build_py', '-c',
-                           '-d', '.', 'build_ext',
-                           '-i', 'build_mo', '--force'])
-    with open('hg.bat', 'w') as put_hg_in_path:
-      # Write a hg.bat since the go toolchain expects to find something called
-      # 'hg' in the path, but Windows only recognizes executables ending with
-      # an extension in PATHEXT. Writing hg.bat effectively makes 'hg' callable
-      # if the mercurial folder is in PATH.
-      mercurial_path = os.path.abspath('hg')
-      put_hg_in_path.write('python %s %%*' % mercurial_path)
-  else:
-    subprocess.check_call(['make', 'local'])
-
-if __name__ == '__main__':
-  sys.exit(main())
diff --git a/copy_apprtc.py b/copy_apprtc.py
deleted file mode 100755
index 6d09953..0000000
--- a/copy_apprtc.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/python
-# Copyright 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Moves Apprtc to the out/ directory, where the browser test can find it."""
-
-import fileinput
-import os
-import shutil
-import subprocess
-import sys
-
-import utils
-
-
-def _ConfigureApprtcServerToDeveloperMode(app_yaml_path):
-  if not os.path.exists(app_yaml_path):
-    return 'Expected app.yaml at %s.' % os.path.abspath(app_yaml_path)
-
-  for line in fileinput.input(app_yaml_path, inplace=True):
-    # We can't click past these in the firefox interop test, so
-    # disable them.
-    line = line.replace('BYPASS_JOIN_CONFIRMATION: false',
-                        'BYPASS_JOIN_CONFIRMATION: true')
-    sys.stdout.write(line)
-
-
-def RemoveDirectory(path):
-  if utils.GetPlatform() == 'win':
-    # Allow clobbering of out dir using cygwin until crbug.com/567538 is fixed.
-    drive, path = os.path.splitdrive(os.path.abspath(path))
-    drive = drive.lower()[0]
-    cygwin_full_path = '/cygdrive/%s%s' % (drive, path.replace('\\', '/'))
-
-    # Now it should be like /cygdrive/c/b/build/slave/Win7_Tester/build/src/out
-    cmd = 'c:\\cygwin\\bin\\bash --login -c "rm -rf %s"' % cygwin_full_path
-    subprocess.check_call(cmd)
-  else:
-    utils.RemoveDirectory(path)
-
-
-def main():
-  target_dir = os.path.join('src', 'out', 'apprtc')
-  RemoveDirectory(target_dir)
-  shutil.copytree('apprtc',
-                  target_dir, ignore=shutil.ignore_patterns('.svn', '.git'))
-
-  app_yaml_path = os.path.join(target_dir, 'out', 'app_engine', 'app.yaml')
-  _ConfigureApprtcServerToDeveloperMode(app_yaml_path)
-
-
-if __name__ == '__main__':
-  sys.exit(main())
-
diff --git a/download_apprtc_appengine_and_mercurial.py b/download_apprtc_appengine_and_mercurial.py
deleted file mode 100755
index 6617329..0000000
--- a/download_apprtc_appengine_and_mercurial.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python
-# Copyright 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Downloads the appengine SDK from WebRTC storage and unpacks it.
-
-Requires that depot_tools is installed and in the PATH. This script expects
-to run with Chrome's base dir as the working directory, e.g. where the .gclient
-file is. This is what should happen if this script is invoked as a hook action.
-"""
-
-import glob
-import os
-import sys
-import subprocess
-
-import utils
-
-def _DownloadResources(webrtc_deps_path):
-  print 'Downloading files in %s...' % webrtc_deps_path
-
-  extension = 'bat' if 'win32' in sys.platform else 'py'
-  cmd = ['download_from_google_storage.%s' % extension,
-         '--bucket=chromium-webrtc-resources',
-         '--directory', webrtc_deps_path]
-  subprocess.check_call(cmd)
-
-
-def _StripVersionNumberFromMercurialFolder():
-  unpacked_name = glob.glob('mercurial*')
-  assert len(unpacked_name) == 1, 'Should have precisely one mercurial!'
-  os.rename(unpacked_name[0], 'mercurial')
-
-
-def main(argv):
-  if len(argv) == 1:
-    return 'Usage: %s <path to webrtc.DEPS>' % argv[0]
-
-  webrtc_deps_path = argv[1]
-  appengine_zip_path = os.path.join(webrtc_deps_path, 'google-appengine.zip')
-  old_appengine_sha1 = utils.ComputeSHA1(appengine_zip_path)
-
-  mercurial_tar_path = os.path.join(webrtc_deps_path, 'mercurial-src.tar.gz')
-  old_mercurial_sha1 = utils.ComputeSHA1(mercurial_tar_path)
-
-  apprtc_zip_path = os.path.join(webrtc_deps_path, 'prebuilt_apprtc.zip')
-  old_apprtc_sha1 = utils.ComputeSHA1(apprtc_zip_path)
-
-  _DownloadResources(webrtc_deps_path)
-
-  if old_appengine_sha1 != utils.ComputeSHA1(appengine_zip_path):
-    utils.DeleteDirNextToGclient('google_appengine')
-    utils.UnpackToWorkingDir(appengine_zip_path)
-
-  if old_mercurial_sha1 != utils.ComputeSHA1(mercurial_tar_path):
-    utils.DeleteDirNextToGclient('mercurial')
-    utils.UnpackToWorkingDir(mercurial_tar_path)
-    _StripVersionNumberFromMercurialFolder()
-
-  if old_apprtc_sha1 != utils.ComputeSHA1(apprtc_zip_path):
-    utils.DeleteDirNextToGclient('apprtc')
-    utils.UnpackToWorkingDir(apprtc_zip_path)
-
-if __name__ == '__main__':
-  sys.exit(main(sys.argv))
diff --git a/download_golang.py b/download_golang.py
deleted file mode 100755
index ce7573e..0000000
--- a/download_golang.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/python
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Downloads the golang SDK from WebRTC storage and unpacks it.
-
-Requires that depot_tools is installed and in the PATH. This script expects
-to run with Chrome's base dir as the working directory, e.g. where the .gclient
-file is. This is what should happen if this script is invoked as a hook action.
-"""
-
-import os
-import subprocess
-import sys
-import tarfile
-import zipfile
-
-import utils
-
-
-def _GetGoArchivePathForPlatform():
-  archive_extension = 'zip' if utils.GetPlatform() == 'win' else 'tar.gz'
-  return os.path.join(utils.GetPlatform(), 'go.%s' % archive_extension)
-
-
-def main(argv):
-  if len(argv) == 1:
-    return 'Usage: %s <path to webrtc.DEPS>' % argv[0]
-  if not os.path.exists('.gclient'):
-    return 'Invoked from wrong dir; invoke from dir with .gclient'
-
-  webrtc_deps_path = argv[1]
-  golang_path = os.path.join(webrtc_deps_path, 'golang')
-  archive_path = os.path.join(golang_path, _GetGoArchivePathForPlatform())
-  old_archive_sha1 = utils.ComputeSHA1(archive_path)
-
-  utils.DownloadFilesFromGoogleStorage(golang_path)
-
-  if (old_archive_sha1 != utils.ComputeSHA1(archive_path)
-      or not os.path.exists('go')):
-    utils.DeleteDirNextToGclient('go')
-    utils.UnpackToWorkingDir(archive_path)
-
-
-if __name__ == '__main__':
-  sys.exit(main(sys.argv))
diff --git a/golang/linux/go.tar.gz.sha1 b/golang/linux/go.tar.gz.sha1
deleted file mode 100644
index 33671f2..0000000
--- a/golang/linux/go.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-a433f76c569055ff8536d796995518dd91a9fa5b
diff --git a/golang/mac/go.tar.gz.sha1 b/golang/mac/go.tar.gz.sha1
deleted file mode 100644
index f74b8e0..0000000
--- a/golang/mac/go.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-aecf5ec9360a004fdbff181269554892743f4bf6
diff --git a/golang/win/go.zip.sha1 b/golang/win/go.zip.sha1
deleted file mode 100644
index 6a7e1ad..0000000
--- a/golang/win/go.zip.sha1
+++ /dev/null
@@ -1 +0,0 @@
-26bf854fb81f12e9c80a146d8f0081cd22ae9d02
diff --git a/google-appengine.zip.sha1 b/google-appengine.zip.sha1
deleted file mode 100644
index cf13e4c..0000000
--- a/google-appengine.zip.sha1
+++ /dev/null
@@ -1 +0,0 @@
-827468f89c78f292c28ceac50e6109c8d649fa61
diff --git a/mercurial-src.tar.gz.sha1 b/mercurial-src.tar.gz.sha1
deleted file mode 100644
index 5ef3e9d..0000000
--- a/mercurial-src.tar.gz.sha1
+++ /dev/null
@@ -1 +0,0 @@
-a8a51aa412abd5155c7de29fd39c9774decb4d3f
\ No newline at end of file
diff --git a/prebuilt_apprtc.zip.sha1 b/prebuilt_apprtc.zip.sha1
deleted file mode 100644
index 7e2833e..0000000
--- a/prebuilt_apprtc.zip.sha1
+++ /dev/null
@@ -1 +0,0 @@
-6a96fc234cfa92ffaa79b0aeb5f4bdc1f31c6340
\ No newline at end of file
diff --git a/utils.py b/utils.py
deleted file mode 100755
index 5813271..0000000
--- a/utils.py
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/python
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Utilities for all our deps-management stuff."""
-
-import hashlib
-import os
-import shutil
-import sys
-import subprocess
-import tarfile
-import time
-import zipfile
-
-
-def RunSubprocessWithRetry(cmd):
-  """Invokes the subprocess and backs off exponentially on fail."""
-  for i in range(5):
-    try:
-      subprocess.check_call(cmd)
-      return
-    except subprocess.CalledProcessError as exception:
-      backoff = pow(2, i)
-      print 'Got %s, retrying in %d seconds...' % (exception, backoff)
-      time.sleep(backoff)
-
-  print 'Giving up.'
-  raise exception
-
-
-def DownloadFilesFromGoogleStorage(path):
-  print 'Downloading files in %s...' % path
-
-  extension = 'bat' if 'win32' in sys.platform else 'py'
-  cmd = ['download_from_google_storage.%s' % extension,
-         '--bucket=chromium-webrtc-resources',
-         '--auto_platform',
-         '--recursive',
-         '--directory', path]
-  subprocess.check_call(cmd)
-
-
-def ComputeSHA1(path):
-  if not os.path.exists(path):
-    return 0
-
-  sha1 = hashlib.sha1()
-  file_to_hash = open(path, 'rb')
-  try:
-    sha1.update(file_to_hash.read())
-  finally:
-    file_to_hash.close()
-
-  return sha1.hexdigest()
-
-
-# Code partially copied from
-# https://cs.chromium.org#chromium/build/scripts/common/chromium_utils.py
-def RemoveDirectory(*path):
-  """Recursively removes a directory, even if it's marked read-only.
-
-  Remove the directory located at *path, if it exists.
-
-  shutil.rmtree() doesn't work on Windows if any of the files or directories
-  are read-only, which svn repositories and some .svn files are.  We need to
-  be able to force the files to be writable (i.e., deletable) as we traverse
-  the tree.
-
-  Even with all this, Windows still sometimes fails to delete a file, citing
-  a permission error (maybe something to do with antivirus scans or disk
-  indexing).  The best suggestion any of the user forums had was to wait a
-  bit and try again, so we do that too.  It's hand-waving, but sometimes it
-  works. :/
-  """
-  file_path = os.path.join(*path)
-  if not os.path.exists(file_path):
-    return
-
-  if sys.platform == 'win32':
-    # Give up and use cmd.exe's rd command.
-    file_path = os.path.normcase(file_path)
-    for _ in xrange(3):
-      print 'RemoveDirectory running %s' % (' '.join(
-          ['cmd.exe', '/c', 'rd', '/q', '/s', file_path]))
-      if not subprocess.call(['cmd.exe', '/c', 'rd', '/q', '/s', file_path]):
-        break
-      print '  Failed'
-      time.sleep(3)
-    return
-  else:
-    shutil.rmtree(file_path, ignore_errors=True)
-
-
-def DeleteDirNextToGclient(directory):
-  # Sanity check to avoid nuking the wrong dirs.
-  if not os.path.exists('.gclient'):
-    raise Exception('Invoked from wrong dir; invoke from dir with .gclient')
-  print 'Deleting %s in %s...' % (directory, os.getcwd())
-  RemoveDirectory(directory)
-
-
-def UnpackToWorkingDir(archive_path):
-  extension = os.path.splitext(archive_path)[1]
-  if extension == '.zip':
-    _Unzip(archive_path)
-  else:
-    _Untar(archive_path)
-
-
-def _Unzip(path):
-  print 'Unzipping %s in %s...' % (path, os.getcwd())
-  zip_file = zipfile.ZipFile(path)
-  try:
-    zip_file.extractall()
-  finally:
-    zip_file.close()
-
-
-def _Untar(path):
-  print 'Untarring %s in %s...' % (path, os.getcwd())
-  tar_file = tarfile.open(path, 'r:gz')
-  try:
-    tar_file.extractall()
-  finally:
-    tar_file.close()
-
-
-def GetPlatform():
-  if sys.platform.startswith('win'):
-    return 'win'
-  if sys.platform.startswith('linux'):
-    return 'linux'
-  if sys.platform.startswith('darwin'):
-    return 'mac'
-  raise Exception("Can't run on platform %s." % sys.platform)
-