| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Invokes the AppRTC closure compiler. | |
| 7 | |
| 8 The AppRTC javascript code must be closure-compiled. This script uses | |
| 9 the node toolchain we downloaded earlier. | |
| 10 """ | |
| 11 | |
| 12 import fileinput | |
| 13 import os | |
| 14 import shutil | |
| 15 import sys | |
| 16 | |
| 17 import utils | |
| 18 | |
| 19 | |
| 20 # Phantomjs generates very deep paths in the node_modules structure and | |
| 21 # Windows can't deal with that, so just hack that out. | |
| 22 def _WorkaroundPhantomJsOnWin(samples_path): | |
| 23 if utils.GetPlatform() is 'win': | |
| 24 package_json = os.path.join(samples_path, 'package.json') | |
| 25 if not os.path.exists(package_json): | |
| 26 raise Exception('Expected %s to exist.' % os.path.abspath(package_json)) | |
| 27 | |
| 28 for line in fileinput.input(package_json, inplace=True): | |
| 29 if not 'phantomjs' in line: | |
| 30 sys.stdout.write(line) | |
| 31 | |
| 32 | |
| 33 def main(): | |
| 34 node_path = os.path.abspath('node') | |
| 35 if not os.path.exists(node_path): | |
| 36 return 'Expected node at %s.' % node_path | |
| 37 samples_path = os.path.join('src', 'out', 'webrtc-samples') | |
| 38 if not os.path.exists(samples_path): | |
| 39 return 'Expected webrtc-samples at %s.' % os.path.abspath(samples_path) | |
| 40 | |
| 41 _WorkaroundPhantomJsOnWin(samples_path) | |
| 42 os.chdir(samples_path) | |
| 43 | |
| 44 if utils.GetPlatform() is 'win': | |
| 45 npm_bin = os.path.join(node_path, 'npm.cmd') | |
| 46 node_bin = os.path.join(node_path, 'node.exe') | |
| 47 else: | |
| 48 npm_bin = os.path.join(node_path, 'bin', 'npm') | |
| 49 node_bin = os.path.join(node_path, 'bin', 'node') | |
| 50 | |
| 51 utils.RunSubprocessWithRetry([npm_bin, 'install']) | |
| 52 local_grunt_bin = os.path.join('node_modules', 'grunt-cli', 'bin', 'grunt') | |
| 53 | |
| 54 if not os.path.exists(local_grunt_bin): | |
| 55 return ('Missing grunt-cli in the webrtc-samples checkout; did ' | |
| 56 'npm install fail?') | |
| 57 | |
| 58 utils.RunSubprocessWithRetry([node_bin, local_grunt_bin, | |
| 59 'closurecompiler:debug']) | |
| 60 | |
| 61 | |
| 62 if __name__ == '__main__': | |
| 63 sys.exit(main()) | |
| OLD | NEW |