Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: packagerEdge.py

Issue 29367145: Issue 4719 - Edge packager does not generate an info module (Closed)
Left Patch Set: Created Dec. 9, 2016, 6:13 a.m.
Right Patch Set: Remove the redundant whitespace. Created Dec. 22, 2016, 4:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | tests/metadata.edge » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import base64 5 import base64
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import mimetypes 8 import mimetypes
9 import os 9 import os
10 import zipfile 10 import zipfile
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 files['{}/{}'.format(EXTENSION_DIR, filename)] = files.pop(filename) 110 files['{}/{}'.format(EXTENSION_DIR, filename)] = files.pop(filename)
111 111
112 112
113 def create_content_types_map(filenames): 113 def create_content_types_map(filenames):
114 """Create [Content_Types].xml -- a mime type map.""" 114 """Create [Content_Types].xml -- a mime type map."""
115 params = {'defaults': {}, 'overrides': {}} 115 params = {'defaults': {}, 'overrides': {}}
116 overrides = { 116 overrides = {
117 BLOCKMAP: 'application/vnd.ms-appx.blockmap+xml', 117 BLOCKMAP: 'application/vnd.ms-appx.blockmap+xml',
118 MANIFEST: 'application/vnd.ms-appx.manifest+xml' 118 MANIFEST: 'application/vnd.ms-appx.manifest+xml'
119 } 119 }
120 types = mimetypes.MimeTypes()
121 types.add_type('application/octet-stream', '.otf')
120 for filename in filenames: 122 for filename in filenames:
121 ext = os.path.splitext(filename)[1] 123 ext = os.path.splitext(filename)[1]
122 if ext: 124 if ext:
123 content_type = mimetypes.guess_type(filename, strict=False)[0] 125 content_type = types.guess_type(filename, strict=False)[0]
124 if content_type is not None: 126 if content_type is not None:
125 params['defaults'][ext[1:]] = content_type 127 params['defaults'][ext[1:]] = content_type
126 if filename in overrides: 128 if filename in overrides:
127 params['overrides']['/' + filename] = overrides[filename] 129 params['overrides']['/' + filename] = overrides[filename]
128 content_types_template = _get_template_for(CONTENT_TYPES) 130 content_types_template = _get_template_for(CONTENT_TYPES)
129 return content_types_template.render(params).encode('utf-8') 131 return content_types_template.render(params).encode('utf-8')
130 132
131 133
132 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API. 134 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API.
133 buildNum=None, releaseBuild=False, keyFile=None, 135 buildNum=None, releaseBuild=False, keyFile=None,
(...skipping 28 matching lines...) Expand all
162 packagerChrome.convertJS(params, files) 164 packagerChrome.convertJS(params, files)
163 165
164 if metadata.has_section('preprocess'): 166 if metadata.has_section('preprocess'):
165 files.preprocess(metadata.options('preprocess'), {'needsExt': True}) 167 files.preprocess(metadata.options('preprocess'), {'needsExt': True})
166 168
167 if metadata.has_section('import_locales'): 169 if metadata.has_section('import_locales'):
168 packagerChrome.importGeckoLocales(params, files) 170 packagerChrome.importGeckoLocales(params, files)
169 171
170 files['manifest.json'] = packagerChrome.createManifest(params, files) 172 files['manifest.json'] = packagerChrome.createManifest(params, files)
171 173
172 if (metadata.has_option('general', 'backgroundScripts') and 174 if devenv:
173 'lib/info.js' in metadata.get('general', 'backgroundScripts').split() an d 175 import buildtools
174 'lib/info.js' not in files): 176 import random
175 files['lib/info.js'] = packagerChrome.createInfoModule(params) 177 files.read(os.path.join(buildtools.__path__[0],
178 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js')
179 files['devenvVersion__'] = str(random.random())
180
181 if metadata.has_option('general', 'backgroundScripts'):
182 bg_scripts = metadata.get('general', 'backgroundScripts').split()
183 if 'lib/info.js' in bg_scripts and 'lib/info.js' not in files:
184 files['lib/info.js'] = packagerChrome.createInfoModule(params)
176 185
177 move_files_to_extension(files) 186 move_files_to_extension(files)
178 187
179 if metadata.has_section('appx_assets'): 188 if metadata.has_section('appx_assets'):
180 for name, path in metadata.items('appx_assets'): 189 for name, path in metadata.items('appx_assets'):
181 path = os.path.join(baseDir, path) 190 path = os.path.join(baseDir, path)
182 files.read(path, '{}/{}'.format(ASSETS_DIR, name)) 191 files.read(path, '{}/{}'.format(ASSETS_DIR, name))
183 192
184 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) 193 files[MANIFEST] = create_appx_manifest(params, files, releaseBuild)
185 files[BLOCKMAP] = create_appx_blockmap(files) 194 files[BLOCKMAP] = create_appx_blockmap(files)
186 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) 195 files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP])
187 196
188 files.zip(outfile, compression=zipfile.ZIP_STORED) 197 files.zip(outfile, compression=zipfile.ZIP_STORED)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld