OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
3 # for details. All rights reserved. Use of this source code is governed by a | |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | |
6 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
7 # Use of this source code is governed by a BSD-style license that can be | |
8 # found in the LICENSE file. | |
9 | |
10 """Dart client buildbot steps | |
11 | |
12 Calls a script in tools/bots whose name is based on the name of the bot. | |
13 | |
14 """ | |
15 | |
16 import imp | |
17 import os | |
18 import re | |
19 import socket | |
20 import subprocess | |
21 import sys | |
22 | |
23 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' | |
24 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' | |
25 | |
26 def GetName(): | |
27 """Returns the name of the bot. | |
28 """ | |
29 name = None | |
30 # Populate via builder environment variables. | |
31 name = os.environ.get(BUILDER_NAME) | |
32 | |
33 # Fall back if not on builder. | |
34 if not name: | |
35 name = socket.gethostname().split('.')[0] | |
36 return name | |
37 | |
38 def ProcessBot(name, target, custom_env=None): | |
39 ''' | |
40 Build and test the named bot target (compiler, android, pub). We look for | |
41 the supporting script in tools/bots/ to run the tests and build. | |
42 ''' | |
43 print 'Process%s' % target.capitalize() | |
44 has_shell = False | |
45 environment = custom_env or os.environ | |
46 if '-win' in name: | |
47 # In Windows we need to run in the shell, so that we have all the | |
48 # environment variables available. | |
49 has_shell = True | |
50 return subprocess.call([sys.executable, | |
51 os.path.join('tools', 'bots', target + '.py')], | |
52 env=environment, shell=has_shell) | |
53 | |
54 def ClobberBuilder(): | |
55 """ Clobber the builder before we do the build. | |
56 """ | |
57 cmd = [sys.executable, | |
58 './tools/clean_output_directory.py'] | |
59 print 'Clobbering %s' % (' '.join(cmd)) | |
60 return subprocess.call(cmd) | |
61 | |
62 def GetShouldClobber(): | |
63 return os.environ.get(BUILDER_CLOBBER) == "1" | |
64 | |
65 def main(): | |
66 if len(sys.argv) == 0: | |
67 print 'Script pathname not known, giving up.' | |
68 return 1 | |
69 | |
70 scriptdir = os.path.dirname(sys.argv[0]) | |
71 # Get at the top-level directory. This script is in client/tools | |
72 os.chdir(os.path.abspath(os.path.join(scriptdir, os.pardir, os.pardir))) | |
73 | |
74 if GetShouldClobber(): | |
75 print '@@@BUILD_STEP Clobber@@@' | |
76 status = ClobberBuilder() | |
77 if status != 0: | |
78 print '@@@STEP_FAILURE@@@' | |
79 return status | |
80 | |
81 name = GetName() | |
82 if name.startswith('pkg-'): | |
83 status = ProcessBot(name, 'pkg') | |
84 elif name.startswith('pub-'): | |
85 status = ProcessBot(name, 'pub') | |
86 elif name.startswith('vm-android'): | |
87 status = ProcessBot(name, 'android') | |
88 elif name.startswith('dart-sdk'): | |
89 status = ProcessBot(name, 'dart_sdk') | |
90 elif name.startswith('cross') or name.startswith('target'): | |
91 status = ProcessBot(name, 'cross-vm') | |
92 elif name.startswith('linux-distribution-support'): | |
93 status = ProcessBot(name, 'linux_distribution_support') | |
94 elif name.startswith('version-checker'): | |
95 status = ProcessBot(name, 'version_checker') | |
96 elif name.startswith('dart2js-dump-info'): | |
97 status = ProcessBot(name, 'dart2js_dump_info') | |
98 else: | |
99 status = ProcessBot(name, 'compiler') | |
100 | |
101 if status: | |
102 print '@@@STEP_FAILURE@@@' | |
103 | |
104 return status | |
105 | |
106 | |
107 if __name__ == '__main__': | |
108 sys.exit(main()) | |
OLD | NEW |