LEFT | RIGHT |
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 errno | 5 import errno |
6 import glob | 6 import glob |
7 import io | 7 import io |
8 import json | 8 import json |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return manifest.encode('utf-8') | 143 return manifest.encode('utf-8') |
144 | 144 |
145 | 145 |
146 def toJson(data): | 146 def toJson(data): |
147 return json.dumps( | 147 return json.dumps( |
148 data, ensure_ascii=False, sort_keys=True, | 148 data, ensure_ascii=False, sort_keys=True, |
149 indent=2, separators=(',', ': ') | 149 indent=2, separators=(',', ': ') |
150 ).encode('utf-8') + '\n' | 150 ).encode('utf-8') + '\n' |
151 | 151 |
152 | 152 |
153 def create_bundles(params, files, devenv): | 153 def create_bundles(params, files, bundle_tests): |
154 base_extension_path = params['baseDir'] | 154 base_extension_path = params['baseDir'] |
155 info_templates = { | 155 info_templates = { |
156 'chrome': 'chromeInfo.js.tmpl', | 156 'chrome': 'chromeInfo.js.tmpl', |
157 'edge': 'edgeInfo.js.tmpl', | 157 'edge': 'edgeInfo.js.tmpl', |
158 'gecko': 'geckoInfo.js.tmpl' | 158 'gecko': 'geckoInfo.js.tmpl' |
159 } | 159 } |
160 | 160 |
161 # Historically we didn't use relative paths when requiring modules, so in | 161 # Historically we didn't use relative paths when requiring modules, so in |
162 # order for webpack to know where to find them we need to pass in a list of | 162 # order for webpack to know where to find them we need to pass in a list of |
163 # resolve paths. Going forward we should always use relative paths, once we | 163 # resolve paths. Going forward we should always use relative paths, once we |
(...skipping 20 matching lines...) Expand all Loading... |
184 | 184 |
185 bundle_file = os.path.relpath(os.path.join(base_item_path, name), | 185 bundle_file = os.path.relpath(os.path.join(base_item_path, name), |
186 base_extension_path) | 186 base_extension_path) |
187 entry_files = [os.path.join(base_item_path, module_path) | 187 entry_files = [os.path.join(base_item_path, module_path) |
188 for module_path in value.split()] | 188 for module_path in value.split()] |
189 configuration['bundles'].append({ | 189 configuration['bundles'].append({ |
190 'bundle_name': bundle_file, | 190 'bundle_name': bundle_file, |
191 'entry_points': entry_files, | 191 'entry_points': entry_files, |
192 }) | 192 }) |
193 | 193 |
194 if devenv: | 194 if bundle_tests: |
195 qunit_path = os.path.join(params['baseDir'], 'qunit') | 195 qunit_path = os.path.join(base_extension_path, 'qunit') |
196 qunit_files = ([os.path.join(qunit_path, 'common.js')] + | 196 qunit_files = ([os.path.join(qunit_path, 'common.js')] + |
197 glob.glob(os.path.join(qunit_path, 'tests', '*.js'))) | 197 glob.glob(os.path.join(qunit_path, 'tests', '*.js'))) |
198 configuration['bundles'].append({ | 198 configuration['bundles'].append({ |
199 'bundle_name': 'qunit/tests.js', | 199 'bundle_name': 'qunit/tests.js', |
200 'entry_points': qunit_files | 200 'entry_points': qunit_files |
201 }) | 201 }) |
202 | 202 |
203 cmd = ['node', os.path.join(os.path.dirname(__file__), 'webpack_runner.js')] | 203 cmd = ['node', os.path.join(os.path.dirname(__file__), 'webpack_runner.js')] |
204 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, | 204 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
205 stdin=subprocess.PIPE) | 205 stdin=subprocess.PIPE) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 366 } |
367 | 367 |
368 mapped = metadata.items('mapping') if metadata.has_section('mapping') else [
] | 368 mapped = metadata.items('mapping') if metadata.has_section('mapping') else [
] |
369 files = Files(getPackageFiles(params), getIgnoredFiles(params), | 369 files = Files(getPackageFiles(params), getIgnoredFiles(params), |
370 process=lambda path, data: processFile(path, data, params)) | 370 process=lambda path, data: processFile(path, data, params)) |
371 | 371 |
372 files.readMappedFiles(mapped) | 372 files.readMappedFiles(mapped) |
373 files.read(baseDir, skip=[opt for opt, _ in mapped]) | 373 files.read(baseDir, skip=[opt for opt, _ in mapped]) |
374 | 374 |
375 if metadata.has_section('bundles'): | 375 if metadata.has_section('bundles'): |
376 create_bundles(params, files, devenv) | 376 bundle_tests = devenv and metadata.has_option('general', 'testScripts') |
| 377 create_bundles(params, files, bundle_tests) |
377 | 378 |
378 if metadata.has_section('preprocess'): | 379 if metadata.has_section('preprocess'): |
379 files.preprocess( | 380 files.preprocess( |
380 [f for f, _ in metadata.items('preprocess')], | 381 [f for f, _ in metadata.items('preprocess')], |
381 {'needsExt': True} | 382 {'needsExt': True} |
382 ) | 383 ) |
383 | 384 |
384 if metadata.has_section('import_locales'): | 385 if metadata.has_section('import_locales'): |
385 import_locales(params, files) | 386 import_locales(params, files) |
386 | 387 |
387 files['manifest.json'] = createManifest(params, files) | 388 files['manifest.json'] = createManifest(params, files) |
388 if type == 'chrome': | 389 if type == 'chrome': |
389 fix_translations_for_chrome(files) | 390 fix_translations_for_chrome(files) |
390 | 391 |
391 if devenv: | 392 if devenv: |
392 add_devenv_requirements(files, metadata, params) | 393 add_devenv_requirements(files, metadata, params) |
393 | 394 |
394 zipdata = files.zipToString() | 395 zipdata = files.zipToString() |
395 signature = None | 396 signature = None |
396 pubkey = None | 397 pubkey = None |
397 if keyFile != None: | 398 if keyFile != None: |
398 signature = signBinary(zipdata, keyFile) | 399 signature = signBinary(zipdata, keyFile) |
399 pubkey = getPublicKey(keyFile) | 400 pubkey = getPublicKey(keyFile) |
400 writePackage(outFile, pubkey, signature, zipdata) | 401 writePackage(outFile, pubkey, signature, zipdata) |
LEFT | RIGHT |