Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: build_apprtc_appengine_app.py

Issue 1565173002: Download a prebuilt apprtc from google storage instead of building it. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/webrtc/webrtc.DEPS@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « DEPS ('k') | download_appengine_and_mercurial.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 grunt build on AppRTC.
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 subprocess
16 import sys
17
18 import utils
19
20
21 # Phantomjs generates very deep paths in the node_modules structure and
22 # Windows can't deal with that, so just hack that out.
23 def _WorkaroundPhantomJsOnWin(samples_path):
24 if utils.GetPlatform() is 'win':
25 package_json = os.path.join(samples_path, 'package.json')
26 if not os.path.exists(package_json):
27 raise Exception('Expected %s to exist.' % os.path.abspath(package_json))
28
29 for line in fileinput.input(package_json, inplace=True):
30 if not 'phantomjs' in line:
31 sys.stdout.write(line)
32
33
34 def _WorkAroundMacNpmCorruptedDataOnInstall(command):
35 print 'Wiping .npm folder and trying again...'
36 npm_storage = os.path.expanduser('~/.npm')
37 assert npm_storage.endswith('.npm')
38 utils.RemoveDirectory(npm_storage)
39 utils.RunSubprocessWithRetry(command)
40
41
42 def main():
43 node_path = os.path.abspath('node')
44 if not os.path.exists(node_path):
45 return 'Expected node at %s.' % node_path
46 apprtc_path = os.path.join('src', 'out', 'apprtc')
47 if not os.path.exists(apprtc_path):
48 return 'Expected apprtc at %s.' % os.path.abspath(apprtc_path)
49
50 _WorkaroundPhantomJsOnWin(apprtc_path)
51 os.chdir(apprtc_path)
52
53 if utils.GetPlatform() is 'win':
54 npm_bin = os.path.join(node_path, 'npm.cmd')
55 node_bin = os.path.join(node_path, 'node.exe')
56 else:
57 npm_bin = os.path.join(node_path, 'bin', 'npm')
58 node_bin = os.path.join(node_path, 'bin', 'node')
59
60 command = [npm_bin, 'install']
61 try:
62 utils.RunSubprocessWithRetry(command)
63 except subprocess.CalledProcessError:
64 if utils.GetPlatform() is not 'mac':
65 raise
66 _WorkAroundMacNpmCorruptedDataOnInstall(command)
67
68 local_grunt_bin = os.path.join('node_modules', 'grunt-cli', 'bin', 'grunt')
69
70 if not os.path.exists(local_grunt_bin):
71 return ('Missing grunt-cli in the apprtc checkout; did '
72 'npm install fail?')
73
74 utils.RunSubprocessWithRetry([node_bin, local_grunt_bin, 'build'])
75
76
77 if __name__ == '__main__':
78 sys.exit(main())
OLDNEW
« no previous file with comments | « DEPS ('k') | download_appengine_and_mercurial.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698