OLD | NEW |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import os, sys, re, subprocess, shutil, buildtools | 7 import os, sys, re, subprocess, shutil, buildtools |
8 from getopt import getopt, GetoptError | 8 from getopt import getopt, GetoptError |
9 from StringIO import StringIO | 9 from StringIO import StringIO |
10 from zipfile import ZipFile | 10 from zipfile import ZipFile |
11 | 11 |
12 knownTypes = ('gecko', 'chrome', 'opera', 'safari', 'generic') | 12 knownTypes = ('gecko', 'chrome', 'safari', 'generic') |
13 | 13 |
14 class Command(object): | 14 class Command(object): |
15 name = property(lambda self: self._name) | 15 name = property(lambda self: self._name) |
16 shortDescription = property(lambda self: self._shortDescription, | 16 shortDescription = property(lambda self: self._shortDescription, |
17 lambda self, value: self.__dict__.update({'_shortDescription': value})) | 17 lambda self, value: self.__dict__.update({'_shortDescription': value})) |
18 description = property(lambda self: self._description, | 18 description = property(lambda self: self._description, |
19 lambda self, value: self.__dict__.update({'_description': value})) | 19 lambda self, value: self.__dict__.update({'_description': value})) |
20 params = property(lambda self: self._params, | 20 params = property(lambda self: self._params, |
21 lambda self, value: self.__dict__.update({'_params': value})) | 21 lambda self, value: self.__dict__.update({'_params': value})) |
22 supportedTypes = property(lambda self: self._supportedTypes, | 22 supportedTypes = property(lambda self: self._supportedTypes, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 releaseBuild = True | 179 releaseBuild = True |
180 elif option == '--experimental': | 180 elif option == '--experimental': |
181 experimentalAPI = True | 181 experimentalAPI = True |
182 outFile = args[0] if len(args) > 0 else None | 182 outFile = args[0] if len(args) > 0 else None |
183 | 183 |
184 if type == 'gecko': | 184 if type == 'gecko': |
185 import buildtools.packagerGecko as packager | 185 import buildtools.packagerGecko as packager |
186 packager.createBuild(baseDir, type=type, outFile=outFile, locales=locales, b
uildNum=buildNum, | 186 packager.createBuild(baseDir, type=type, outFile=outFile, locales=locales, b
uildNum=buildNum, |
187 releaseBuild=releaseBuild, keyFile=keyFile, | 187 releaseBuild=releaseBuild, keyFile=keyFile, |
188 multicompartment=multicompartment) | 188 multicompartment=multicompartment) |
189 elif type == 'chrome' or type == 'opera': | 189 elif type == 'chrome': |
190 import buildtools.packagerChrome as packager | 190 import buildtools.packagerChrome as packager |
191 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=buildNum, | 191 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=buildNum, |
192 releaseBuild=releaseBuild, keyFile=keyFile, | 192 releaseBuild=releaseBuild, keyFile=keyFile, |
193 experimentalAPI=experimentalAPI) | 193 experimentalAPI=experimentalAPI) |
194 elif type == 'safari': | 194 elif type == 'safari': |
195 import buildtools.packagerSafari as packager | 195 import buildtools.packagerSafari as packager |
196 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=buildNum, | 196 packager.createBuild(baseDir, type=type, outFile=outFile, buildNum=buildNum, |
197 releaseBuild=releaseBuild, keyFile=keyFile) | 197 releaseBuild=releaseBuild, keyFile=keyFile) |
198 | 198 |
199 | 199 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 def readLocaleConfig(baseDir, type, metadata): | 239 def readLocaleConfig(baseDir, type, metadata): |
240 if type == 'gecko': | 240 if type == 'gecko': |
241 import buildtools.packagerGecko as packager | 241 import buildtools.packagerGecko as packager |
242 localeDir = packager.getLocalesDir(baseDir) | 242 localeDir = packager.getLocalesDir(baseDir) |
243 localeConfig = { | 243 localeConfig = { |
244 'name_format': 'BCP-47', | 244 'name_format': 'BCP-47', |
245 'file_format': 'gecko-dtd', | 245 'file_format': 'gecko-dtd', |
246 'target_platforms': {'gecko'}, | 246 'target_platforms': {'gecko'}, |
247 'default_locale': packager.defaultLocale | 247 'default_locale': packager.defaultLocale |
248 } | 248 } |
249 elif type == 'chrome' or type == 'opera': | 249 elif type == 'chrome': |
250 import buildtools.packagerChrome as packager | 250 import buildtools.packagerChrome as packager |
251 localeDir = os.path.join(baseDir, '_locales') | 251 localeDir = os.path.join(baseDir, '_locales') |
252 localeConfig = { | 252 localeConfig = { |
253 'name_format': 'ISO-15897', | 253 'name_format': 'ISO-15897', |
254 'file_format': 'chrome-json', | 254 'file_format': 'chrome-json', |
255 'target_platforms': {'chrome'}, | 255 'target_platforms': {'chrome'}, |
256 'default_locale': packager.defaultLocale, | 256 'default_locale': packager.defaultLocale, |
257 } | 257 } |
258 else: | 258 else: |
259 localeDir = os.path.join(baseDir, | 259 localeDir = os.path.join(baseDir, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName,
type), ('help', '-h', '--help')) as command: | 453 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName,
type), ('help', '-h', '--help')) as command: |
454 command.shortDescription = 'Show this message' | 454 command.shortDescription = 'Show this message' |
455 | 455 |
456 with addCommand(runBuild, 'build') as command: | 456 with addCommand(runBuild, 'build') as command: |
457 command.shortDescription = 'Create a build' | 457 command.shortDescription = 'Create a build' |
458 command.description = 'Creates an extension build with given file name. If out
put_file is missing a default name will be chosen.' | 458 command.description = 'Creates an extension build with given file name. If out
put_file is missing a default name will be chosen.' |
459 command.params = '[options] [output_file]' | 459 command.params = '[options] [output_file]' |
460 command.addOption('Only include the given locales (if omitted: all locales not
marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=('ge
cko')) | 460 command.addOption('Only include the given locales (if omitted: all locales not
marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=('ge
cko')) |
461 command.addOption('Use given build number (if omitted the build number will be
retrieved from Mercurial)', short='b', long='build', value='num') | 461 command.addOption('Use given build number (if omitted the build number will be
retrieved from Mercurial)', short='b', long='build', value='num') |
462 command.addOption('File containing private key and certificates required to si
gn the package', short='k', long='key', value='file', types=('gecko', 'chrome',
'opera', 'safari')) | 462 command.addOption('File containing private key and certificates required to si
gn the package', short='k', long='key', value='file', types=('gecko', 'chrome',
'safari')) |
463 command.addOption('Create a build for leak testing', short='m', long='multi-co
mpartment', types=('gecko')) | 463 command.addOption('Create a build for leak testing', short='m', long='multi-co
mpartment', types=('gecko')) |
464 command.addOption('Create a release build', short='r', long='release') | 464 command.addOption('Create a release build', short='r', long='release') |
465 command.addOption('Enable use of experimental APIs', long='experimental') | 465 command.addOption('Enable use of experimental APIs', long='experimental') |
466 command.supportedTypes = ('gecko', 'chrome', 'opera', 'safari') | 466 command.supportedTypes = ('gecko', 'chrome', 'safari') |
467 | 467 |
468 with addCommand(runAutoInstall, 'autoinstall') as command: | 468 with addCommand(runAutoInstall, 'autoinstall') as command: |
469 command.shortDescription = 'Install extension automatically' | 469 command.shortDescription = 'Install extension automatically' |
470 command.description = 'Will automatically install the extension in a browser r
unning Extension Auto-Installer. If host parameter is omitted assumes that the b
rowser runs on localhost.' | 470 command.description = 'Will automatically install the extension in a browser r
unning Extension Auto-Installer. If host parameter is omitted assumes that the b
rowser runs on localhost.' |
471 command.params = '[<host>:]<port>' | 471 command.params = '[<host>:]<port>' |
472 command.addOption('Create a build for leak testing', short='m', long='multi-co
mpartment') | 472 command.addOption('Create a build for leak testing', short='m', long='multi-co
mpartment') |
473 command.supportedTypes = ('gecko') | 473 command.supportedTypes = ('gecko') |
474 | 474 |
475 with addCommand(createDevEnv, 'devenv') as command: | 475 with addCommand(createDevEnv, 'devenv') as command: |
476 command.shortDescription = 'Set up a development environment' | 476 command.shortDescription = 'Set up a development environment' |
477 command.description = 'Will set up or update the devenv folder as an unpacked
extension folder for development.' | 477 command.description = 'Will set up or update the devenv folder as an unpacked
extension folder for development.' |
478 command.supportedTypes = ('chrome', 'opera', 'safari') | 478 command.supportedTypes = ('chrome', 'safari') |
479 | 479 |
480 with addCommand(setupTranslations, 'setuptrans') as command: | 480 with addCommand(setupTranslations, 'setuptrans') as command: |
481 command.shortDescription = 'Sets up translation languages' | 481 command.shortDescription = 'Sets up translation languages' |
482 command.description = 'Sets up translation languages for the project on crowdi
n.net.' | 482 command.description = 'Sets up translation languages for the project on crowdi
n.net.' |
483 command.params = '[options] project-key' | 483 command.params = '[options] project-key' |
484 command.supportedTypes = ('gecko', 'chrome', 'opera', 'generic') | 484 command.supportedTypes = ('gecko', 'chrome', 'generic') |
485 | 485 |
486 with addCommand(updateTranslationMaster, 'translate') as command: | 486 with addCommand(updateTranslationMaster, 'translate') as command: |
487 command.shortDescription = 'Updates translation master files' | 487 command.shortDescription = 'Updates translation master files' |
488 command.description = 'Updates the translation master files in the project on
crowdin.net.' | 488 command.description = 'Updates the translation master files in the project on
crowdin.net.' |
489 command.params = '[options] project-key' | 489 command.params = '[options] project-key' |
490 command.supportedTypes = ('gecko', 'chrome', 'opera', 'generic') | 490 command.supportedTypes = ('gecko', 'chrome', 'generic') |
491 | 491 |
492 with addCommand(uploadTranslations, 'uploadtrans') as command: | 492 with addCommand(uploadTranslations, 'uploadtrans') as command: |
493 command.shortDescription = 'Uploads existing translations' | 493 command.shortDescription = 'Uploads existing translations' |
494 command.description = 'Uploads already existing translations to the project on
crowdin.net.' | 494 command.description = 'Uploads already existing translations to the project on
crowdin.net.' |
495 command.params = '[options] project-key' | 495 command.params = '[options] project-key' |
496 command.supportedTypes = ('gecko', 'chrome', 'opera', 'generic') | 496 command.supportedTypes = ('gecko', 'chrome', 'generic') |
497 | 497 |
498 with addCommand(getTranslations, 'gettranslations') as command: | 498 with addCommand(getTranslations, 'gettranslations') as command: |
499 command.shortDescription = 'Downloads translation updates' | 499 command.shortDescription = 'Downloads translation updates' |
500 command.description = 'Downloads updated translations from crowdin.net.' | 500 command.description = 'Downloads updated translations from crowdin.net.' |
501 command.params = '[options] project-key' | 501 command.params = '[options] project-key' |
502 command.supportedTypes = ('gecko', 'chrome', 'opera', 'generic') | 502 command.supportedTypes = ('gecko', 'chrome', 'generic') |
503 | 503 |
504 with addCommand(showDescriptions, 'showdesc') as command: | 504 with addCommand(showDescriptions, 'showdesc') as command: |
505 command.shortDescription = 'Print description strings for all locales' | 505 command.shortDescription = 'Print description strings for all locales' |
506 command.description = 'Display description strings for all locales as specifie
d in the corresponding meta.properties files.' | 506 command.description = 'Display description strings for all locales as specifie
d in the corresponding meta.properties files.' |
507 command.addOption('Only include the given locales', short='l', long='locales',
value='l1,l2,l3') | 507 command.addOption('Only include the given locales', short='l', long='locales',
value='l1,l2,l3') |
508 command.params = '[options]' | 508 command.params = '[options]' |
509 command.supportedTypes = ('gecko') | 509 command.supportedTypes = ('gecko') |
510 | 510 |
511 with addCommand(generateDocs, 'docs') as command: | 511 with addCommand(generateDocs, 'docs') as command: |
512 command.shortDescription = 'Generate documentation (requires node.js)' | 512 command.shortDescription = 'Generate documentation (requires node.js)' |
513 command.description = 'Generate documentation files and write them into the sp
ecified directory. This operation requires JsDoc 3 to be installed.' | 513 command.description = 'Generate documentation files and write them into the sp
ecified directory. This operation requires JsDoc 3 to be installed.' |
514 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 514 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
515 command.params = '[options] <directory>' | 515 command.params = '[options] <directory>' |
516 command.supportedTypes = ('gecko', 'chrome') | 516 command.supportedTypes = ('gecko', 'chrome') |
517 | 517 |
518 with addCommand(runReleaseAutomation, 'release') as command: | 518 with addCommand(runReleaseAutomation, 'release') as command: |
519 command.shortDescription = 'Run release automation' | 519 command.shortDescription = 'Run release automation' |
520 command.description = 'Note: If you are not the project owner then you '\ | 520 command.description = 'Note: If you are not the project owner then you '\ |
521 'probably don\'t want to run this!\n\n'\ | 521 'probably don\'t want to run this!\n\n'\ |
522 'Runs release automation: creates downloads for the new version, tags '\ | 522 'Runs release automation: creates downloads for the new version, tags '\ |
523 'source code repository as well as downloads and buildtools repository.' | 523 'source code repository as well as downloads and buildtools repository.' |
524 command.addOption('File containing private key and certificates required to si
gn the release. Note that for Chrome releases this option needs to be specified
twice: first a key to sign Chrome/Opera builds, then another to sign the Safari
build.', short='k', long='key', value='file', types=('gecko', 'chrome')) | 524 command.addOption('File containing private key and certificates required to si
gn the release. Note that for Chrome releases this option needs to be specified
twice: first a key to sign Chrome builds, then another to sign the Safari build.
', short='k', long='key', value='file', types=('gecko', 'chrome')) |
525 command.addOption('Directory containing downloads repository (if omitted ../do
wnloads is assumed)', short='d', long='downloads', value='dir') | 525 command.addOption('Directory containing downloads repository (if omitted ../do
wnloads is assumed)', short='d', long='downloads', value='dir') |
526 command.params = '[options] <version>' | 526 command.params = '[options] <version>' |
527 command.supportedTypes = ('gecko', 'chrome') | 527 command.supportedTypes = ('gecko', 'chrome') |
528 | 528 |
529 with addCommand(updatePSL, 'updatepsl') as command: | 529 with addCommand(updatePSL, 'updatepsl') as command: |
530 command.shortDescription = 'Updates Public Suffix List' | 530 command.shortDescription = 'Updates Public Suffix List' |
531 command.description = 'Downloads Public Suffix List (see http://publicsuffix.o
rg/) and generates lib/publicSuffixList.js from it.' | 531 command.description = 'Downloads Public Suffix List (see http://publicsuffix.o
rg/) and generates lib/publicSuffixList.js from it.' |
532 command.supportedTypes = ('chrome', 'opera') | 532 command.supportedTypes = ('chrome',) |
533 | 533 |
534 def getType(baseDir, scriptName, args): | 534 def getType(baseDir, scriptName, args): |
535 # Look for an explicit type parameter (has to be the first parameter) | 535 # Look for an explicit type parameter (has to be the first parameter) |
536 if len(args) >= 2 and args[0] == '-t': | 536 if len(args) >= 2 and args[0] == '-t': |
537 type = args[1] | 537 type = args[1] |
538 del args[1] | 538 del args[1] |
539 del args[0] | 539 del args[0] |
540 if type not in knownTypes: | 540 if type not in knownTypes: |
541 print ''' | 541 print ''' |
542 Unknown type %s specified, supported types are: %s | 542 Unknown type %s specified, supported types are: %s |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 if option in ('-h', '--help'): | 595 if option in ('-h', '--help'): |
596 usage(scriptName, type, command) | 596 usage(scriptName, type, command) |
597 sys.exit() | 597 sys.exit() |
598 commands[command](baseDir, scriptName, opts, args, type) | 598 commands[command](baseDir, scriptName, opts, args, type) |
599 else: | 599 else: |
600 print 'Command %s is not supported for this application type' % command | 600 print 'Command %s is not supported for this application type' % command |
601 usage(scriptName, type) | 601 usage(scriptName, type) |
602 else: | 602 else: |
603 print 'Command %s is unrecognized' % command | 603 print 'Command %s is unrecognized' % command |
604 usage(scriptName, type) | 604 usage(scriptName, type) |
OLD | NEW |