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

Delta Between Two Patch Sets: build.py

Issue 29562614: Issue 5752 - Removing safari support (Closed)
Left Patch Set: Created Oct. 2, 2017, 10:35 a.m.
Right Patch Set: NO CHANGE rebase against #5751 @ Patch Set 7 Created Oct. 10, 2017, 9:28 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 | « no previous file | packagerSafari.py » ('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', 'generic', 'edge') 14 knownTypes = ('gecko-webext', 'chrome', '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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 'description': description, 172 'description': description,
174 'options': '\n'.join(options) 173 'options': '\n'.join(options)
175 } 174 }
176 175
177 176
178 def runBuild(baseDir, scriptName, opts, args, type): 177 def runBuild(baseDir, scriptName, opts, args, type):
179 kwargs = {} 178 kwargs = {}
180 for option, value in opts: 179 for option, value in opts:
181 if option in {'-b', '--build'}: 180 if option in {'-b', '--build'}:
182 kwargs['buildNum'] = value 181 kwargs['buildNum'] = value
183 no_gecko_build = type != 'gecko-webext' 182 if type != 'gecko-webext' and not kwargs['buildNum'].isdigit():
184 if no_gecko_build and not kwargs['buildNum'].isdigit():
185 raise TypeError('Build number must be numerical') 183 raise TypeError('Build number must be numerical')
186 elif option in {'-k', '--key'}: 184 elif option in {'-k', '--key'}:
187 kwargs['keyFile'] = value 185 kwargs['keyFile'] = value
188 elif option in {'-r', '--release'}: 186 elif option in {'-r', '--release'}:
189 kwargs['releaseBuild'] = True 187 kwargs['releaseBuild'] = True
190 if len(args) > 0: 188 if len(args) > 0:
191 kwargs['outFile'] = args[0] 189 kwargs['outFile'] = args[0]
192 190
193 if type in {'chrome', 'gecko-webext'}: 191 if type in {'chrome', 'gecko-webext'}:
194 import buildtools.packagerChrome as packager 192 import buildtools.packagerChrome as packager
(...skipping 13 matching lines...) Expand all
208 devenv_dir = getDevEnvPath(baseDir, type) 206 devenv_dir = getDevEnvPath(baseDir, type)
209 207
210 shutil.rmtree(devenv_dir, ignore_errors=True) 208 shutil.rmtree(devenv_dir, ignore_errors=True)
211 209
212 file.seek(0) 210 file.seek(0)
213 with ZipFile(file, 'r') as zip_file: 211 with ZipFile(file, 'r') as zip_file:
214 zip_file.extractall(devenv_dir) 212 zip_file.extractall(devenv_dir)
215 213
216 214
217 def readLocaleConfig(baseDir, type, metadata): 215 def readLocaleConfig(baseDir, type, metadata):
218 if type in {'chrome', 'gecko-webext'}: 216 if type != 'generic':
219 import buildtools.packagerChrome as packager 217 import buildtools.packagerChrome as packager
220 localeDir = os.path.join(baseDir, '_locales') 218 localeDir = os.path.join(baseDir, '_locales')
221 localeConfig = { 219 localeConfig = {
222 'name_format': 'ISO-15897',
223 'file_format': 'chrome-json',
224 'target_platforms': {type},
225 'default_locale': packager.defaultLocale, 220 'default_locale': packager.defaultLocale,
226 } 221 }
227 else: 222 else:
228 localeDir = os.path.join( 223 localeDir = os.path.join(
229 baseDir, *metadata.get('locales', 'base_path').split('/') 224 baseDir, *metadata.get('locales', 'base_path').split('/')
230 ) 225 )
231 localeConfig = { 226 localeConfig = {
232 'name_format': metadata.get('locales', 'name_format'),
233 'file_format': metadata.get('locales', 'file_format'),
234 'target_platforms': set(metadata.get('locales',
235 'target_platforms').split()),
236 'default_locale': metadata.get('locales', 'default_locale') 227 'default_locale': metadata.get('locales', 'default_locale')
237 } 228 }
238 229
239 localeConfig['base_path'] = localeDir 230 localeConfig['base_path'] = localeDir
240 231
241 locales = [(locale, os.path.join(localeDir, locale)) 232 locales = [(locale.replace('_', '-'), os.path.join(localeDir, locale))
242 for locale in os.listdir(localeDir)] 233 for locale in os.listdir(localeDir)]
243 if localeConfig['name_format'] == 'ISO-15897':
244 locales = [(locale.replace('_', '-'), localePath)
245 for locale, localePath in locales]
246 localeConfig['locales'] = dict(locales) 234 localeConfig['locales'] = dict(locales)
247 235
248 return localeConfig 236 return localeConfig
249 237
250 238
251 def setupTranslations(baseDir, scriptName, opts, args, type): 239 def setupTranslations(baseDir, scriptName, opts, args, type):
252 if len(args) < 1: 240 if len(args) < 1:
253 print 'Project key is required to update translation master files.' 241 print 'Project key is required to update translation master files.'
254 usage(scriptName, type, 'setuptrans') 242 usage(scriptName, type, 'setuptrans')
255 return 243 return
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 key = args[0] 285 key = args[0]
298 286
299 from buildtools.packager import readMetadata 287 from buildtools.packager import readMetadata
300 metadata = readMetadata(baseDir, type) 288 metadata = readMetadata(baseDir, type)
301 289
302 basename = metadata.get('general', 'basename') 290 basename = metadata.get('general', 'basename')
303 localeConfig = readLocaleConfig(baseDir, type, metadata) 291 localeConfig = readLocaleConfig(baseDir, type, metadata)
304 292
305 import buildtools.localeTools as localeTools 293 import buildtools.localeTools as localeTools
306 for locale, localeDir in localeConfig['locales'].iteritems(): 294 for locale, localeDir in localeConfig['locales'].iteritems():
307 if locale != localeConfig['default_locale']: 295 if locale != localeConfig['default_locale'].replace('_', '-'):
308 localeTools.uploadTranslations(localeConfig, metadata, localeDir, lo cale, 296 localeTools.uploadTranslations(localeConfig, metadata, localeDir, lo cale,
309 basename, key) 297 basename, key)
310 298
311 299
312 def getTranslations(baseDir, scriptName, opts, args, type): 300 def getTranslations(baseDir, scriptName, opts, args, type):
313 if len(args) < 1: 301 if len(args) < 1:
314 print 'Project key is required to update translation master files.' 302 print 'Project key is required to update translation master files.'
315 usage(scriptName, type, 'translate') 303 usage(scriptName, type, 'translate')
316 return 304 return
317 305
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 return 371 return
384 372
385 import buildtools.releaseAutomation as releaseAutomation 373 import buildtools.releaseAutomation as releaseAutomation
386 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) 374 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo)
387 375
388 376
389 def updatePSL(baseDir, scriptName, opts, args, type): 377 def updatePSL(baseDir, scriptName, opts, args, type):
390 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater 378 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater
391 publicSuffixListUpdater.updatePSL(baseDir) 379 publicSuffixListUpdater.updatePSL(baseDir)
392 380
381
393 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: 382 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command:
394 command.shortDescription = 'Show this message' 383 command.shortDescription = 'Show this message'
395 384
396 with addCommand(runBuild, 'build') as command: 385 with addCommand(runBuild, 'build') as command:
397 command.shortDescription = 'Create a build' 386 command.shortDescription = 'Create a build'
398 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' 387 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.'
399 command.params = '[options] [output_file]' 388 command.params = '[options] [output_file]'
400 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') 389 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num')
401 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome')) 390 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome',))
402 command.addOption('Create a release build', short='r', long='release') 391 command.addOption('Create a release build', short='r', long='release')
403 command.supportedTypes = ('gecko-webext', 'chrome', 'edge') 392 command.supportedTypes = ('gecko-webext', 'chrome', 'edge')
404 393
405 with addCommand(createDevEnv, 'devenv') as command: 394 with addCommand(createDevEnv, 'devenv') as command:
406 command.shortDescription = 'Set up a development environment' 395 command.shortDescription = 'Set up a development environment'
407 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' 396 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.'
408 command.supportedTypes = ('gecko-webext', 'chrome') 397 command.supportedTypes = ('gecko-webext', 'chrome')
409 398
410 with addCommand(setupTranslations, 'setuptrans') as command: 399 with addCommand(setupTranslations, 'setuptrans') as command:
411 command.shortDescription = 'Sets up translation languages' 400 command.shortDescription = 'Sets up translation languages'
412 command.description = 'Sets up translation languages for the project on crow din.net.' 401 command.description = 'Sets up translation languages for the project on crow din.net.'
413 command.params = '[options] project-key' 402 command.params = '[options] project-key'
414 command.supportedTypes = ('chrome', 'generic')
415 403
416 with addCommand(updateTranslationMaster, 'translate') as command: 404 with addCommand(updateTranslationMaster, 'translate') as command:
417 command.shortDescription = 'Updates translation master files' 405 command.shortDescription = 'Updates translation master files'
418 command.description = 'Updates the translation master files in the project o n crowdin.net.' 406 command.description = 'Updates the translation master files in the project o n crowdin.net.'
419 command.params = '[options] project-key' 407 command.params = '[options] project-key'
420 command.supportedTypes = ('chrome', 'generic')
421 408
422 with addCommand(uploadTranslations, 'uploadtrans') as command: 409 with addCommand(uploadTranslations, 'uploadtrans') as command:
423 command.shortDescription = 'Uploads existing translations' 410 command.shortDescription = 'Uploads existing translations'
424 command.description = 'Uploads already existing translations to the project on crowdin.net.' 411 command.description = 'Uploads already existing translations to the project on crowdin.net.'
425 command.params = '[options] project-key' 412 command.params = '[options] project-key'
426 command.supportedTypes = ('chrome', 'generic')
427 413
428 with addCommand(getTranslations, 'gettranslations') as command: 414 with addCommand(getTranslations, 'gettranslations') as command:
429 command.shortDescription = 'Downloads translation updates' 415 command.shortDescription = 'Downloads translation updates'
430 command.description = 'Downloads updated translations from crowdin.net.' 416 command.description = 'Downloads updated translations from crowdin.net.'
431 command.params = '[options] project-key' 417 command.params = '[options] project-key'
432 command.supportedTypes = ('chrome', 'generic')
433 418
434 with addCommand(generateDocs, 'docs') as command: 419 with addCommand(generateDocs, 'docs') as command:
435 command.shortDescription = 'Generate documentation (requires node.js)' 420 command.shortDescription = 'Generate documentation (requires node.js)'
436 command.description = ('Generate documentation files and write them into ' 421 command.description = ('Generate documentation files and write them into '
437 'the specified directory.') 422 'the specified directory.')
438 command.addOption('Suppress JsDoc output', short='q', long='quiet') 423 command.addOption('Suppress JsDoc output', short='q', long='quiet')
439 command.params = '[options] <directory>' 424 command.params = '[options] <directory>'
440 command.supportedTypes = ('chrome') 425 command.supportedTypes = ('chrome',)
441 426
442 with addCommand(runReleaseAutomation, 'release') as command: 427 with addCommand(runReleaseAutomation, 'release') as command:
443 command.shortDescription = 'Run release automation' 428 command.shortDescription = 'Run release automation'
444 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.' 429 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.'
445 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'edge' )) 430 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'edge' ))
446 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') 431 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir')
447 command.params = '[options] <version>' 432 command.params = '[options] <version>'
448 command.supportedTypes = ('chrome', 'edge') 433 command.supportedTypes = ('chrome', 'edge')
449 434
450 with addCommand(updatePSL, 'updatepsl') as command: 435 with addCommand(updatePSL, 'updatepsl') as command:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 if option in ('-h', '--help'): 503 if option in ('-h', '--help'):
519 usage(scriptName, type, command) 504 usage(scriptName, type, command)
520 sys.exit() 505 sys.exit()
521 commands[command](baseDir, scriptName, opts, args, type) 506 commands[command](baseDir, scriptName, opts, args, type)
522 else: 507 else:
523 print 'Command %s is not supported for this application type' % comm and 508 print 'Command %s is not supported for this application type' % comm and
524 usage(scriptName, type) 509 usage(scriptName, type)
525 else: 510 else:
526 print 'Command %s is unrecognized' % command 511 print 'Command %s is unrecognized' % command
527 usage(scriptName, type) 512 usage(scriptName, type)
LEFTRIGHT
« no previous file | packagerSafari.py » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld