Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 | |
11 from getopt import getopt, GetoptError | 10 from getopt import getopt, GetoptError |
12 from StringIO import StringIO | 11 from StringIO import StringIO |
13 from zipfile import ZipFile | 12 from zipfile import ZipFile |
14 | 13 |
15 knownTypes = ('gecko-webext', 'chrome', 'safari', 'generic', 'edge') | 14 knownTypes = ('gecko-webext', 'chrome', 'safari', 'generic', 'edge') |
16 | 15 |
17 | 16 |
18 class Command(object): | 17 class Command(object): |
19 name = property(lambda self: self._name) | 18 name = property(lambda self: self._name) |
20 shortDescription = property( | 19 shortDescription = property( |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 devenv_dir = getDevEnvPath(baseDir, type) | 211 devenv_dir = getDevEnvPath(baseDir, type) |
213 | 212 |
214 shutil.rmtree(devenv_dir, ignore_errors=True) | 213 shutil.rmtree(devenv_dir, ignore_errors=True) |
215 | 214 |
216 file.seek(0) | 215 file.seek(0) |
217 with ZipFile(file, 'r') as zip_file: | 216 with ZipFile(file, 'r') as zip_file: |
218 zip_file.extractall(devenv_dir) | 217 zip_file.extractall(devenv_dir) |
219 | 218 |
220 | 219 |
221 def readLocaleConfig(baseDir, type, metadata): | 220 def readLocaleConfig(baseDir, type, metadata): |
222 if type != 'generic': | 221 if type != 'generic': |
Vasily Kuznetsov
2017/10/10 12:44:33
We could swap the branches of this if statement to
tlucas
2017/10/10 12:50:13
Well, imho the "not generic" platforms are those m
| |
223 import buildtools.packagerChrome as packager | 222 import buildtools.packagerChrome as packager |
224 localeDir = os.path.join(baseDir, '_locales') | 223 localeDir = os.path.join(baseDir, '_locales') |
225 localeConfig = { | 224 localeConfig = { |
226 'default_locale': packager.defaultLocale, | 225 'default_locale': packager.defaultLocale, |
227 } | 226 } |
228 else: | 227 else: |
229 localeDir = os.path.join( | 228 localeDir = os.path.join( |
230 baseDir, *metadata.get('locales', 'base_path').split('/') | 229 baseDir, *metadata.get('locales', 'base_path').split('/') |
231 ) | 230 ) |
232 localeConfig = { | 231 localeConfig = { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 return | 376 return |
378 | 377 |
379 import buildtools.releaseAutomation as releaseAutomation | 378 import buildtools.releaseAutomation as releaseAutomation |
380 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) | 379 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) |
381 | 380 |
382 | 381 |
383 def updatePSL(baseDir, scriptName, opts, args, type): | 382 def updatePSL(baseDir, scriptName, opts, args, type): |
384 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater | 383 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater |
385 publicSuffixListUpdater.updatePSL(baseDir) | 384 publicSuffixListUpdater.updatePSL(baseDir) |
386 | 385 |
386 | |
387 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: | 387 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: |
388 command.shortDescription = 'Show this message' | 388 command.shortDescription = 'Show this message' |
389 | 389 |
390 with addCommand(runBuild, 'build') as command: | 390 with addCommand(runBuild, 'build') as command: |
391 command.shortDescription = 'Create a build' | 391 command.shortDescription = 'Create a build' |
392 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' | 392 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' |
393 command.params = '[options] [output_file]' | 393 command.params = '[options] [output_file]' |
394 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') | 394 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') |
395 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome', 'safari ')) | 395 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome', 'safari ')) |
396 command.addOption('Create a release build', short='r', long='release') | 396 command.addOption('Create a release build', short='r', long='release') |
(...skipping 23 matching lines...) Expand all Loading... | |
420 command.shortDescription = 'Downloads translation updates' | 420 command.shortDescription = 'Downloads translation updates' |
421 command.description = 'Downloads updated translations from crowdin.net.' | 421 command.description = 'Downloads updated translations from crowdin.net.' |
422 command.params = '[options] project-key' | 422 command.params = '[options] project-key' |
423 | 423 |
424 with addCommand(generateDocs, 'docs') as command: | 424 with addCommand(generateDocs, 'docs') as command: |
425 command.shortDescription = 'Generate documentation (requires node.js)' | 425 command.shortDescription = 'Generate documentation (requires node.js)' |
426 command.description = ('Generate documentation files and write them into ' | 426 command.description = ('Generate documentation files and write them into ' |
427 'the specified directory.') | 427 'the specified directory.') |
428 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 428 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
429 command.params = '[options] <directory>' | 429 command.params = '[options] <directory>' |
430 command.supportedTypes = ('chrome') | 430 command.supportedTypes = ('chrome',) |
431 | 431 |
432 with addCommand(runReleaseAutomation, 'release') as command: | 432 with addCommand(runReleaseAutomation, 'release') as command: |
433 command.shortDescription = 'Run release automation' | 433 command.shortDescription = 'Run release automation' |
434 command.description = 'Note: If you are not the project owner then you ' "probably don't want to run this!\n\n" 'Runs release automation: crea tes downloads for the new version, tags ' 'source code repository as well as downloads and buildtools repository.' | 434 command.description = 'Note: If you are not the project owner then you ' "probably don't want to run this!\n\n" 'Runs release automation: crea tes downloads for the new version, tags ' 'source code repository as well as downloads and buildtools repository.' |
435 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'safar i', 'edge')) | 435 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'safar i', 'edge')) |
436 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') | 436 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') |
437 command.params = '[options] <version>' | 437 command.params = '[options] <version>' |
438 command.supportedTypes = ('chrome', 'safari', 'edge') | 438 command.supportedTypes = ('chrome', 'safari', 'edge') |
439 | 439 |
440 with addCommand(updatePSL, 'updatepsl') as command: | 440 with addCommand(updatePSL, 'updatepsl') as command: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 if option in ('-h', '--help'): | 508 if option in ('-h', '--help'): |
509 usage(scriptName, type, command) | 509 usage(scriptName, type, command) |
510 sys.exit() | 510 sys.exit() |
511 commands[command](baseDir, scriptName, opts, args, type) | 511 commands[command](baseDir, scriptName, opts, args, type) |
512 else: | 512 else: |
513 print 'Command %s is not supported for this application type' % comm and | 513 print 'Command %s is not supported for this application type' % comm and |
514 usage(scriptName, type) | 514 usage(scriptName, type) |
515 else: | 515 else: |
516 print 'Command %s is unrecognized' % command | 516 print 'Command %s is unrecognized' % command |
517 usage(scriptName, type) | 517 usage(scriptName, type) |
LEFT | RIGHT |