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

Side by Side Diff: build.py

Issue 29365583: Issue 4670 - Add a new build type for Gecko-based WebExtensions (Closed) Base URL: https://hg.adblockplus.org/buildtools
Patch Set: Updated the way options page is specified in the manifest Created Nov. 30, 2016, 1:23 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 | packagerChrome.py » ('j') | packagerChrome.py » ('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', 'edge') 15 knownTypes = ('gecko', 'gecko-webext', '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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 kwargs['keyFile'] = value 188 kwargs['keyFile'] = value
189 elif option in {'-m', '--multi-compartment'} and type == 'gecko': 189 elif option in {'-m', '--multi-compartment'} and type == 'gecko':
190 kwargs['multicompartment'] = True 190 kwargs['multicompartment'] = True
191 elif option in {'-r', '--release'}: 191 elif option in {'-r', '--release'}:
192 kwargs['releaseBuild'] = True 192 kwargs['releaseBuild'] = True
193 if len(args) > 0: 193 if len(args) > 0:
194 kwargs['outFile'] = args[0] 194 kwargs['outFile'] = args[0]
195 195
196 if type == 'gecko': 196 if type == 'gecko':
197 import buildtools.packagerGecko as packager 197 import buildtools.packagerGecko as packager
198 elif type == 'chrome': 198 elif type == 'chrome' or type == 'gecko-webext':
Sebastian Noack 2016/12/01 16:24:54 How about |type in {'chrome', 'gecko-webext'}|?
Wladimir Palant 2016/12/01 21:39:31 Done.
199 import buildtools.packagerChrome as packager 199 import buildtools.packagerChrome as packager
200 elif type == 'safari': 200 elif type == 'safari':
201 import buildtools.packagerSafari as packager 201 import buildtools.packagerSafari as packager
202 elif type == 'edge': 202 elif type == 'edge':
203 import buildtools.packagerEdge as packager 203 import buildtools.packagerEdge as packager
204 204
205 packager.createBuild(baseDir, type=type, **kwargs) 205 packager.createBuild(baseDir, type=type, **kwargs)
206 206
207 207
208 def runAutoInstall(baseDir, scriptName, opts, args, type): 208 def runAutoInstall(baseDir, scriptName, opts, args, type):
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 def readLocaleConfig(baseDir, type, metadata): 247 def readLocaleConfig(baseDir, type, metadata):
248 if type == 'gecko': 248 if type == 'gecko':
249 import buildtools.packagerGecko as packager 249 import buildtools.packagerGecko as packager
250 localeDir = packager.getLocalesDir(baseDir) 250 localeDir = packager.getLocalesDir(baseDir)
251 localeConfig = { 251 localeConfig = {
252 'name_format': 'BCP-47', 252 'name_format': 'BCP-47',
253 'file_format': 'gecko-dtd', 253 'file_format': 'gecko-dtd',
254 'target_platforms': {'gecko'}, 254 'target_platforms': {'gecko'},
255 'default_locale': packager.defaultLocale 255 'default_locale': packager.defaultLocale
256 } 256 }
257 elif type == 'chrome': 257 elif type == 'chrome' or type == 'gecko-webext':
258 import buildtools.packagerChrome as packager 258 import buildtools.packagerChrome as packager
259 localeDir = os.path.join(baseDir, '_locales') 259 localeDir = os.path.join(baseDir, '_locales')
260 localeConfig = { 260 localeConfig = {
261 'name_format': 'ISO-15897', 261 'name_format': 'ISO-15897',
262 'file_format': 'chrome-json', 262 'file_format': 'chrome-json',
263 'target_platforms': {'chrome'}, 263 'target_platforms': {'chrome'},
264 'default_locale': packager.defaultLocale, 264 'default_locale': packager.defaultLocale,
265 } 265 }
266 else: 266 else:
267 localeDir = os.path.join( 267 localeDir = os.path.join(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 with addCommand(runBuild, 'build') as command: 461 with addCommand(runBuild, 'build') as command:
462 command.shortDescription = 'Create a build' 462 command.shortDescription = 'Create a build'
463 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.'
464 command.params = '[options] [output_file]' 464 command.params = '[options] [output_file]'
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')) 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'))
466 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')
467 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 '))
468 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'))
469 command.addOption('Create a release build', short='r', long='release') 469 command.addOption('Create a release build', short='r', long='release')
470 command.supportedTypes = ('gecko', 'chrome', 'safari', 'edge') 470 command.supportedTypes = ('gecko', 'gecko-webext', 'chrome', 'safari', 'edge ')
471 471
472 with addCommand(runAutoInstall, 'autoinstall') as command: 472 with addCommand(runAutoInstall, 'autoinstall') as command:
473 command.shortDescription = 'Install extension automatically' 473 command.shortDescription = 'Install extension automatically'
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.' 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.'
475 command.params = '[<host>:]<port>' 475 command.params = '[<host>:]<port>'
476 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')
477 command.supportedTypes = ('gecko') 477 command.supportedTypes = ('gecko')
478 478
479 with addCommand(createDevEnv, 'devenv') as command: 479 with addCommand(createDevEnv, 'devenv') as command:
480 command.shortDescription = 'Set up a development environment' 480 command.shortDescription = 'Set up a development environment'
481 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' 481 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.'
482 command.supportedTypes = ('chrome', 'safari') 482 command.supportedTypes = ('gecko-webext', 'chrome', 'safari')
483 483
484 with addCommand(setupTranslations, 'setuptrans') as command: 484 with addCommand(setupTranslations, 'setuptrans') as command:
485 command.shortDescription = 'Sets up translation languages' 485 command.shortDescription = 'Sets up translation languages'
486 command.description = 'Sets up translation languages for the project on crow din.net.' 486 command.description = 'Sets up translation languages for the project on crow din.net.'
487 command.params = '[options] project-key' 487 command.params = '[options] project-key'
488 command.supportedTypes = ('gecko', 'chrome', 'generic') 488 command.supportedTypes = ('gecko', 'chrome', 'generic')
489 489
490 with addCommand(updateTranslationMaster, 'translate') as command: 490 with addCommand(updateTranslationMaster, 'translate') as command:
491 command.shortDescription = 'Updates translation master files' 491 command.shortDescription = 'Updates translation master files'
492 command.description = 'Updates the translation master files in the project o n crowdin.net.' 492 command.description = 'Updates the translation master files in the project o n crowdin.net.'
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 if option in ('-h', '--help'): 598 if option in ('-h', '--help'):
599 usage(scriptName, type, command) 599 usage(scriptName, type, command)
600 sys.exit() 600 sys.exit()
601 commands[command](baseDir, scriptName, opts, args, type) 601 commands[command](baseDir, scriptName, opts, args, type)
602 else: 602 else:
603 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
604 usage(scriptName, type) 604 usage(scriptName, type)
605 else: 605 else:
606 print 'Command %s is unrecognized' % command 606 print 'Command %s is unrecognized' % command
607 usage(scriptName, type) 607 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | packagerChrome.py » ('j') | packagerChrome.py » ('J')

Powered by Google App Engine
This is Rietveld