OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """Invokes the AppRTC closure compiler. | 6 """Invokes the AppRTC closure compiler. |
7 | 7 |
8 The AppRTC javascript code must be closure-compiled. This script uses | 8 The AppRTC javascript code must be closure-compiled. This script uses |
9 the node toolchain we downloaded earlier. | 9 the node toolchain we downloaded earlier. |
10 """ | 10 """ |
11 | 11 |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import subprocess | |
15 import sys | 14 import sys |
16 | 15 |
17 import utils | 16 import utils |
18 | 17 |
19 | 18 |
20 def main(): | 19 def main(): |
21 node_path = os.path.abspath('node') | 20 node_path = os.path.abspath('node') |
22 if not os.path.exists(node_path): | 21 if not os.path.exists(node_path): |
23 return 'Expected node at %s.' % node_path | 22 return 'Expected node at %s.' % node_path |
24 samples_path = os.path.join('src', 'out', 'webrtc-samples') | 23 samples_path = os.path.join('src', 'out', 'webrtc-samples') |
25 if not os.path.exists(samples_path): | 24 if not os.path.exists(samples_path): |
26 return 'Expected webrtc-samples at %s.' % os.path.abspath(samples_path) | 25 return 'Expected webrtc-samples at %s.' % os.path.abspath(samples_path) |
27 | 26 |
28 os.chdir(samples_path) | 27 os.chdir(samples_path) |
29 | 28 |
30 if utils.GetPlatform() is 'win': | 29 if utils.GetPlatform() is 'win': |
31 npm_bin = os.path.join(node_path, 'npm.cmd') | 30 npm_bin = os.path.join(node_path, 'npm.cmd') |
32 node_bin = os.path.join(node_path, 'node.exe') | 31 node_bin = os.path.join(node_path, 'node.exe') |
33 else: | 32 else: |
34 npm_bin = os.path.join(node_path, 'bin', 'npm') | 33 npm_bin = os.path.join(node_path, 'bin', 'npm') |
35 node_bin = os.path.join(node_path, 'bin', 'node') | 34 node_bin = os.path.join(node_path, 'bin', 'node') |
36 | 35 |
37 subprocess.check_call([npm_bin, 'install']) | 36 utils.RunSubprocessWithRetry([npm_bin, 'install']) |
38 local_grunt_bin = os.path.join('node_modules', 'grunt-cli', 'bin', 'grunt') | 37 local_grunt_bin = os.path.join('node_modules', 'grunt-cli', 'bin', 'grunt') |
39 | 38 |
40 if not os.path.exists(local_grunt_bin): | 39 if not os.path.exists(local_grunt_bin): |
41 return ('Missing grunt-cli in the webrtc-samples checkout; did ' | 40 return ('Missing grunt-cli in the webrtc-samples checkout; did ' |
42 'npm install fail?') | 41 'npm install fail?') |
43 | 42 |
44 subprocess.check_call([node_bin, local_grunt_bin, 'closurecompiler:debug']) | 43 utils.RunSubprocessWithRetry([node_bin, local_grunt_bin, |
| 44 'closurecompiler:debug']) |
45 | 45 |
46 | 46 |
47 if __name__ == '__main__': | 47 if __name__ == '__main__': |
48 sys.exit(main()) | 48 sys.exit(main()) |
OLD | NEW |