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

Delta Between Two Patch Sets: build.py

Issue 29562599: Issue 5751 - Removing legacy gecko support (Closed)
Left Patch Set: Rebasing agains 5763, purging .properties code, addressing comments Created Oct. 4, 2017, 11:37 a.m.
Right Patch Set: Rebase against current master ( 489:293593da6033 ) Created Oct. 10, 2017, 9:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « LocaleTester.pm ('k') | lib/hooks.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 in {'chrome', 'gecko-webext'}: 221 if type != 'generic':
Sebastian Noack 2017/10/04 22:33:00 I think we can make all the translation commands (
tlucas 2017/10/05 10:10:30 Good idea, would clean things up a bit more. Done.
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 key = args[0] 290 key = args[0]
292 291
293 from buildtools.packager import readMetadata 292 from buildtools.packager import readMetadata
294 metadata = readMetadata(baseDir, type) 293 metadata = readMetadata(baseDir, type)
295 294
296 basename = metadata.get('general', 'basename') 295 basename = metadata.get('general', 'basename')
297 localeConfig = readLocaleConfig(baseDir, type, metadata) 296 localeConfig = readLocaleConfig(baseDir, type, metadata)
298 297
299 import buildtools.localeTools as localeTools 298 import buildtools.localeTools as localeTools
300 for locale, localeDir in localeConfig['locales'].iteritems(): 299 for locale, localeDir in localeConfig['locales'].iteritems():
301 if locale != localeConfig['default_locale']: 300 if locale != localeConfig['default_locale'].replace('_', '-'):
302 localeTools.uploadTranslations(localeConfig, metadata, localeDir, lo cale, 301 localeTools.uploadTranslations(localeConfig, metadata, localeDir, lo cale,
303 basename, key) 302 basename, key)
304 303
305 304
306 def getTranslations(baseDir, scriptName, opts, args, type): 305 def getTranslations(baseDir, scriptName, opts, args, type):
307 if len(args) < 1: 306 if len(args) < 1:
308 print 'Project key is required to update translation master files.' 307 print 'Project key is required to update translation master files.'
309 usage(scriptName, type, 'translate') 308 usage(scriptName, type, 'translate')
310 return 309 return
311 310
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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')
397 command.supportedTypes = ('gecko-webext', 'chrome', 'safari', 'edge') 397 command.supportedTypes = ('gecko-webext', 'chrome', 'safari', 'edge')
398 398
399 with addCommand(createDevEnv, 'devenv') as command: 399 with addCommand(createDevEnv, 'devenv') as command:
400 command.shortDescription = 'Set up a development environment' 400 command.shortDescription = 'Set up a development environment'
401 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' 401 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.'
402 command.supportedTypes = ('gecko-webext', 'chrome', 'safari') 402 command.supportedTypes = ('gecko-webext', 'chrome', 'safari')
403 403
404 with addCommand(setupTranslations, 'setuptrans') as command: 404 with addCommand(setupTranslations, 'setuptrans') as command:
405 command.shortDescription = 'Sets up translation languages' 405 command.shortDescription = 'Sets up translation languages'
406 command.description = 'Sets up translation languages for the project on crow din.net.' 406 command.description = 'Sets up translation languages for the project on crow din.net.'
407 command.params = '[options] project-key' 407 command.params = '[options] project-key'
408 command.supportedTypes = ('chrome', 'generic')
409 408
410 with addCommand(updateTranslationMaster, 'translate') as command: 409 with addCommand(updateTranslationMaster, 'translate') as command:
411 command.shortDescription = 'Updates translation master files' 410 command.shortDescription = 'Updates translation master files'
412 command.description = 'Updates the translation master files in the project o n crowdin.net.' 411 command.description = 'Updates the translation master files in the project o n crowdin.net.'
413 command.params = '[options] project-key' 412 command.params = '[options] project-key'
414 command.supportedTypes = ('chrome', 'generic')
415 413
416 with addCommand(uploadTranslations, 'uploadtrans') as command: 414 with addCommand(uploadTranslations, 'uploadtrans') as command:
417 command.shortDescription = 'Uploads existing translations' 415 command.shortDescription = 'Uploads existing translations'
418 command.description = 'Uploads already existing translations to the project on crowdin.net.' 416 command.description = 'Uploads already existing translations to the project on crowdin.net.'
419 command.params = '[options] project-key' 417 command.params = '[options] project-key'
420 command.supportedTypes = ('chrome', 'generic')
421 418
422 with addCommand(getTranslations, 'gettranslations') as command: 419 with addCommand(getTranslations, 'gettranslations') as command:
423 command.shortDescription = 'Downloads translation updates' 420 command.shortDescription = 'Downloads translation updates'
424 command.description = 'Downloads updated translations from crowdin.net.' 421 command.description = 'Downloads updated translations from crowdin.net.'
425 command.params = '[options] project-key' 422 command.params = '[options] project-key'
426 command.supportedTypes = ('chrome', 'generic')
427 423
428 with addCommand(generateDocs, 'docs') as command: 424 with addCommand(generateDocs, 'docs') as command:
429 command.shortDescription = 'Generate documentation (requires node.js)' 425 command.shortDescription = 'Generate documentation (requires node.js)'
430 command.description = ('Generate documentation files and write them into ' 426 command.description = ('Generate documentation files and write them into '
431 'the specified directory.') 427 'the specified directory.')
432 command.addOption('Suppress JsDoc output', short='q', long='quiet') 428 command.addOption('Suppress JsDoc output', short='q', long='quiet')
433 command.params = '[options] <directory>' 429 command.params = '[options] <directory>'
434 command.supportedTypes = ('chrome') 430 command.supportedTypes = ('chrome',)
435 431
436 with addCommand(runReleaseAutomation, 'release') as command: 432 with addCommand(runReleaseAutomation, 'release') as command:
437 command.shortDescription = 'Run release automation' 433 command.shortDescription = 'Run release automation'
438 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.'
439 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'))
440 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')
441 command.params = '[options] <version>' 437 command.params = '[options] <version>'
442 command.supportedTypes = ('chrome', 'safari', 'edge') 438 command.supportedTypes = ('chrome', 'safari', 'edge')
443 439
444 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
512 if option in ('-h', '--help'): 508 if option in ('-h', '--help'):
513 usage(scriptName, type, command) 509 usage(scriptName, type, command)
514 sys.exit() 510 sys.exit()
515 commands[command](baseDir, scriptName, opts, args, type) 511 commands[command](baseDir, scriptName, opts, args, type)
516 else: 512 else:
517 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
518 usage(scriptName, type) 514 usage(scriptName, type)
519 else: 515 else:
520 print 'Command %s is unrecognized' % command 516 print 'Command %s is unrecognized' % command
521 usage(scriptName, type) 517 usage(scriptName, type)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld