| 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 | 10 import buildtools |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 def runBuild(baseDir, scriptName, opts, args, type): | 178 def runBuild(baseDir, scriptName, opts, args, type): |
| 179 kwargs = {} | 179 kwargs = {} |
| 180 for option, value in opts: | 180 for option, value in opts: |
| 181 if option in {'-l', '--locales'} and type == 'gecko': | 181 if option in {'-l', '--locales'} and type == 'gecko': |
| 182 kwargs['locales'] = value.split(',') | 182 kwargs['locales'] = value.split(',') |
| 183 elif option in {'-b', '--build'}: | 183 elif option in {'-b', '--build'}: |
| 184 kwargs['buildNum'] = value | 184 kwargs['buildNum'] = value |
| 185 if type != 'gecko' and not kwargs['buildNum'].isdigit(): | 185 no_gecko_build = type not in {'gecko', 'gecko-webext'} |
| 186 if no_gecko_build and not kwargs['buildNum'].isdigit(): |
| 186 raise TypeError('Build number must be numerical') | 187 raise TypeError('Build number must be numerical') |
| 187 elif option in {'-k', '--key'}: | 188 elif option in {'-k', '--key'}: |
| 188 kwargs['keyFile'] = value | 189 kwargs['keyFile'] = value |
| 189 elif option in {'-m', '--multi-compartment'} and type == 'gecko': | 190 elif option in {'-m', '--multi-compartment'} and type == 'gecko': |
| 190 kwargs['multicompartment'] = True | 191 kwargs['multicompartment'] = True |
| 191 elif option in {'-r', '--release'}: | 192 elif option in {'-r', '--release'}: |
| 192 kwargs['releaseBuild'] = True | 193 kwargs['releaseBuild'] = True |
| 193 if len(args) > 0: | 194 if len(args) > 0: |
| 194 kwargs['outFile'] = args[0] | 195 kwargs['outFile'] = args[0] |
| 195 | 196 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return | 406 return |
| 406 targetDir = args[0] | 407 targetDir = args[0] |
| 407 | 408 |
| 408 source_dir = os.path.join(baseDir, 'lib') | 409 source_dir = os.path.join(baseDir, 'lib') |
| 409 sources = [source_dir] | 410 sources = [source_dir] |
| 410 | 411 |
| 411 # JSDoc struggles wih huge objects: https://github.com/jsdoc3/jsdoc/issues/9
76 | 412 # JSDoc struggles wih huge objects: https://github.com/jsdoc3/jsdoc/issues/9
76 |
| 412 if type == 'chrome': | 413 if type == 'chrome': |
| 413 sources = [os.path.join(source_dir, filename) for filename in os.listdir
(source_dir) if filename != 'publicSuffixList.js'] | 414 sources = [os.path.join(source_dir, filename) for filename in os.listdir
(source_dir) if filename != 'publicSuffixList.js'] |
| 414 | 415 |
| 415 config = os.path.join(os.path.dirname(__file__), 'jsdoc.conf') | 416 buildtools_path = os.path.dirname(__file__) |
| 416 command = ['jsdoc', '--destination', targetDir, '--configure', config] + sou
rces | 417 config = os.path.join(buildtools_path, 'jsdoc.conf') |
| 418 |
| 419 command = ['npm', 'run-script', 'jsdoc', '--', '--destination', targetDir, |
| 420 '--configure', config] + sources |
| 417 if any(opt in ('-q', '--quiet') for opt, _ in opts): | 421 if any(opt in ('-q', '--quiet') for opt, _ in opts): |
| 418 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subpr
ocess.PIPE) | 422 process = subprocess.Popen(command, stdout=subprocess.PIPE, |
| 423 stderr=subprocess.PIPE, cwd=buildtools_path) |
| 419 stderr = process.communicate()[1] | 424 stderr = process.communicate()[1] |
| 420 retcode = process.poll() | 425 retcode = process.poll() |
| 421 if retcode: | 426 if retcode: |
| 422 sys.stderr.write(stderr) | 427 sys.stderr.write(stderr) |
| 423 raise subprocess.CalledProcessError(command, retcode) | 428 raise subprocess.CalledProcessError(command, retcode) |
| 424 else: | 429 else: |
| 425 subprocess.check_call(command) | 430 subprocess.check_call(command, cwd=buildtools_path) |
| 426 | 431 |
| 427 | 432 |
| 428 def runReleaseAutomation(baseDir, scriptName, opts, args, type): | 433 def runReleaseAutomation(baseDir, scriptName, opts, args, type): |
| 429 keyFile = None | 434 keyFile = None |
| 430 downloadsRepo = os.path.join(baseDir, '..', 'downloads') | 435 downloadsRepo = os.path.join(baseDir, '..', 'downloads') |
| 431 for option, value in opts: | 436 for option, value in opts: |
| 432 if option in ('-k', '--key'): | 437 if option in ('-k', '--key'): |
| 433 keyFile = value | 438 keyFile = value |
| 434 elif option in ('-d', '--downloads'): | 439 elif option in ('-d', '--downloads'): |
| 435 downloadsRepo = value | 440 downloadsRepo = value |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 514 |
| 510 with addCommand(showDescriptions, 'showdesc') as command: | 515 with addCommand(showDescriptions, 'showdesc') as command: |
| 511 command.shortDescription = 'Print description strings for all locales' | 516 command.shortDescription = 'Print description strings for all locales' |
| 512 command.description = 'Display description strings for all locales as specif
ied in the corresponding meta.properties files.' | 517 command.description = 'Display description strings for all locales as specif
ied in the corresponding meta.properties files.' |
| 513 command.addOption('Only include the given locales', short='l', long='locales
', value='l1,l2,l3') | 518 command.addOption('Only include the given locales', short='l', long='locales
', value='l1,l2,l3') |
| 514 command.params = '[options]' | 519 command.params = '[options]' |
| 515 command.supportedTypes = ('gecko') | 520 command.supportedTypes = ('gecko') |
| 516 | 521 |
| 517 with addCommand(generateDocs, 'docs') as command: | 522 with addCommand(generateDocs, 'docs') as command: |
| 518 command.shortDescription = 'Generate documentation (requires node.js)' | 523 command.shortDescription = 'Generate documentation (requires node.js)' |
| 519 command.description = 'Generate documentation files and write them into the
specified directory. This operation requires JsDoc 3 to be installed.' | 524 command.description = ('Generate documentation files and write them into ' |
| 525 'the specified directory.') |
| 520 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 526 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
| 521 command.params = '[options] <directory>' | 527 command.params = '[options] <directory>' |
| 522 command.supportedTypes = ('gecko', 'chrome') | 528 command.supportedTypes = ('gecko', 'chrome') |
| 523 | 529 |
| 524 with addCommand(runReleaseAutomation, 'release') as command: | 530 with addCommand(runReleaseAutomation, 'release') as command: |
| 525 command.shortDescription = 'Run release automation' | 531 command.shortDescription = 'Run release automation' |
| 526 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.' | 532 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.' |
| 527 command.addOption('File containing private key and certificates required to
sign the release.', short='k', long='key', value='file', types=('chrome', 'safar
i', 'edge')) | 533 command.addOption('File containing private key and certificates required to
sign the release.', short='k', long='key', value='file', types=('chrome', 'safar
i', 'edge')) |
| 528 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') | 534 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') |
| 529 command.params = '[options] <version>' | 535 command.params = '[options] <version>' |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if option in ('-h', '--help'): | 606 if option in ('-h', '--help'): |
| 601 usage(scriptName, type, command) | 607 usage(scriptName, type, command) |
| 602 sys.exit() | 608 sys.exit() |
| 603 commands[command](baseDir, scriptName, opts, args, type) | 609 commands[command](baseDir, scriptName, opts, args, type) |
| 604 else: | 610 else: |
| 605 print 'Command %s is not supported for this application type' % comm
and | 611 print 'Command %s is not supported for this application type' % comm
and |
| 606 usage(scriptName, type) | 612 usage(scriptName, type) |
| 607 else: | 613 else: |
| 608 print 'Command %s is unrecognized' % command | 614 print 'Command %s is unrecognized' % command |
| 609 usage(scriptName, type) | 615 usage(scriptName, type) |
| LEFT | RIGHT |