| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 # for details. All rights reserved. Use of this source code is governed by a | |
| 3 # BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #!/usr/bin/env python | |
| 6 # | |
| 7 | |
| 8 # This script builds a Chrome App file (.crx) for Swarm | |
| 9 import os | |
| 10 import platform | |
| 11 import subprocess | |
| 12 import sys | |
| 13 | |
| 14 DART_PATH = os.path.normpath(os.path.dirname(__file__) + '/../../..') | |
| 15 CLIENT_PATH = os.path.normpath(DART_PATH + '/client') | |
| 16 | |
| 17 # Add the tools directory so we can find utils.py. | |
| 18 sys.path.append(os.path.abspath(DART_PATH + '/tools')) | |
| 19 import utils | |
| 20 | |
| 21 buildRoot = CLIENT_PATH + '/' + utils.GetBuildRoot( | |
| 22 utils.GuessOS(), 'debug', 'dartc') | |
| 23 | |
| 24 def execute(*command): | |
| 25 ''' | |
| 26 Executes the given command in a new process. If the command fails (returns | |
| 27 non-zero) halts the script and returns that exit code. | |
| 28 ''' | |
| 29 exitcode = subprocess.call(command) | |
| 30 if exitcode != 0: | |
| 31 sys.exit(exitcode) | |
| 32 | |
| 33 def createChromeApp(buildRoot, antTarget, resultFile): | |
| 34 buildDir = os.path.join(buildRoot, 'war') | |
| 35 | |
| 36 # Use ant to create the 'war' directory | |
| 37 # TODO(jmesserly): we should factor out as much as possible from the ant file | |
| 38 # It's not really doing anything useful for us besides compiling Dart code | |
| 39 # with DartC and copying files. But for now, it helps us share code with | |
| 40 # our appengine update.py, which is good. | |
| 41 execute( | |
| 42 DART_PATH + '/third_party/apache_ant/v1_7_1/bin/ant', | |
| 43 '-f', 'build-appengine.xml', | |
| 44 '-Dbuild.dir=' + buildRoot, | |
| 45 antTarget) | |
| 46 | |
| 47 # Call Dartium (could be any Chrome--but we know Dartium will be there) and | |
| 48 # ask it to create the .crx file for us using the checked in developer key. | |
| 49 chrome = CLIENT_PATH + '/tests/drt/chrome' | |
| 50 | |
| 51 # On Mac Chrome is under a .app folder | |
| 52 if platform.system() == 'Darwin': | |
| 53 chrome = CLIENT_PATH + '/tests/drt/Chromium.app/Contents/MacOS/Chromium' | |
| 54 | |
| 55 keyFile = CLIENT_PATH + '/samples/swarm/swarm-dev.pem' | |
| 56 execute(chrome, '--pack-extension=' + buildDir, | |
| 57 '--pack-extension-key=' + keyFile) | |
| 58 | |
| 59 resultFile = os.path.join(buildRoot, resultFile) | |
| 60 os.rename(buildDir + '.crx', resultFile) | |
| 61 return os.path.abspath(resultFile) | |
| 62 | |
| 63 | |
| 64 def main(): | |
| 65 # Create a DartC and Dartium app | |
| 66 dartiumResult = createChromeApp(buildRoot, 'build_dart_app', 'swarm.crx') | |
| 67 dartCResult = createChromeApp(buildRoot, 'build_js_app', 'swarm-js.crx') | |
| 68 | |
| 69 print ''' | |
| 70 Successfully created Chrome apps! | |
| 71 Dartium: file://%s | |
| 72 | |
| 73 DartC/JS: file://%s | |
| 74 | |
| 75 To install, open this URL in Chrome and select Continue at the bottom. | |
| 76 ''' % (dartiumResult, dartCResult) | |
| 77 return 0 | |
| 78 | |
| 79 if __name__ == '__main__': | |
| 80 sys.exit(main()) | |
| OLD | NEW |