Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Builds the AppRTC collider using the golang toolchain. | 6 """Builds the AppRTC collider using the golang toolchain. |
| 7 | 7 |
| 8 The golang toolchain is downloaded by download_golang.py. We use that here | 8 The golang toolchain is downloaded by download_golang.py. We use that here |
| 9 to build the AppRTC collider server. | 9 to build the AppRTC collider server. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import os | 12 import os |
| 13 import shutil | 13 import shutil |
| 14 import subprocess | 14 import subprocess |
| 15 import sys | 15 import sys |
| 16 import tempfile | |
| 16 | 17 |
| 17 import utils | 18 import utils |
| 18 | 19 |
| 19 | 20 |
| 20 def main(): | 21 def main(): |
| 21 apprtc_dir = os.path.join('apprtc', 'src') | 22 apprtc_dir = os.path.join('apprtc', 'src') |
| 22 golang_workspace = os.path.join('src', 'out', 'go-workspace') | 23 golang_workspace = os.path.join('src', 'out', 'go-workspace') |
| 23 utils.RemoveDirectory(golang_workspace) | 24 utils.RemoveDirectory(golang_workspace) |
| 24 | 25 |
| 25 golang_workspace_src = os.path.join(golang_workspace, 'src') | 26 golang_workspace_src = os.path.join(golang_workspace, 'src') |
| 26 | 27 |
| 27 collider_dir = os.path.join(apprtc_dir, 'collider') | 28 collider_dir = os.path.join(apprtc_dir, 'collider') |
| 28 shutil.copytree(collider_dir, golang_workspace_src, | 29 shutil.copytree(collider_dir, golang_workspace_src, |
| 29 ignore=shutil.ignore_patterns('.svn', '.git')) | 30 ignore=shutil.ignore_patterns('.svn', '.git')) |
| 30 | 31 |
| 31 golang_binary = 'go%s' % ('.exe' if utils.GetPlatform() == 'win' else '') | 32 golang_binary = 'go%s' % ('.exe' if utils.GetPlatform() == 'win' else '') |
| 32 golang_path = os.path.join('go', 'bin', golang_binary) | 33 golang_path = os.path.join('go', 'bin', golang_binary) |
| 33 | 34 |
| 34 golang_env = os.environ.copy() | 35 golang_env = os.environ.copy() |
| 35 golang_env['GOROOT'] = os.path.abspath('go') | 36 golang_env['GOROOT'] = os.path.abspath('go') |
| 36 golang_env['GOPATH'] = os.path.abspath(golang_workspace) | 37 golang_env['GOPATH'] = os.path.abspath(golang_workspace) |
| 37 golang_env['PATH'] += os.pathsep + os.path.abspath('mercurial') | 38 golang_env['PATH'] += os.pathsep + os.path.abspath('mercurial') |
| 38 subprocess.check_call([golang_path, 'get', 'collidermain'], | 39 subprocess.check_call([golang_path, 'get', 'collidermain'], |
| 39 env=golang_env) | 40 env=golang_env) |
| 40 subprocess.check_call([golang_path, 'build', 'collidermain'], | 41 subprocess.check_call([golang_path, 'build', 'collidermain'], |
| 41 env=golang_env) | 42 env=golang_env) |
| 42 | 43 |
| 44 # Delete everything in the workspace except the build artifacts. | |
| 45 go_bin_dir = os.path.join(golang_workspace, 'bin') | |
| 46 tmp_dir = tempfile.mkdtemp() | |
| 47 shutil.move(go_bin_dir, tmp_dir) | |
| 48 shutil.rmtree(golang_workspace) | |
|
kjellander_chromium
2016/02/09 16:27:29
If you remove src/out/go-workspace here, then tryi
| |
| 49 shutil.move(os.path.join(tmp_dir, 'bin'), go_bin_dir) | |
| 50 os.rmdir(tmp_dir) | |
| 51 | |
| 43 if __name__ == '__main__': | 52 if __name__ == '__main__': |
| 44 sys.exit(main()) | 53 sys.exit(main()) |
| 45 | 54 |
| OLD | NEW |