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 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 return manifest.encode('utf-8') | 137 return manifest.encode('utf-8') |
138 | 138 |
139 | 139 |
140 def createInfoModule(params): | 140 def createInfoModule(params): |
141 template = getTemplate('chromeInfo.js.tmpl') | 141 template = getTemplate('chromeInfo.js.tmpl') |
142 return template.render(params).encode('utf-8') | 142 return template.render(params).encode('utf-8') |
143 | 143 |
144 | 144 |
145 def convertJS(params, files): | 145 def convertJS(params, files): |
146 from jshydra.abp_rewrite import doRewrite | 146 from jshydra.abp_rewrite import rewrite_js |
147 | 147 |
148 for item in params['metadata'].items('convert_js'): | 148 for item in params['metadata'].items('convert_js'): |
149 file, sources = item | 149 file, sources = item |
150 baseDir = os.path.dirname(item.source) | 150 baseDir = os.path.dirname(item.source) |
151 | 151 |
152 # Make sure the file is inside an included directory | 152 # Make sure the file is inside an included directory |
153 if '/' in file and not files.isIncluded(file): | 153 if '/' in file and not files.isIncluded(file): |
154 continue | 154 continue |
155 | 155 |
156 sourceFiles = sources.split() | 156 sourceFiles = sources.split() |
157 args = [] | 157 args = [] |
158 try: | 158 try: |
159 argsStart = sourceFiles.index('--arg') | 159 argsStart = sourceFiles.index('--arg') |
160 args = sourceFiles[argsStart + 1:] | 160 args = sourceFiles[argsStart + 1:] |
161 sourceFiles = sourceFiles[0:argsStart] | 161 sourceFiles = sourceFiles[0:argsStart] |
162 except ValueError: | 162 except ValueError: |
163 pass | 163 pass |
164 | 164 |
165 # Source files of the conversion shouldn't be part of the build | 165 # Source files of the conversion shouldn't be part of the build |
166 for sourceFile in sourceFiles: | 166 for sourceFile in sourceFiles: |
167 if sourceFile in files: | 167 if sourceFile in files: |
168 del files[sourceFile] | 168 del files[sourceFile] |
169 | 169 |
170 sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), s
ourceFiles) | 170 sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), s
ourceFiles) |
171 files[file] = doRewrite(sourceFiles, args) | 171 files[file] = rewrite_js(['--arg', ' '.join(args)] + sourceFiles) |
172 | 172 |
173 | 173 |
174 def toJson(data): | 174 def toJson(data): |
175 return json.dumps( | 175 return json.dumps( |
176 data, ensure_ascii=False, sort_keys=True, | 176 data, ensure_ascii=False, sort_keys=True, |
177 indent=2, separators=(',', ': ') | 177 indent=2, separators=(',', ': ') |
178 ).encode('utf-8') + '\n' | 178 ).encode('utf-8') + '\n' |
179 | 179 |
180 | 180 |
181 def importGeckoLocales(params, files): | 181 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', | 385 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp
l', |
386 ('general', 'testScripts')) | 386 ('general', 'testScripts')) |
387 | 387 |
388 zipdata = files.zipToString() | 388 zipdata = files.zipToString() |
389 signature = None | 389 signature = None |
390 pubkey = None | 390 pubkey = None |
391 if keyFile != None: | 391 if keyFile != None: |
392 signature = signBinary(zipdata, keyFile) | 392 signature = signBinary(zipdata, keyFile) |
393 pubkey = getPublicKey(keyFile) | 393 pubkey = getPublicKey(keyFile) |
394 writePackage(outFile, pubkey, signature, zipdata) | 394 writePackage(outFile, pubkey, signature, zipdata) |
OLD | NEW |