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