You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #!/usr/bin/env python
  2. # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
  3. #
  4. # Use of this source code is governed by a BSD-style license
  5. # that can be found in the LICENSE file in the root of the source
  6. # tree. An additional intellectual property rights grant can be found
  7. # in the file PATENTS. All contributing project authors may
  8. # be found in the AUTHORS file in the root of the source tree.
  9. """Builds the AppRTC collider using the golang toolchain.
  10. The golang toolchain is downloaded by download_apprtc.py. We use that here
  11. to build the AppRTC collider server.
  12. This script needs to know the path to the 'src' directory in apprtc, the
  13. root directory of 'go' and the output_dir.
  14. """
  15. import fileinput
  16. import os
  17. import shutil
  18. import subprocess
  19. import sys
  20. import utils
  21. USAGE_STR = "Usage: {} <apprtc_dir> <go_dir> <output_dir>"
  22. def _ConfigureApprtcServerToDeveloperMode(app_yaml_path):
  23. for line in fileinput.input(app_yaml_path, inplace=True):
  24. # We can't click past these in browser-based tests, so disable them.
  25. line = line.replace('BYPASS_JOIN_CONFIRMATION: false',
  26. 'BYPASS_JOIN_CONFIRMATION: true')
  27. sys.stdout.write(line)
  28. def main(argv):
  29. if len(argv) != 4:
  30. return USAGE_STR.format(argv[0])
  31. apprtc_dir = os.path.abspath(argv[1])
  32. go_root_dir = os.path.abspath(argv[2])
  33. golang_workspace = os.path.abspath(argv[3])
  34. app_yaml_path = os.path.join(apprtc_dir, 'out', 'app_engine', 'app.yaml')
  35. _ConfigureApprtcServerToDeveloperMode(app_yaml_path)
  36. utils.RemoveDirectory(golang_workspace)
  37. collider_dir = os.path.join(apprtc_dir, 'src', 'collider')
  38. shutil.copytree(collider_dir, os.path.join(golang_workspace, 'src'))
  39. golang_path = os.path.join(go_root_dir, 'bin',
  40. 'go' + utils.GetExecutableExtension())
  41. golang_env = os.environ.copy()
  42. golang_env['GOROOT'] = go_root_dir
  43. golang_env['GOPATH'] = golang_workspace
  44. collider_out = os.path.join(golang_workspace,
  45. 'collidermain' + utils.GetExecutableExtension())
  46. subprocess.check_call([golang_path, 'build', '-o', collider_out,
  47. 'collidermain'], env=golang_env)
  48. if __name__ == '__main__':
  49. sys.exit(main(sys.argv))