OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import collections | 7 import collections |
8 import copy | 8 import copy |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 16 matching lines...) Expand all Loading... |
27 def DictDiff(d1, d2): | 27 def DictDiff(d1, d2): |
28 diff = [] | 28 diff = [] |
29 for key in sorted(set(d1.keys() + d2.keys())): | 29 for key in sorted(set(d1.keys() + d2.keys())): |
30 if key in d1 and d1[key] != d2.get(key): | 30 if key in d1 and d1[key] != d2.get(key): |
31 diff.append('- %s=%s' % (key, pipes.quote(d1[key]))) | 31 diff.append('- %s=%s' % (key, pipes.quote(d1[key]))) |
32 if key in d2 and d2[key] != d1.get(key): | 32 if key in d2 and d2[key] != d1.get(key): |
33 diff.append('+ %s=%s' % (key, pipes.quote(d2[key]))) | 33 diff.append('+ %s=%s' % (key, pipes.quote(d2[key]))) |
34 return '\n'.join(diff) | 34 return '\n'.join(diff) |
35 | 35 |
36 | 36 |
37 def GetEnvironment(host_obj): | 37 def GetEnvironment(host_obj, testing): |
38 init_env = dict(os.environ) | 38 init_env = dict(os.environ) |
39 init_env['GYP_GENERATORS'] = 'ninja' | 39 init_env['GYP_GENERATORS'] = 'ninja' |
40 init_env['GOMA_DIR'] = bb_utils.GOMA_DIR | 40 init_env['GOMA_DIR'] = bb_utils.GOMA_DIR |
41 envsetup_cmd = '. build/android/envsetup.sh' | 41 envsetup_cmd = '. build/android/envsetup.sh' |
42 if host_obj.target_arch: | 42 if host_obj.target_arch: |
43 envsetup_cmd += ' --target_arch=%s' % host_obj.target_arch | 43 envsetup_cmd += ' --target_arch=%s' % host_obj.target_arch |
44 print 'Running %s' % envsetup_cmd | 44 if testing: |
| 45 # Skip envsetup to avoid presubmit dependence on android deps. |
| 46 print 'Testing mode - skipping "%s"' % envsetup_cmd |
| 47 envsetup_cmd = ':' |
| 48 else: |
| 49 print 'Running %s' % envsetup_cmd |
45 proc = subprocess.Popen(['bash', '-exc', | 50 proc = subprocess.Popen(['bash', '-exc', |
46 envsetup_cmd + ' >&2; python build/android/buildbot/env_to_json.py'], | 51 envsetup_cmd + ' >&2; python build/android/buildbot/env_to_json.py'], |
47 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 52 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
48 cwd=bb_utils.CHROME_SRC, env=init_env) | 53 cwd=bb_utils.CHROME_SRC, env=init_env) |
49 json_env, envsetup_output = proc.communicate() | 54 json_env, envsetup_output = proc.communicate() |
50 if proc.returncode != 0: | 55 if proc.returncode != 0: |
51 print 'FATAL Failure in envsetup.' | 56 print >> sys.stderr, 'FATAL Failure in envsetup.' |
52 print envsetup_output | 57 print >> sys.stderr, envsetup_output |
53 sys.exit(1) | 58 sys.exit(1) |
54 env = json.loads(json_env) | 59 env = json.loads(json_env) |
55 env['GYP_DEFINES'] = env.get('GYP_DEFINES', '') + ' fastbuild=1' | 60 env['GYP_DEFINES'] = env.get('GYP_DEFINES', '') + ' fastbuild=1' |
56 extra_gyp = host_obj.extra_gyp_defines | 61 extra_gyp = host_obj.extra_gyp_defines |
57 if extra_gyp: | 62 if extra_gyp: |
58 env['GYP_DEFINES'] += ' %s' % extra_gyp | 63 env['GYP_DEFINES'] += ' %s' % extra_gyp |
59 if re.search('(asan|clang)=1', extra_gyp): | 64 if re.search('(asan|clang)=1', extra_gyp): |
60 env.pop('CXX_target', None) | 65 env.pop('CXX_target', None) |
61 | 66 |
62 # Bots checkout chrome in /b/build/slave/<name>/build/src | 67 # Bots checkout chrome in /b/build/slave/<name>/build/src |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 bot_config = bot_map[max_id] | 204 bot_config = bot_map[max_id] |
200 if not bot_config: | 205 if not bot_config: |
201 print 'Error: config for id="%s" cannot be inferred.' % bot_id | 206 print 'Error: config for id="%s" cannot be inferred.' % bot_id |
202 return 1 | 207 return 1 |
203 | 208 |
204 print 'Using config:', bot_config | 209 print 'Using config:', bot_config |
205 | 210 |
206 commands = GetCommands(options, bot_config) | 211 commands = GetCommands(options, bot_config) |
207 for command in commands: | 212 for command in commands: |
208 print 'Will run: ', bb_utils.CommandToString(command) | 213 print 'Will run: ', bb_utils.CommandToString(command) |
| 214 print |
209 | 215 |
210 env = GetEnvironment(bot_config.host_obj) | 216 env = GetEnvironment(bot_config.host_obj, options.testing) |
211 print 'Environment changes:' | 217 print 'Environment changes:' |
212 print DictDiff(dict(os.environ), env) | 218 print DictDiff(dict(os.environ), env) |
213 | 219 |
214 for command in commands: | 220 for command in commands: |
215 print bb_utils.CommandToString(command) | 221 print bb_utils.CommandToString(command) |
216 sys.stdout.flush() | 222 sys.stdout.flush() |
217 if options.testing: | 223 if options.testing: |
218 env['BUILDBOT_TESTING'] = '1' | 224 env['BUILDBOT_TESTING'] = '1' |
219 return_code = subprocess.call(command, cwd=bb_utils.CHROME_SRC, env=env) | 225 return_code = subprocess.call(command, cwd=bb_utils.CHROME_SRC, env=env) |
220 if return_code != 0: | 226 if return_code != 0: |
221 return return_code | 227 return return_code |
222 | 228 |
223 | 229 |
224 if __name__ == '__main__': | 230 if __name__ == '__main__': |
225 sys.exit(main(sys.argv)) | 231 sys.exit(main(sys.argv)) |
OLD | NEW |