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 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 Loading... | |
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': |
Sebastian Noack
2016/10/04 19:58:04
While refactoring this code anyway, this should be
Vasily Kuznetsov
2016/10/11 15:58:27
Done.
| |
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, | |
202 locales=locales, buildNum=buildNum, | |
203 releaseBuild=releaseBuild, | |
204 multicompartment=multicompartment) | |
205 elif type == 'chrome': | 198 elif type == 'chrome': |
206 import buildtools.packagerChrome as packager | 199 import buildtools.packagerChrome as packager |
207 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=build Num, | |
208 releaseBuild=releaseBuild, keyFile=keyFile) | |
209 elif type == 'safari': | 200 elif type == 'safari': |
210 import buildtools.packagerSafari as packager | 201 import buildtools.packagerSafari as packager |
211 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=build Num, | 202 elif type == 'edge': |
212 releaseBuild=releaseBuild, keyFile=keyFile) | 203 import buildtools.packagerEdge as packager |
204 | |
205 packager.createBuild(baseDir, type=type, **kwargs) | |
Sebastian Noack
2016/10/04 19:58:05
Since you are apparently changing the calling code
Vasily Kuznetsov
2016/10/11 15:58:27
That's a lot of unrelated changes to pull in. Also
Sebastian Noack
2016/10/12 11:07:48
I was only talking about packagerEdge.create_build
Vasily Kuznetsov
2016/10/12 14:13:42
I tried doing it, but unfortunately we still can't
Sebastian Noack
2016/10/12 14:43:26
I guess, let's leave it as is for now. We still sh
Vasily Kuznetsov
2016/10/13 11:56:35
Fully agree.
| |
213 | 206 |
214 | 207 |
215 def runAutoInstall(baseDir, scriptName, opts, args, type): | 208 def runAutoInstall(baseDir, scriptName, opts, args, type): |
216 if len(args) == 0: | 209 if len(args) == 0: |
217 print 'Port of the Extension Auto-Installer needs to be specified' | 210 print 'Port of the Extension Auto-Installer needs to be specified' |
218 usage(scriptName, type, 'autoinstall') | 211 usage(scriptName, type, 'autoinstall') |
219 return | 212 return |
220 | 213 |
221 multicompartment = False | 214 multicompartment = False |
222 for option, value in opts: | 215 for option, value in opts: |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 | 460 |
468 with addCommand(runBuild, 'build') as command: | 461 with addCommand(runBuild, 'build') as command: |
469 command.shortDescription = 'Create a build' | 462 command.shortDescription = 'Create a build' |
470 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' | 463 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' |
471 command.params = '[options] [output_file]' | 464 command.params = '[options] [output_file]' |
472 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')) | 465 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')) |
473 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') | 466 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') |
474 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome', 'safari ')) | 467 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome', 'safari ')) |
475 command.addOption('Create a build for leak testing', short='m', long='multi- compartment', types=('gecko')) | 468 command.addOption('Create a build for leak testing', short='m', long='multi- compartment', types=('gecko')) |
476 command.addOption('Create a release build', short='r', long='release') | 469 command.addOption('Create a release build', short='r', long='release') |
477 command.supportedTypes = ('gecko', 'chrome', 'safari') | 470 command.supportedTypes = ('gecko', 'chrome', 'safari', 'edge') |
478 | 471 |
479 with addCommand(runAutoInstall, 'autoinstall') as command: | 472 with addCommand(runAutoInstall, 'autoinstall') as command: |
480 command.shortDescription = 'Install extension automatically' | 473 command.shortDescription = 'Install extension automatically' |
481 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.' | 474 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.' |
482 command.params = '[<host>:]<port>' | 475 command.params = '[<host>:]<port>' |
483 command.addOption('Create a build for leak testing', short='m', long='multi- compartment') | 476 command.addOption('Create a build for leak testing', short='m', long='multi- compartment') |
484 command.supportedTypes = ('gecko') | 477 command.supportedTypes = ('gecko') |
485 | 478 |
486 with addCommand(createDevEnv, 'devenv') as command: | 479 with addCommand(createDevEnv, 'devenv') as command: |
487 command.shortDescription = 'Set up a development environment' | 480 command.shortDescription = 'Set up a development environment' |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 if option in ('-h', '--help'): | 598 if option in ('-h', '--help'): |
606 usage(scriptName, type, command) | 599 usage(scriptName, type, command) |
607 sys.exit() | 600 sys.exit() |
608 commands[command](baseDir, scriptName, opts, args, type) | 601 commands[command](baseDir, scriptName, opts, args, type) |
609 else: | 602 else: |
610 print 'Command %s is not supported for this application type' % comm and | 603 print 'Command %s is not supported for this application type' % comm and |
611 usage(scriptName, type) | 604 usage(scriptName, type) |
612 else: | 605 else: |
613 print 'Command %s is unrecognized' % command | 606 print 'Command %s is unrecognized' % command |
614 usage(scriptName, type) | 607 usage(scriptName, type) |
OLD | NEW |