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

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

Issue 10075002: Source major & minor versions from remoting, build & patch versions from Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 8 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
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 29 matching lines...) Expand all
40 zipfile_base = os.path.splitext(os.path.basename(zip_path))[0] 40 zipfile_base = os.path.splitext(os.path.basename(zip_path))[0]
41 zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) 41 zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
42 for (root, dirs, files) in os.walk(directory): 42 for (root, dirs, files) in os.walk(directory):
43 for f in files: 43 for f in files:
44 full_path = os.path.join(root, f) 44 full_path = os.path.join(root, f)
45 rel_path = os.path.relpath(full_path, directory) 45 rel_path = os.path.relpath(full_path, directory)
46 zip.write(full_path, os.path.join(zipfile_base, rel_path)) 46 zip.write(full_path, os.path.join(zipfile_base, rel_path))
47 zip.close() 47 zip.close()
48 48
49 49
50 def buildWebApp(buildtype, mimetype, destination, zip_path, plugin, files, 50 def buildWebApp(buildtype, version, mimetype, destination, zip_path, plugin,
51 locales): 51 files, locales):
52 """Does the main work of building the webapp directory and zipfile. 52 """Does the main work of building the webapp directory and zipfile.
53 53
54 Args: 54 Args:
55 buildtype: the type of build ("Official" or "Dev") 55 buildtype: the type of build ("Official" or "Dev")
56 mimetype: A string with mimetype of plugin. 56 mimetype: A string with mimetype of plugin.
57 destination: A string with path to directory where the webapp will be 57 destination: A string with path to directory where the webapp will be
58 written. 58 written.
59 zipfile: A string with path to the zipfile to create containing the 59 zipfile: A string with path to the zipfile to create containing the
60 contents of |destination|. 60 contents of |destination|.
61 plugin: A string with path to the binary plugin for this webapp. 61 plugin: A string with path to the binary plugin for this webapp.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if os.path.isdir(plugin): 148 if os.path.isdir(plugin):
149 # On Mac we have a directory. 149 # On Mac we have a directory.
150 shutil.copytree(plugin, newPluginPath) 150 shutil.copytree(plugin, newPluginPath)
151 else: 151 else:
152 shutil.copy2(plugin, newPluginPath) 152 shutil.copy2(plugin, newPluginPath)
153 153
154 # Strip the linux build. 154 # Strip the linux build.
155 if ((platform.system() == 'Linux') and (buildtype == 'Official')): 155 if ((platform.system() == 'Linux') and (buildtype == 'Official')):
156 subprocess.call(["strip", newPluginPath]) 156 subprocess.call(["strip", newPluginPath])
157 157
158 # Add unique build numbers to manifest version. 158 # Set the version number in the manifest version.
159 # For now, this is based on the system clock (seconds since 1/1/1970), since
160 # a previous attempt (based on build/utils/lastchange.py) was failing on Mac.
161 # TODO(lambroslambrou): Use the SVN revision number or an incrementing build
162 # number (http://crbug.com/90110).
163 timestamp = int(time.time())
164 # Version string must be 1-4 numbers separated by dots, with each number
165 # between 0 and 0xffff.
166 version1 = timestamp / 0x10000
167 version2 = timestamp % 0x10000
168 findAndReplace(os.path.join(destination, 'manifest.json'), 159 findAndReplace(os.path.join(destination, 'manifest.json'),
169 'UNIQUE_VERSION', 160 'FULL_APP_VERSION',
170 '%d.%d' % (version1, version2)) 161 version)
171 162
172 # Set the correct mimetype. 163 # Set the correct mimetype.
173 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 164 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
174 'HOST_PLUGIN_MIMETYPE', 165 'HOST_PLUGIN_MIMETYPE',
175 mimetype) 166 mimetype)
176 167
177 # Set the correct OAuth2 redirect URL. 168 # Set the correct OAuth2 redirect URL.
178 baseUrl = ( 169 baseUrl = (
179 'https://talkgadget.google.com/talkgadget/oauth/chrome-remote-desktop') 170 'https://talkgadget.google.com/talkgadget/oauth/chrome-remote-desktop')
180 if (buildtype == 'Official'): 171 if (buildtype == 'Official'):
(...skipping 24 matching lines...) Expand all
205 "'" + apiClientId + "'") 196 "'" + apiClientId + "'")
206 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 197 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
207 "'API_CLIENT_SECRET'", 198 "'API_CLIENT_SECRET'",
208 "'" + apiClientSecret + "'") 199 "'" + apiClientSecret + "'")
209 200
210 # Make the zipfile. 201 # Make the zipfile.
211 createZip(zip_path, destination) 202 createZip(zip_path, destination)
212 203
213 204
214 def main(): 205 def main():
215 if len(sys.argv) < 6: 206 if len(sys.argv) < 7:
216 print ('Usage: build-webapp.py ' 207 print ('Usage: build-webapp.py '
217 '<build-type> <mime-type> <dst> <zip-path> <plugin> ' 208 '<build-type> <version> <mime-type> <dst> <zip-path> <plugin> '
218 '<other files...> --locales <locales...>') 209 '<other files...> --locales <locales...>')
219 return 1 210 return 1
220 211
221 reading_locales = False 212 reading_locales = False
222 files = [] 213 files = []
223 locales = [] 214 locales = []
224 for arg in sys.argv[6:]: 215 for arg in sys.argv[7:]:
225 if arg == "--locales": 216 if arg == "--locales":
226 reading_locales = True; 217 reading_locales = True;
227 elif reading_locales: 218 elif reading_locales:
228 locales.append(arg) 219 locales.append(arg)
229 else: 220 else:
230 files.append(arg) 221 files.append(arg)
231 222
232 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], 223 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5],
233 files, locales) 224 sys.argv[6], files, locales)
234 return 0 225 return 0
235 226
236 227
237 if __name__ == '__main__': 228 if __name__ == '__main__':
238 sys.exit(main()) 229 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698