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

Side by Side Diff: build.py

Issue 6116696976785408: Issue 1590 - Add devenv support for Safari (Closed)
Patch Set: Created Nov. 21, 2014, 10:32 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | packagerChrome.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 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
10 from zipfile import ZipFile
9 11
10 knownTypes = ('gecko', 'chrome', 'opera', 'safari') 12 knownTypes = ('gecko', 'chrome', 'opera', 'safari')
11 13
12 class Command(object): 14 class Command(object):
13 name = property(lambda self: self._name) 15 name = property(lambda self: self._name)
14 shortDescription = property(lambda self: self._shortDescription, 16 shortDescription = property(lambda self: self._shortDescription,
15 lambda self, value: self.__dict__.update({'_shortDescription': value})) 17 lambda self, value: self.__dict__.update({'_shortDescription': value}))
16 description = property(lambda self: self._description, 18 description = property(lambda self: self._description,
17 lambda self, value: self.__dict__.update({'_description': value})) 19 lambda self, value: self.__dict__.update({'_description': value}))
18 params = property(lambda self: self._params, 20 params = property(lambda self: self._params,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if ':' in args[0]: 211 if ':' in args[0]:
210 host, port = args[0].rsplit(':', 1) 212 host, port = args[0].rsplit(':', 1)
211 else: 213 else:
212 host, port = ('localhost', args[0]) 214 host, port = ('localhost', args[0])
213 215
214 import buildtools.packagerGecko as packager 216 import buildtools.packagerGecko as packager
215 packager.autoInstall(baseDir, type, host, port, multicompartment=multicompartm ent) 217 packager.autoInstall(baseDir, type, host, port, multicompartment=multicompartm ent)
216 218
217 219
218 def createDevEnv(baseDir, scriptName, opts, args, type): 220 def createDevEnv(baseDir, scriptName, opts, args, type):
219 import buildtools.packagerChrome as packager 221 if type == 'safari':
220 packager.createDevEnv(baseDir, type=type) 222 import buildtools.packagerSafari as packager
223 else:
224 import buildtools.packagerChrome as packager
225
226 file = StringIO()
227 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseBui ld=True)
228
229 devenv_dir = os.path.join(baseDir, 'devenv')
230 shutil.rmtree(devenv_dir, ignore_errors=True)
231
232 file.seek(0)
233 with ZipFile(file, 'r') as zip_file:
234 zip_file.extractall(devenv_dir)
221 235
222 236
223 def setupTranslations(baseDir, scriptName, opts, args, type): 237 def setupTranslations(baseDir, scriptName, opts, args, type):
224 if len(args) < 1: 238 if len(args) < 1:
225 print 'Project key is required to update translation master files.' 239 print 'Project key is required to update translation master files.'
226 usage(scriptName, type, 'setuptrans') 240 usage(scriptName, type, 'setuptrans')
227 return 241 return
228 242
229 key = args[0] 243 key = args[0]
230 244
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 with addCommand(runAutoInstall, 'autoinstall') as command: 444 with addCommand(runAutoInstall, 'autoinstall') as command:
431 command.shortDescription = 'Install extension automatically' 445 command.shortDescription = 'Install extension automatically'
432 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.' 446 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.'
433 command.params = '[<host>:]<port>' 447 command.params = '[<host>:]<port>'
434 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment') 448 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment')
435 command.supportedTypes = ('gecko') 449 command.supportedTypes = ('gecko')
436 450
437 with addCommand(createDevEnv, 'devenv') as command: 451 with addCommand(createDevEnv, 'devenv') as command:
438 command.shortDescription = 'Set up a development environment' 452 command.shortDescription = 'Set up a development environment'
439 command.description = 'Will set up or update the devenv folder as an unpacked extension folder for development.' 453 command.description = 'Will set up or update the devenv folder as an unpacked extension folder for development.'
440 command.supportedTypes = ('chrome', 'opera') 454 command.supportedTypes = ('chrome', 'opera', 'safari')
441 455
442 with addCommand(setupTranslations, 'setuptrans') as command: 456 with addCommand(setupTranslations, 'setuptrans') as command:
443 command.shortDescription = 'Sets up translation languages' 457 command.shortDescription = 'Sets up translation languages'
444 command.description = 'Sets up translation languages for the project on crowdi n.net.' 458 command.description = 'Sets up translation languages for the project on crowdi n.net.'
445 command.params = '[options] project-key' 459 command.params = '[options] project-key'
446 command.supportedTypes = ('gecko', 'chrome', 'opera') 460 command.supportedTypes = ('gecko', 'chrome', 'opera')
447 461
448 with addCommand(updateTranslationMaster, 'translate') as command: 462 with addCommand(updateTranslationMaster, 'translate') as command:
449 command.shortDescription = 'Updates translation master files' 463 command.shortDescription = 'Updates translation master files'
450 command.description = 'Updates the translation master files in the project on crowdin.net.' 464 command.description = 'Updates the translation master files in the project on crowdin.net.'
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if option in ('-h', '--help'): 572 if option in ('-h', '--help'):
559 usage(scriptName, type, command) 573 usage(scriptName, type, command)
560 sys.exit() 574 sys.exit()
561 commands[command](baseDir, scriptName, opts, args, type) 575 commands[command](baseDir, scriptName, opts, args, type)
562 else: 576 else:
563 print 'Command %s is not supported for this application type' % command 577 print 'Command %s is not supported for this application type' % command
564 usage(scriptName, type) 578 usage(scriptName, type)
565 else: 579 else:
566 print 'Command %s is unrecognized' % command 580 print 'Command %s is unrecognized' % command
567 usage(scriptName, type) 581 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | packagerChrome.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld