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

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

Issue 342583002: Remove NPAPI plugin from chromoting webapp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 sys.path.append(os.path.split(jinja2_path)[0]) 68 sys.path.append(os.path.split(jinja2_path)[0])
69 import jinja2 69 import jinja2
70 (template_path, template_name) = os.path.split(input_file) 70 (template_path, template_name) = os.path.split(input_file)
71 env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path)) 71 env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path))
72 template = env.get_template(template_name) 72 template = env.get_template(template_name)
73 rendered = template.render(context) 73 rendered = template.render(context)
74 io.open(output_file, 'w', encoding='utf-8').write(rendered) 74 io.open(output_file, 'w', encoding='utf-8').write(rendered)
75 75
76 76
77 77
78 def buildWebApp(buildtype, version, mimetype, destination, zip_path, 78 def buildWebApp(buildtype, version, destination, zip_path,
79 manifest_template, webapp_type, plugin, files, locales): 79 manifest_template, webapp_type, files, locales):
80 """Does the main work of building the webapp directory and zipfile. 80 """Does the main work of building the webapp directory and zipfile.
81 81
82 Args: 82 Args:
83 buildtype: the type of build ("Official" or "Dev"). 83 buildtype: the type of build ("Official" or "Dev").
84 mimetype: A string with mimetype of plugin.
85 destination: A string with path to directory where the webapp will be 84 destination: A string with path to directory where the webapp will be
86 written. 85 written.
87 zipfile: A string with path to the zipfile to create containing the 86 zipfile: A string with path to the zipfile to create containing the
88 contents of |destination|. 87 contents of |destination|.
89 manifest_template: jinja2 template file for manifest. 88 manifest_template: jinja2 template file for manifest.
90 webapp_type: webapp type ("v1", "v2" or "v2_pnacl"). 89 webapp_type: webapp type ("v1", "v2" or "v2_pnacl").
91 plugin: A string with path to the binary plugin for this webapp.
92 files: An array of strings listing the paths for resources to include 90 files: An array of strings listing the paths for resources to include
93 in this webapp. 91 in this webapp.
94 locales: An array of strings listing locales, which are copied, along 92 locales: An array of strings listing locales, which are copied, along
95 with their directory structure from the _locales directory down. 93 with their directory structure from the _locales directory down.
96 """ 94 """
97 # Ensure a fresh directory. 95 # Ensure a fresh directory.
98 try: 96 try:
99 shutil.rmtree(destination) 97 shutil.rmtree(destination)
100 except OSError: 98 except OSError:
101 if os.path.exists(destination): 99 if os.path.exists(destination):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 os.path.split(current_locale)[1]) 142 os.path.split(current_locale)[1])
145 os.mkdir(destination_dir, 0775) 143 os.mkdir(destination_dir, 0775)
146 shutil.copy2(current_locale, destination_file) 144 shutil.copy2(current_locale, destination_file)
147 elif extension == '.pak': 145 elif extension == '.pak':
148 destination_file = os.path.join(remoting_locales, 146 destination_file = os.path.join(remoting_locales,
149 os.path.split(current_locale)[1]) 147 os.path.split(current_locale)[1])
150 shutil.copy2(current_locale, destination_file) 148 shutil.copy2(current_locale, destination_file)
151 else: 149 else:
152 raise Exception("Unknown extension: " + current_locale); 150 raise Exception("Unknown extension: " + current_locale);
153 151
154 # Create fake plugin files to appease the manifest checker.
155 # It requires that if there is a plugin listed in the manifest that
156 # there be a file in the plugin with that name.
157 names = [
158 'remoting_host_plugin.dll', # Windows
159 'remoting_host_plugin.plugin', # Mac
160 'libremoting_host_plugin.ia32.so', # Linux 32
161 'libremoting_host_plugin.x64.so' # Linux 64
162 ]
163 pluginName = os.path.basename(plugin)
164
165 for name in names:
166 if name != pluginName:
167 path = os.path.join(destination, name)
168 f = open(path, 'w')
169 f.write("placeholder for %s" % (name))
170 f.close()
171
172 # Copy the plugin. On some platforms (e.g. ChromeOS) plugin compilation may be
173 # disabled, in which case we don't need to copy anything.
174 if plugin:
175 newPluginPath = os.path.join(destination, pluginName)
176 if os.path.isdir(plugin):
177 # On Mac we have a directory.
178 shutil.copytree(plugin, newPluginPath)
179 else:
180 shutil.copy2(plugin, newPluginPath)
181
182 # Strip the linux build.
183 if ((platform.system() == 'Linux') and (buildtype == 'Official')):
184 subprocess.call(["strip", newPluginPath])
185
186 # Set the correct mimetype.
187 hostPluginMimeType = os.environ.get(
188 'HOST_PLUGIN_MIMETYPE', 'application/vnd.chromium.remoting-host')
189 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
190 'HOST_PLUGIN_MIMETYPE', hostPluginMimeType)
191
192 # Set client plugin type. 152 # Set client plugin type.
193 client_plugin = 'pnacl' if webapp_type == 'v2_pnacl' else 'native' 153 client_plugin = 'pnacl' if webapp_type == 'v2_pnacl' else 'native'
194 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 154 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
195 "'CLIENT_PLUGIN_TYPE'", "'" + client_plugin + "'") 155 "'CLIENT_PLUGIN_TYPE'", "'" + client_plugin + "'")
196 156
197 # Allow host names for google services/apis to be overriden via env vars. 157 # Allow host names for google services/apis to be overriden via env vars.
198 oauth2AccountsHost = os.environ.get( 158 oauth2AccountsHost = os.environ.get(
199 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com') 159 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com')
200 oauth2ApiHost = os.environ.get( 160 oauth2ApiHost = os.environ.get(
201 'OAUTH2_API_HOST', 'https://www.googleapis.com') 161 'OAUTH2_API_HOST', 'https://www.googleapis.com')
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 257
298 # Make the zipfile. 258 # Make the zipfile.
299 createZip(zip_path, destination) 259 createZip(zip_path, destination)
300 260
301 return 0 261 return 0
302 262
303 263
304 def main(): 264 def main():
305 if len(sys.argv) < 6: 265 if len(sys.argv) < 6:
306 print ('Usage: build-webapp.py ' 266 print ('Usage: build-webapp.py '
307 '<build-type> <version> <mime-type> <dst> <zip-path> ' 267 '<build-type> <version> <dst> <zip-path> <manifest_template> '
308 '<manifest_template> <webapp_type> <other files...> ' 268 '<webapp_type> <other files...> '
309 '[--plugin <plugin>] [--locales <locales...>]') 269 '[--locales <locales...>]')
310 return 1 270 return 1
311 271
312 arg_type = '' 272 arg_type = ''
313 files = [] 273 files = []
314 locales = [] 274 locales = []
315 plugin = ""
316 for arg in sys.argv[8:]: 275 for arg in sys.argv[8:]:
317 if arg in ['--locales', '--plugin']: 276 if arg in ['--locales']:
318 arg_type = arg 277 arg_type = arg
319 elif arg_type == '--locales': 278 elif arg_type == '--locales':
320 locales.append(arg) 279 locales.append(arg)
321 elif arg_type == '--plugin':
322 plugin = arg
323 arg_type = ''
324 else: 280 else:
325 files.append(arg) 281 files.append(arg)
326 282
327 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], 283 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
328 sys.argv[5], sys.argv[6], sys.argv[7], plugin, 284 sys.argv[5], sys.argv[6], files, locales)
329 files, locales)
330 285
331 286
332 if __name__ == '__main__': 287 if __name__ == '__main__':
333 sys.exit(main()) 288 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698