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

Side by Side Diff: remoting/webapp/build-webapp.py

Issue 11875021: Allow an AppsV2 build to be configured using GYP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/appsv2.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Creates a directory with with the unpacked contents of the remoting webapp. 6 """Creates a directory with with the unpacked contents of the remoting webapp.
7 7
8 The directory will contain a copy-of or a link-to to all remoting webapp 8 The directory will contain a copy-of or a link-to to all remoting webapp
9 resources. This includes HTML/JS and any plugin binaries. The script also 9 resources. This includes HTML/JS and any plugin binaries. The script also
10 massages resulting files appropriately with host plugin data. Finally, 10 massages resulting files appropriately with host plugin data. Finally,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) 49 zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
50 for (root, dirs, files) in os.walk(directory): 50 for (root, dirs, files) in os.walk(directory):
51 for f in files: 51 for f in files:
52 full_path = os.path.join(root, f) 52 full_path = os.path.join(root, f)
53 rel_path = os.path.relpath(full_path, directory) 53 rel_path = os.path.relpath(full_path, directory)
54 zip.write(full_path, os.path.join(zipfile_base, rel_path)) 54 zip.write(full_path, os.path.join(zipfile_base, rel_path))
55 zip.close() 55 zip.close()
56 56
57 57
58 def buildWebApp(buildtype, version, mimetype, destination, zip_path, plugin, 58 def buildWebApp(buildtype, version, mimetype, destination, zip_path, plugin,
59 files, locales): 59 files, locales, patches):
60 """Does the main work of building the webapp directory and zipfile. 60 """Does the main work of building the webapp directory and zipfile.
61 61
62 Args: 62 Args:
63 buildtype: the type of build ("Official" or "Dev") 63 buildtype: the type of build ("Official" or "Dev")
64 mimetype: A string with mimetype of plugin. 64 mimetype: A string with mimetype of plugin.
65 destination: A string with path to directory where the webapp will be 65 destination: A string with path to directory where the webapp will be
66 written. 66 written.
67 zipfile: A string with path to the zipfile to create containing the 67 zipfile: A string with path to the zipfile to create containing the
68 contents of |destination|. 68 contents of |destination|.
69 plugin: A string with path to the binary plugin for this webapp. 69 plugin: A string with path to the binary plugin for this webapp.
70 files: An array of strings listing the paths for resources to include 70 files: An array of strings listing the paths for resources to include
71 in this webapp. 71 in this webapp.
72 locales: An array of strings listing locales, which are copied, along 72 locales: An array of strings listing locales, which are copied, along
73 with their directory structure from the _locales directory down. 73 with their directory structure from the _locales directory down.
74 patches: An array of strings listing patch files to be applied to the
75 webapp directory. Paths in the patch file should be relative to
76 the parent directory, for example a/main.html.
Wez 2013/01/16 20:43:57 To the parent directory of what?
Jamie 2013/01/16 21:11:34 The parent directory of the web-app. The example i
74 """ 77 """
75 # Ensure a fresh directory. 78 # Ensure a fresh directory.
76 try: 79 try:
77 shutil.rmtree(destination) 80 shutil.rmtree(destination)
78 except OSError: 81 except OSError:
79 if os.path.exists(destination): 82 if os.path.exists(destination):
80 raise 83 raise
81 else: 84 else:
82 pass 85 pass
83 os.mkdir(destination, 0775) 86 os.mkdir(destination, 0775)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if os.path.isdir(plugin): 155 if os.path.isdir(plugin):
153 # On Mac we have a directory. 156 # On Mac we have a directory.
154 shutil.copytree(plugin, newPluginPath) 157 shutil.copytree(plugin, newPluginPath)
155 else: 158 else:
156 shutil.copy2(plugin, newPluginPath) 159 shutil.copy2(plugin, newPluginPath)
157 160
158 # Strip the linux build. 161 # Strip the linux build.
159 if ((platform.system() == 'Linux') and (buildtype == 'Official')): 162 if ((platform.system() == 'Linux') and (buildtype == 'Official')):
160 subprocess.call(["strip", newPluginPath]) 163 subprocess.call(["strip", newPluginPath])
161 164
165 # Patch the files, if necessary. Do this before updating any placeholders
166 # in case any of the diff contexts refer to the placeholders.
167 for patch in patches:
168 patchfile = os.path.join(os.getcwd(), patch)
169 if subprocess.call(['patch', '-d', destination, '-i', patchfile,
170 '-p1']) != 0:
171 print 'Patch ' + patch + ' failed to apply.'
172 return 1
173
162 # Set the version number in the manifest version. 174 # Set the version number in the manifest version.
163 findAndReplace(os.path.join(destination, 'manifest.json'), 175 findAndReplace(os.path.join(destination, 'manifest.json'),
164 'FULL_APP_VERSION', 176 'FULL_APP_VERSION',
165 version) 177 version)
166 178
167 # Set the correct mimetype. 179 # Set the correct mimetype.
168 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 180 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
169 'HOST_PLUGIN_MIMETYPE', 181 'HOST_PLUGIN_MIMETYPE',
170 mimetype) 182 mimetype)
171 183
(...skipping 23 matching lines...) Expand all
195 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 207 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
196 "'API_CLIENT_ID'", 208 "'API_CLIENT_ID'",
197 "'" + apiClientId + "'") 209 "'" + apiClientId + "'")
198 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 210 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
199 "'API_CLIENT_SECRET'", 211 "'API_CLIENT_SECRET'",
200 "'" + apiClientSecret + "'") 212 "'" + apiClientSecret + "'")
201 213
202 # Make the zipfile. 214 # Make the zipfile.
203 createZip(zip_path, destination) 215 createZip(zip_path, destination)
204 216
217 return 0
218
205 219
206 def main(): 220 def main():
207 if len(sys.argv) < 7: 221 if len(sys.argv) < 7:
208 print ('Usage: build-webapp.py ' 222 print ('Usage: build-webapp.py '
209 '<build-type> <version> <mime-type> <dst> <zip-path> <plugin> ' 223 '<build-type> <version> <mime-type> <dst> <zip-path> <plugin> '
210 '<other files...> --locales <locales...>') 224 '<other files...> [--patches <patches...>] '
225 '[--locales <locales...>]')
211 return 1 226 return 1
212 227
213 reading_locales = False 228 arg_type = ''
214 files = [] 229 files = []
215 locales = [] 230 locales = []
231 patches = []
216 for arg in sys.argv[7:]: 232 for arg in sys.argv[7:]:
217 if arg == "--locales": 233 if arg == '--locales' or arg == '--patches':
218 reading_locales = True; 234 arg_type = arg
219 elif reading_locales: 235 elif arg_type == '--locales':
220 locales.append(arg) 236 locales.append(arg)
237 elif arg_type == '--patches':
238 patches.append(arg)
221 else: 239 else:
222 files.append(arg) 240 files.append(arg)
223 241
224 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], 242 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
225 sys.argv[6], files, locales) 243 sys.argv[5], sys.argv[6], files, locales, patches)
226 return 0
227 244
228 245
229 if __name__ == '__main__': 246 if __name__ == '__main__':
230 sys.exit(main()) 247 sys.exit(main())
OLDNEW
« no previous file with comments | « remoting/webapp/appsv2.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698