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

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

Issue 340993002: Revert of 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
« no previous file with comments | « remoting/resources/remoting_strings.grd ('k') | remoting/webapp/host_controller.js » ('j') | 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 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, destination, zip_path, 78 def buildWebApp(buildtype, version, mimetype, destination, zip_path,
79 manifest_template, webapp_type, files, locales): 79 manifest_template, webapp_type, plugin, 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.
84 destination: A string with path to directory where the webapp will be 85 destination: A string with path to directory where the webapp will be
85 written. 86 written.
86 zipfile: A string with path to the zipfile to create containing the 87 zipfile: A string with path to the zipfile to create containing the
87 contents of |destination|. 88 contents of |destination|.
88 manifest_template: jinja2 template file for manifest. 89 manifest_template: jinja2 template file for manifest.
89 webapp_type: webapp type ("v1", "v2" or "v2_pnacl"). 90 webapp_type: webapp type ("v1", "v2" or "v2_pnacl").
91 plugin: A string with path to the binary plugin for this webapp.
90 files: An array of strings listing the paths for resources to include 92 files: An array of strings listing the paths for resources to include
91 in this webapp. 93 in this webapp.
92 locales: An array of strings listing locales, which are copied, along 94 locales: An array of strings listing locales, which are copied, along
93 with their directory structure from the _locales directory down. 95 with their directory structure from the _locales directory down.
94 """ 96 """
95 # Ensure a fresh directory. 97 # Ensure a fresh directory.
96 try: 98 try:
97 shutil.rmtree(destination) 99 shutil.rmtree(destination)
98 except OSError: 100 except OSError:
99 if os.path.exists(destination): 101 if os.path.exists(destination):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 os.path.split(current_locale)[1]) 144 os.path.split(current_locale)[1])
143 os.mkdir(destination_dir, 0775) 145 os.mkdir(destination_dir, 0775)
144 shutil.copy2(current_locale, destination_file) 146 shutil.copy2(current_locale, destination_file)
145 elif extension == '.pak': 147 elif extension == '.pak':
146 destination_file = os.path.join(remoting_locales, 148 destination_file = os.path.join(remoting_locales,
147 os.path.split(current_locale)[1]) 149 os.path.split(current_locale)[1])
148 shutil.copy2(current_locale, destination_file) 150 shutil.copy2(current_locale, destination_file)
149 else: 151 else:
150 raise Exception("Unknown extension: " + current_locale); 152 raise Exception("Unknown extension: " + current_locale);
151 153
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
152 # Set client plugin type. 192 # Set client plugin type.
153 client_plugin = 'pnacl' if webapp_type == 'v2_pnacl' else 'native' 193 client_plugin = 'pnacl' if webapp_type == 'v2_pnacl' else 'native'
154 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 194 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
155 "'CLIENT_PLUGIN_TYPE'", "'" + client_plugin + "'") 195 "'CLIENT_PLUGIN_TYPE'", "'" + client_plugin + "'")
156 196
157 # Allow host names for google services/apis to be overriden via env vars. 197 # Allow host names for google services/apis to be overriden via env vars.
158 oauth2AccountsHost = os.environ.get( 198 oauth2AccountsHost = os.environ.get(
159 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com') 199 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com')
160 oauth2ApiHost = os.environ.get( 200 oauth2ApiHost = os.environ.get(
161 'OAUTH2_API_HOST', 'https://www.googleapis.com') 201 'OAUTH2_API_HOST', 'https://www.googleapis.com')
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 297
258 # Make the zipfile. 298 # Make the zipfile.
259 createZip(zip_path, destination) 299 createZip(zip_path, destination)
260 300
261 return 0 301 return 0
262 302
263 303
264 def main(): 304 def main():
265 if len(sys.argv) < 6: 305 if len(sys.argv) < 6:
266 print ('Usage: build-webapp.py ' 306 print ('Usage: build-webapp.py '
267 '<build-type> <version> <dst> <zip-path> <manifest_template> ' 307 '<build-type> <version> <mime-type> <dst> <zip-path> '
268 '<webapp_type> <other files...> ' 308 '<manifest_template> <webapp_type> <other files...> '
269 '[--locales <locales...>]') 309 '[--plugin <plugin>] [--locales <locales...>]')
270 return 1 310 return 1
271 311
272 arg_type = '' 312 arg_type = ''
273 files = [] 313 files = []
274 locales = [] 314 locales = []
315 plugin = ""
275 for arg in sys.argv[8:]: 316 for arg in sys.argv[8:]:
276 if arg in ['--locales']: 317 if arg in ['--locales', '--plugin']:
277 arg_type = arg 318 arg_type = arg
278 elif arg_type == '--locales': 319 elif arg_type == '--locales':
279 locales.append(arg) 320 locales.append(arg)
321 elif arg_type == '--plugin':
322 plugin = arg
323 arg_type = ''
280 else: 324 else:
281 files.append(arg) 325 files.append(arg)
282 326
283 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], 327 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
284 sys.argv[5], sys.argv[6], files, locales) 328 sys.argv[5], sys.argv[6], sys.argv[7], plugin,
329 files, locales)
285 330
286 331
287 if __name__ == '__main__': 332 if __name__ == '__main__':
288 sys.exit(main()) 333 sys.exit(main())
OLDNEW
« no previous file with comments | « remoting/resources/remoting_strings.grd ('k') | remoting/webapp/host_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698