| 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 fileinput | 12 import fileinput |
| 13 import os | 13 import os |
| 14 import shutil | 14 import shutil |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 import utils | 17 import utils |
| 18 | 18 |
| 19 | 19 |
| 20 # Phantomjs generates very deep paths in the node_modules structure and | 20 # Phantomjs generates very deep paths in the node_modules structure and |
| 21 # Windows can't deal with that, so just hack that out. | 21 # Windows can't deal with that, so just hack that out. |
| 22 def _WorkaroundPhantomJsOnWin(samples_path): | 22 def _WorkaroundPhantomJsOnWin(samples_path): |
| 23 if utils.GetPlatform() is 'win': | 23 if utils.GetPlatform() is 'win': |
| 24 package_json = os.path.join(samples_path, 'package.json') | 24 package_json = os.path.join(samples_path, 'package.json') |
| 25 if not os.path.exists(package_json): | 25 if not os.path.exists(package_json): |
| 26 raise Exception('Expected %s to exist.' % os.path.abspath(package_json)) | 26 raise Exception('Expected %s to exist.' % os.path.abspath(package_json)) |
| 27 | 27 |
| 28 for line in fileinput.input(package_json, inplace=True): | 28 for line in fileinput.input(package_json, inplace=True): |
| 29 if not 'phantomjs' in line: | 29 if not 'phantomjs' in line: |
| 30 print line | 30 sys.stdout.write(line) |
| 31 | 31 |
| 32 | 32 |
| 33 def main(): | 33 def main(): |
| 34 node_path = os.path.abspath('node') | 34 node_path = os.path.abspath('node') |
| 35 if not os.path.exists(node_path): | 35 if not os.path.exists(node_path): |
| 36 return 'Expected node at %s.' % node_path | 36 return 'Expected node at %s.' % node_path |
| 37 samples_path = os.path.join('src', 'out', 'webrtc-samples') | 37 samples_path = os.path.join('src', 'out', 'webrtc-samples') |
| 38 if not os.path.exists(samples_path): | 38 if not os.path.exists(samples_path): |
| 39 return 'Expected webrtc-samples at %s.' % os.path.abspath(samples_path) | 39 return 'Expected webrtc-samples at %s.' % os.path.abspath(samples_path) |
| 40 | 40 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 54 if not os.path.exists(local_grunt_bin): | 54 if not os.path.exists(local_grunt_bin): |
| 55 return ('Missing grunt-cli in the webrtc-samples checkout; did ' | 55 return ('Missing grunt-cli in the webrtc-samples checkout; did ' |
| 56 'npm install fail?') | 56 'npm install fail?') |
| 57 | 57 |
| 58 utils.RunSubprocessWithRetry([node_bin, local_grunt_bin, | 58 utils.RunSubprocessWithRetry([node_bin, local_grunt_bin, |
| 59 'closurecompiler:debug']) | 59 'closurecompiler:debug']) |
| 60 | 60 |
| 61 | 61 |
| 62 if __name__ == '__main__': | 62 if __name__ == '__main__': |
| 63 sys.exit(main()) | 63 sys.exit(main()) |
| OLD | NEW |