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

Side by Side Diff: build.py

Issue 29345751: Issue 4028 - Add support for Edge extensions to buildtools (Closed)
Patch Set: Address comments on patch set 4 Created July 8, 2016, 4:46 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 | « no previous file | docs/metadata.edge.example » ('j') | docs/metadata.edge.example » ('J')
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 os 5 import os
6 import sys 6 import sys
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import shutil 9 import shutil
10 import buildtools 10 import buildtools
11 from getopt import getopt, GetoptError 11 from getopt import getopt, GetoptError
12 from StringIO import StringIO 12 from StringIO import StringIO
13 from zipfile import ZipFile 13 from zipfile import ZipFile
14 14
15 knownTypes = ('gecko', 'chrome', 'safari', 'generic') 15 knownTypes = ('gecko', 'chrome', 'safari', 'generic', 'edge')
16 16
17 17
18 class Command(object): 18 class Command(object):
19 name = property(lambda self: self._name) 19 name = property(lambda self: self._name)
20 shortDescription = property( 20 shortDescription = property(
21 lambda self: self._shortDescription, 21 lambda self: self._shortDescription,
22 lambda self, value: self.__dict__.update({'_shortDescription': value}) 22 lambda self, value: self.__dict__.update({'_shortDescription': value})
23 ) 23 )
24 description = property( 24 description = property(
25 lambda self: self._description, 25 lambda self: self._description,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 'scriptName': scriptName, 169 'scriptName': scriptName,
170 'type': type, 170 'type': type,
171 'name': command.name, 171 'name': command.name,
172 'params': command.params, 172 'params': command.params,
173 'description': description, 173 'description': description,
174 'options': '\n'.join(options) 174 'options': '\n'.join(options)
175 } 175 }
176 176
177 177
178 def runBuild(baseDir, scriptName, opts, args, type): 178 def runBuild(baseDir, scriptName, opts, args, type):
179 locales = None 179 kwargs = {}
180 buildNum = None
181 multicompartment = False
182 releaseBuild = False
183 keyFile = None
184 for option, value in opts: 180 for option, value in opts:
185 if option in ('-l', '--locales'): 181 if option in ('-l', '--locales') and type == 'gecko':
186 locales = value.split(',') 182 kwargs['locales'] = value.split(',')
187 elif option in ('-b', '--build'): 183 elif option in ('-b', '--build'):
188 buildNum = value 184 kwargs['buildNum'] = value
189 if type != 'gecko' and not re.search(r'^\d+$', buildNum): 185 if type != 'gecko' and not kwargs['buildNum'].isdigit():
190 raise TypeError('Build number must be numerical') 186 raise TypeError('Build number must be numerical')
191 elif option in ('-k', '--key'): 187 elif option in ('-k', '--key'):
192 keyFile = value 188 kwargs['keyFile'] = value
193 elif option in ('-m', '--multi-compartment'): 189 elif option in ('-m', '--multi-compartment') and type == 'gecko':
194 multicompartment = True 190 kwargs['multicompartment'] = True
195 elif option in ('-r', '--release'): 191 elif option in ('-r', '--release'):
196 releaseBuild = True 192 kwargs['releaseBuild'] = True
197 outFile = args[0] if len(args) > 0 else None 193 if len(args) > 0:
194 kwargs['outFile'] = args[0]
198 195
199 if type == 'gecko': 196 if type == 'gecko':
200 import buildtools.packagerGecko as packager 197 import buildtools.packagerGecko as packager
201 packager.createBuild(baseDir, type=type, outFile=outFile, locales=locale s, buildNum=buildNum,
202 releaseBuild=releaseBuild, keyFile=keyFile,
203 multicompartment=multicompartment)
204 elif type == 'chrome': 198 elif type == 'chrome':
205 import buildtools.packagerChrome as packager 199 import buildtools.packagerChrome as packager
206 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=build Num,
207 releaseBuild=releaseBuild, keyFile=keyFile)
208 elif type == 'safari': 200 elif type == 'safari':
209 import buildtools.packagerSafari as packager 201 import buildtools.packagerSafari as packager
210 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=build Num, 202 elif type == 'edge':
211 releaseBuild=releaseBuild, keyFile=keyFile) 203 import buildtools.packagerEdge as packager
204
205 packager.createBuild(baseDir, type=type, **kwargs)
212 206
213 207
214 def runAutoInstall(baseDir, scriptName, opts, args, type): 208 def runAutoInstall(baseDir, scriptName, opts, args, type):
215 if len(args) == 0: 209 if len(args) == 0:
216 print 'Port of the Extension Auto-Installer needs to be specified' 210 print 'Port of the Extension Auto-Installer needs to be specified'
217 usage(scriptName, type, 'autoinstall') 211 usage(scriptName, type, 'autoinstall')
218 return 212 return
219 213
220 multicompartment = False 214 multicompartment = False
221 for option, value in opts: 215 for option, value in opts:
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 466
473 with addCommand(runBuild, 'build') as command: 467 with addCommand(runBuild, 'build') as command:
474 command.shortDescription = 'Create a build' 468 command.shortDescription = 'Create a build'
475 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' 469 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.'
476 command.params = '[options] [output_file]' 470 command.params = '[options] [output_file]'
477 command.addOption('Only include the given locales (if omitted: all locales n ot marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=(' gecko')) 471 command.addOption('Only include the given locales (if omitted: all locales n ot marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=(' gecko'))
478 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') 472 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num')
479 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('gecko', 'chrome' , 'safari')) 473 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('gecko', 'chrome' , 'safari'))
480 command.addOption('Create a build for leak testing', short='m', long='multi- compartment', types=('gecko')) 474 command.addOption('Create a build for leak testing', short='m', long='multi- compartment', types=('gecko'))
481 command.addOption('Create a release build', short='r', long='release') 475 command.addOption('Create a release build', short='r', long='release')
482 command.supportedTypes = ('gecko', 'chrome', 'safari') 476 command.supportedTypes = ('gecko', 'chrome', 'safari', 'edge')
483 477
484 with addCommand(runAutoInstall, 'autoinstall') as command: 478 with addCommand(runAutoInstall, 'autoinstall') as command:
485 command.shortDescription = 'Install extension automatically' 479 command.shortDescription = 'Install extension automatically'
486 command.description = 'Will automatically install the extension in a browser running Extension Auto-Installer. If host parameter is omitted assumes that the browser runs on localhost.' 480 command.description = 'Will automatically install the extension in a browser running Extension Auto-Installer. If host parameter is omitted assumes that the browser runs on localhost.'
487 command.params = '[<host>:]<port>' 481 command.params = '[<host>:]<port>'
488 command.addOption('Create a build for leak testing', short='m', long='multi- compartment') 482 command.addOption('Create a build for leak testing', short='m', long='multi- compartment')
489 command.supportedTypes = ('gecko') 483 command.supportedTypes = ('gecko')
490 484
491 with addCommand(createDevEnv, 'devenv') as command: 485 with addCommand(createDevEnv, 'devenv') as command:
492 command.shortDescription = 'Set up a development environment' 486 command.shortDescription = 'Set up a development environment'
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if option in ('-h', '--help'): 604 if option in ('-h', '--help'):
611 usage(scriptName, type, command) 605 usage(scriptName, type, command)
612 sys.exit() 606 sys.exit()
613 commands[command](baseDir, scriptName, opts, args, type) 607 commands[command](baseDir, scriptName, opts, args, type)
614 else: 608 else:
615 print 'Command %s is not supported for this application type' % comm and 609 print 'Command %s is not supported for this application type' % comm and
616 usage(scriptName, type) 610 usage(scriptName, type)
617 else: 611 else:
618 print 'Command %s is unrecognized' % command 612 print 'Command %s is unrecognized' % command
619 usage(scriptName, type) 613 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | docs/metadata.edge.example » ('j') | docs/metadata.edge.example » ('J')

Powered by Google App Engine
This is Rietveld