| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 io | 6 import io |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 from StringIO import StringIO | 10 from StringIO import StringIO |
| 11 import struct | 11 import struct |
| 12 import sys | 12 import sys |
| 13 from collections import OrderedDict | |
| 13 | 14 |
| 14 import packager | 15 import packager |
| 15 from packager import readMetadata, getMetadataPath, getDefaultFileName, getBuild Version, getTemplate, Files | 16 from packager import readMetadata, getMetadataPath, getDefaultFileName, getBuild Version, getTemplate, Files |
| 16 | 17 |
| 17 defaultLocale = 'en_US' | 18 defaultLocale = 'en_US' |
| 18 | 19 |
| 19 | 20 |
| 20 def getIgnoredFiles(params): | 21 def getIgnoredFiles(params): |
| 21 return {'store.description'} | 22 return {'store.description'} |
| 22 | 23 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 | 139 |
| 139 | 140 |
| 140 def createInfoModule(params): | 141 def createInfoModule(params): |
| 141 template = getTemplate('chromeInfo.js.tmpl') | 142 template = getTemplate('chromeInfo.js.tmpl') |
| 142 return template.render(params).encode('utf-8') | 143 return template.render(params).encode('utf-8') |
| 143 | 144 |
| 144 | 145 |
| 145 def convertJS(params, files): | 146 def convertJS(params, files): |
| 146 from jshydra.abp_rewrite import rewrite_js | 147 from jshydra.abp_rewrite import rewrite_js |
| 147 | 148 |
| 149 output_files = OrderedDict() | |
| 148 for item in params['metadata'].items('convert_js'): | 150 for item in params['metadata'].items('convert_js'): |
| 149 file, sources = item | 151 filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups() |
| 150 baseDir = os.path.dirname(item.source) | 152 if arg is None: |
| 153 output_files[filename] = (item[1].split(), item.source, []) | |
| 154 else: | |
| 155 output_files[filename][2].append('{}={}'.format(arg, item[1])) | |
|
Vasily Kuznetsov
2016/08/29 16:56:40
Perhaps we should issue a more user-friendly messa
Sebastian Noack
2016/08/30 12:40:31
Well, it's simpler to avoid that error than handli
Vasily Kuznetsov
2016/08/30 13:30:18
Indeed. Actually you can make the code even cleane
Sebastian Noack
2016/08/30 14:06:50
Yeah, that is even better. Done.
| |
| 151 | 156 |
| 152 # Make sure the file is inside an included directory | 157 for filename, (input_files, origin, args) in output_files.iteritems(): |
| 153 if '/' in file and not files.isIncluded(file): | 158 if '/' in filename and not files.isIncluded(filename): |
| 154 continue | 159 continue |
| 155 | 160 |
| 156 sourceFiles = sources.split() | 161 base_dir = os.path.dirname(origin) |
| 157 args = [] | 162 jshydra_args = ['--arg', ' '.join(args)] |
| 158 try: | |
| 159 argsStart = sourceFiles.index('--arg') | |
| 160 args = sourceFiles[argsStart + 1:] | |
| 161 sourceFiles = sourceFiles[0:argsStart] | |
| 162 except ValueError: | |
| 163 pass | |
| 164 | 163 |
| 165 # Source files of the conversion shouldn't be part of the build | 164 for input_filename in input_files: |
| 166 for sourceFile in sourceFiles: | 165 jshydra_args.append(os.path.join(base_dir, input_filename)) |
| 167 if sourceFile in files: | 166 files.pop(input_filename, None) |
| 168 del files[sourceFile] | |
| 169 | 167 |
| 170 sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), s ourceFiles) | 168 files[filename] = rewrite_js(jshydra_args) |
| 171 files[file] = rewrite_js(['--arg', ' '.join(args)] + sourceFiles) | |
| 172 | 169 |
| 173 | 170 |
| 174 def toJson(data): | 171 def toJson(data): |
| 175 return json.dumps( | 172 return json.dumps( |
| 176 data, ensure_ascii=False, sort_keys=True, | 173 data, ensure_ascii=False, sort_keys=True, |
| 177 indent=2, separators=(',', ': ') | 174 indent=2, separators=(',', ': ') |
| 178 ).encode('utf-8') + '\n' | 175 ).encode('utf-8') + '\n' |
| 179 | 176 |
| 180 | 177 |
| 181 def importGeckoLocales(params, files): | 178 def importGeckoLocales(params, files): |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp l', | 382 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp l', |
| 386 ('general', 'testScripts')) | 383 ('general', 'testScripts')) |
| 387 | 384 |
| 388 zipdata = files.zipToString() | 385 zipdata = files.zipToString() |
| 389 signature = None | 386 signature = None |
| 390 pubkey = None | 387 pubkey = None |
| 391 if keyFile != None: | 388 if keyFile != None: |
| 392 signature = signBinary(zipdata, keyFile) | 389 signature = signBinary(zipdata, keyFile) |
| 393 pubkey = getPublicKey(keyFile) | 390 pubkey = getPublicKey(keyFile) |
| 394 writePackage(outFile, pubkey, signature, zipdata) | 391 writePackage(outFile, pubkey, signature, zipdata) |
| OLD | NEW |