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

Side by Side Diff: packagerChrome.py

Issue 29365583: Issue 4670 - Add a new build type for Gecko-based WebExtensions (Closed) Base URL: https://hg.adblockplus.org/buildtools
Patch Set: Split out info module into a Chrome and Gecko specific one Created Dec. 3, 2016, 7:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build.py ('k') | templates/geckoInfo.js.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 licenseComment = re.compile(r'/\*.*?\*/', re.S) 132 licenseComment = re.compile(r'/\*.*?\*/', re.S)
133 data = json.loads(re.sub(licenseComment, '', manifest, 1)) 133 data = json.loads(re.sub(licenseComment, '', manifest, 1))
134 if '_dummy' in data: 134 if '_dummy' in data:
135 del data['_dummy'] 135 del data['_dummy']
136 manifest = json.dumps(data, sort_keys=True, indent=2) 136 manifest = json.dumps(data, sort_keys=True, indent=2)
137 137
138 return manifest.encode('utf-8') 138 return manifest.encode('utf-8')
139 139
140 140
141 def createInfoModule(params): 141 def createInfoModule(params):
142 template = getTemplate('chromeInfo.js.tmpl') 142 if params['type'] == 'gecko-webext':
143 template = getTemplate('geckoInfo.js.tmpl')
144 else:
145 template = getTemplate('chromeInfo.js.tmpl')
143 return template.render(params).encode('utf-8') 146 return template.render(params).encode('utf-8')
144 147
145 148
146 def convertJS(params, files): 149 def convertJS(params, files):
147 from jshydra.abp_rewrite import rewrite_js 150 from jshydra.abp_rewrite import rewrite_js
148 151
149 output_files = collections.OrderedDict() 152 output_files = collections.OrderedDict()
150 args = collections.defaultdict(list) 153 args = collections.defaultdict(list)
151 154
152 for item in params['metadata'].items('convert_js'): 155 for item in params['metadata'].items('convert_js'):
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 file.write(pubkey) 331 file.write(pubkey)
329 file.write(signature) 332 file.write(signature)
330 file.write(zipdata) 333 file.write(zipdata)
331 334
332 335
333 def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuil d=False, keyFile=None, devenv=False): 336 def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuil d=False, keyFile=None, devenv=False):
334 metadata = readMetadata(baseDir, type) 337 metadata = readMetadata(baseDir, type)
335 version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum) 338 version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)
336 339
337 if outFile == None: 340 if outFile == None:
338 outFile = getDefaultFileName(metadata, version, 'crx' if keyFile else 'z ip') 341 if type == 'gecko-webext':
342 file_extension = 'xpi'
343 else:
344 file_extension = 'crx' if keyFile else 'zip'
345 outFile = getDefaultFileName(metadata, version, file_extension)
339 346
340 params = { 347 params = {
341 'type': type, 348 'type': type,
342 'baseDir': baseDir, 349 'baseDir': baseDir,
343 'releaseBuild': releaseBuild, 350 'releaseBuild': releaseBuild,
344 'version': version, 351 'version': version,
345 'devenv': devenv, 352 'devenv': devenv,
346 'metadata': metadata, 353 'metadata': metadata,
347 } 354 }
348 355
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp l', 391 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmp l',
385 ('general', 'testScripts')) 392 ('general', 'testScripts'))
386 393
387 zipdata = files.zipToString() 394 zipdata = files.zipToString()
388 signature = None 395 signature = None
389 pubkey = None 396 pubkey = None
390 if keyFile != None: 397 if keyFile != None:
391 signature = signBinary(zipdata, keyFile) 398 signature = signBinary(zipdata, keyFile)
392 pubkey = getPublicKey(keyFile) 399 pubkey = getPublicKey(keyFile)
393 writePackage(outFile, pubkey, signature, zipdata) 400 writePackage(outFile, pubkey, signature, zipdata)
OLDNEW
« no previous file with comments | « build.py ('k') | templates/geckoInfo.js.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld