Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: build/android/buildbot/bb_utils.py

Issue 2180023002: Remove src/build/android/buildbot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/buildbot/bb_run_bot.py ('k') | build/android/buildbot/env_to_json.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6 import optparse
7 import os
8 import subprocess
9 import sys
10
11 import bb_annotations
12
13 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
14 import devil_chromium # pylint: disable=unused-import
15 from devil.utils import cmd_helper
16 from pylib import constants
17
18
19 TESTING = 'BUILDBOT_TESTING' in os.environ
20
21 BB_BUILD_DIR = os.path.abspath(
22 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
23 os.pardir, os.pardir, os.pardir, os.pardir))
24
25 CHROME_SRC = os.path.abspath(
26 os.path.join(os.path.dirname(__file__), '..', '..', '..'))
27
28 # TODO: Figure out how to merge this with devil.utils.cmd_helper.OutDirectory().
29 CHROME_OUT_DIR = os.path.join(CHROME_SRC, 'out')
30
31 GOMA_DIR = os.environ.get('GOMA_DIR', os.path.join(BB_BUILD_DIR, 'goma'))
32
33 GSUTIL_PATH = os.path.join(BB_BUILD_DIR, 'third_party', 'gsutil', 'gsutil')
34
35 def CommandToString(command):
36 """Returns quoted command that can be run in bash shell."""
37 return ' '.join(cmd_helper.SingleQuote(c) for c in command)
38
39
40 def SpawnCmd(command, stdout=None, cwd=CHROME_SRC):
41 """Spawn a process without waiting for termination."""
42 print '>', CommandToString(command)
43 sys.stdout.flush()
44 if TESTING:
45 class MockPopen(object):
46 @staticmethod
47 def wait():
48 return 0
49 @staticmethod
50 def communicate():
51 return '', ''
52 return MockPopen()
53 return subprocess.Popen(command, cwd=cwd, stdout=stdout)
54
55
56 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False,
57 warning_code=constants.WARNING_EXIT_CODE, stdout=None,
58 cwd=CHROME_SRC):
59 """Run a command relative to the chrome source root."""
60 code = SpawnCmd(command, stdout, cwd).wait()
61 print '<', CommandToString(command)
62 if code != 0:
63 print 'ERROR: process exited with code %d' % code
64 if code != warning_code and flunk_on_failure:
65 bb_annotations.PrintError()
66 else:
67 bb_annotations.PrintWarning()
68 # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
69 if code != warning_code and halt_on_failure:
70 print 'FATAL %d != %d' % (code, warning_code)
71 sys.exit(1)
72 return code
73
74
75 def GetParser():
76 def ConvertJson(option, _, value, parser):
77 setattr(parser.values, option.dest, json.loads(value))
78 parser = optparse.OptionParser()
79 parser.add_option('--build-properties', action='callback',
80 callback=ConvertJson, type='string', default={},
81 help='build properties in JSON format')
82 parser.add_option('--factory-properties', action='callback',
83 callback=ConvertJson, type='string', default={},
84 help='factory properties in JSON format')
85 return parser
86
87
88 def EncodeProperties(options):
89 return ['--factory-properties=%s' % json.dumps(options.factory_properties),
90 '--build-properties=%s' % json.dumps(options.build_properties)]
91
92
93 def RunSteps(steps, step_cmds, options):
94 unknown_steps = set(steps) - set(step for step, _ in step_cmds)
95 if unknown_steps:
96 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps)
97 sys.exit(1)
98
99 exit_code = 0
100 for step, cmd in step_cmds:
101 if step in steps:
102 exit_code = cmd(options) or exit_code
103
104 return exit_code
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_run_bot.py ('k') | build/android/buildbot/env_to_json.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698