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

Side by Side Diff: native_client_sdk/src/build_tools/buildbot_common.py

Issue 275523003: [NaCl SDK] Make build_projects quiet by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: flushing Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Common utilities for all buildbot scripts that specifically don't rely 5 """Common utilities for all buildbot scripts that specifically don't rely
6 on having a full chromium checkout. 6 on having a full chromium checkout.
7 """ 7 """
8 8
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 12
13 from build_paths import SDK_SRC_DIR, NACL_DIR 13 from build_paths import SDK_SRC_DIR, NACL_DIR
14 14
15 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) 15 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))
16 import oshelpers 16 import oshelpers
17 import getos 17 import getos
18 18
19
20 verbose = True
21
22
19 def IsSDKBuilder(): 23 def IsSDKBuilder():
20 """Returns True if this script is running on an SDK builder. 24 """Returns True if this script is running on an SDK builder.
21 25
22 False means it is either running on a trybot, or a user's machine. 26 False means it is either running on a trybot, or a user's machine.
23 27
24 Trybot names: 28 Trybot names:
25 (win|mac|linux)_nacl_sdk 29 (win|mac|linux)_nacl_sdk
26 30
27 Build-only Trybot names: 31 Build-only Trybot names:
28 (win|mac|linux)_nacl_sdk_build 32 (win|mac|linux)_nacl_sdk_build
(...skipping 12 matching lines...) Expand all
41 See IsSDKBuilder above for trybot/buildbot names.""" 45 See IsSDKBuilder above for trybot/buildbot names."""
42 return '_nacl_sdk' in os.getenv('BUILDBOT_BUILDERNAME', '') 46 return '_nacl_sdk' in os.getenv('BUILDBOT_BUILDERNAME', '')
43 47
44 48
45 def ErrorExit(msg): 49 def ErrorExit(msg):
46 """Write and error to stderr, then exit with 1 signaling failure.""" 50 """Write and error to stderr, then exit with 1 signaling failure."""
47 sys.stderr.write(str(msg) + '\n') 51 sys.stderr.write(str(msg) + '\n')
48 sys.exit(1) 52 sys.exit(1)
49 53
50 54
55 def Trace(msg):
56 if verbose:
57 sys.stderr.write(str(msg) + '\n')
58
59
51 def GetWindowsEnvironment(): 60 def GetWindowsEnvironment():
52 sys.path.append(os.path.join(NACL_DIR, 'buildbot')) 61 sys.path.append(os.path.join(NACL_DIR, 'buildbot'))
53 import buildbot_standard 62 import buildbot_standard
54 63
55 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll 64 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll
56 # fake enough of that here to work. 65 # fake enough of that here to work.
57 class FakeContext(object): 66 class FakeContext(object):
58 def __init__(self): 67 def __init__(self):
59 self.env = os.environ 68 self.env = os.environ
60 69
(...skipping 25 matching lines...) Expand all
86 # It looks like this: 95 # It looks like this:
87 # KEY1=VALUE1\r\n 96 # KEY1=VALUE1\r\n
88 # KEY2=VALUE2\r\n 97 # KEY2=VALUE2\r\n
89 # ... 98 # ...
90 return dict(line.split('=') for line in stdout.split('\r\n')[:-1]) 99 return dict(line.split('=') for line in stdout.split('\r\n')[:-1])
91 100
92 101
93 def BuildStep(name): 102 def BuildStep(name):
94 """Annotate a buildbot build step.""" 103 """Annotate a buildbot build step."""
95 sys.stdout.flush() 104 sys.stdout.flush()
96 print '\n@@@BUILD_STEP %s@@@' % name 105 sys.stderr.write('\n@@@BUILD_STEP %s@@@\n' % name)
97 sys.stdout.flush()
98 106
99 107
100 def Run(args, cwd=None, env=None, shell=False): 108 def Run(args, cwd=None, env=None, shell=False):
101 """Start a process with the provided arguments. 109 """Start a process with the provided arguments.
102 110
103 Starts a process in the provided directory given the provided arguments. If 111 Starts a process in the provided directory given the provided arguments. If
104 shell is not False, the process is launched via the shell to provide shell 112 shell is not False, the process is launched via the shell to provide shell
105 interpretation of the arguments. Shell behavior can differ between platforms 113 interpretation of the arguments. Shell behavior can differ between platforms
106 so this should be avoided when not using platform dependent shell scripts.""" 114 so this should be avoided when not using platform dependent shell scripts."""
107 115
108 # We need to modify the environment to build host on Windows. 116 # We need to modify the environment to build host on Windows.
109 if not env and getos.GetPlatform() == 'win': 117 if not env and getos.GetPlatform() == 'win':
110 env = GetWindowsEnvironment() 118 env = GetWindowsEnvironment()
111 119
112 print 'Running: ' + ' '.join(args) 120 Trace('Running: ' + ' '.join(args))
113 sys.stdout.flush() 121 sys.stdout.flush()
114 sys.stderr.flush() 122 sys.stderr.flush()
115 try: 123 try:
116 subprocess.check_call(args, cwd=cwd, env=env, shell=shell) 124 subprocess.check_call(args, cwd=cwd, env=env, shell=shell)
117 except subprocess.CalledProcessError as e: 125 except subprocess.CalledProcessError as e:
118 sys.stdout.flush() 126 sys.stdout.flush()
119 sys.stderr.flush() 127 sys.stderr.flush()
120 ErrorExit('buildbot_common: %s' % e) 128 ErrorExit('buildbot_common: %s' % e)
121 129
122 sys.stdout.flush() 130 sys.stdout.flush()
123 sys.stderr.flush() 131 sys.stderr.flush()
124 132
125 133
126 def CopyDir(src, dst, excludes=('.svn', '*/.svn')): 134 def CopyDir(src, dst, excludes=('.svn', '*/.svn')):
127 """Recursively copy a directory using.""" 135 """Recursively copy a directory using."""
128 args = ['-r', src, dst] 136 args = ['-r', src, dst]
129 for exc in excludes: 137 for exc in excludes:
130 args.append('--exclude=' + exc) 138 args.append('--exclude=' + exc)
131 print 'cp -r %s %s' % (src, dst) 139 Trace('cp -r %s %s' % (src, dst))
132 if os.path.abspath(src) == os.path.abspath(dst): 140 if os.path.abspath(src) == os.path.abspath(dst):
133 ErrorExit('ERROR: Copying directory onto itself: ' + src) 141 ErrorExit('ERROR: Copying directory onto itself: ' + src)
134 oshelpers.Copy(args) 142 oshelpers.Copy(args)
135 143
136 144
137 def CopyFile(src, dst): 145 def CopyFile(src, dst):
138 print 'cp %s %s' % (src, dst) 146 Trace('cp %s %s' % (src, dst))
139 if os.path.abspath(src) == os.path.abspath(dst): 147 if os.path.abspath(src) == os.path.abspath(dst):
140 ErrorExit('ERROR: Copying file onto itself: ' + src) 148 ErrorExit('ERROR: Copying file onto itself: ' + src)
141 args = [src, dst] 149 args = [src, dst]
142 oshelpers.Copy(args) 150 oshelpers.Copy(args)
143 151
144 152
145 def RemoveDir(dst): 153 def RemoveDir(dst):
146 """Remove the provided path.""" 154 """Remove the provided path."""
147 print 'rm -fr ' + dst 155 Trace('rm -fr ' + dst)
148 oshelpers.Remove(['-fr', dst]) 156 oshelpers.Remove(['-fr', dst])
149 157
150 158
151 def MakeDir(dst): 159 def MakeDir(dst):
152 """Create the path including all parent directories as needed.""" 160 """Create the path including all parent directories as needed."""
153 print 'mkdir -p ' + dst 161 Trace('mkdir -p ' + dst)
154 oshelpers.Mkdir(['-p', dst]) 162 oshelpers.Mkdir(['-p', dst])
155 163
156 164
157 def Move(src, dst): 165 def Move(src, dst):
158 """Move the path src to dst.""" 166 """Move the path src to dst."""
159 print 'mv -f %s %s' % (src, dst) 167 Trace('mv -f %s %s' % (src, dst))
160 oshelpers.Move(['-f', src, dst]) 168 oshelpers.Move(['-f', src, dst])
161 169
162 170
163 def RemoveFile(dst): 171 def RemoveFile(dst):
164 """Remove the provided file.""" 172 """Remove the provided file."""
165 print 'rm ' + dst 173 Trace('rm ' + dst)
166 oshelpers.Remove(['-f', dst]) 174 oshelpers.Remove(['-f', dst])
167 175
168 176
169 BOT_GSUTIL = '/b/build/scripts/slave/gsutil' 177 BOT_GSUTIL = '/b/build/scripts/slave/gsutil'
170 # On Windows, the current working directory may be on a different drive than 178 # On Windows, the current working directory may be on a different drive than
171 # gsutil. 179 # gsutil.
172 WIN_BOT_GSUTIL = 'E:' + BOT_GSUTIL 180 WIN_BOT_GSUTIL = 'E:' + BOT_GSUTIL
173 LOCAL_GSUTIL = 'gsutil' 181 LOCAL_GSUTIL = 'gsutil'
174 182
175 183
(...skipping 14 matching lines...) Expand all
190 # Since GetGsutil() might just return 'gsutil' and expect it to be looked 198 # Since GetGsutil() might just return 'gsutil' and expect it to be looked
191 # up in the PATH, we must pass shell=True on windows. 199 # up in the PATH, we must pass shell=True on windows.
192 # Without shell=True the windows implementation of subprocess.call will not 200 # Without shell=True the windows implementation of subprocess.call will not
193 # search the PATH for the executable: http://bugs.python.org/issue8557 201 # search the PATH for the executable: http://bugs.python.org/issue8557
194 shell = getos.GetPlatform() == 'win' 202 shell = getos.GetPlatform() == 'win'
195 203
196 cmd = [GetGsutil(), 'cp', '-a', 'public-read', filename, full_dst] 204 cmd = [GetGsutil(), 'cp', '-a', 'public-read', filename, full_dst]
197 Run(cmd, shell=shell, cwd=cwd) 205 Run(cmd, shell=shell, cwd=cwd)
198 url = 'https://storage.googleapis.com/%s/%s' % (bucket_path, filename) 206 url = 'https://storage.googleapis.com/%s/%s' % (bucket_path, filename)
199 if step_link: 207 if step_link:
200 print '@@@STEP_LINK@download@%s@@@' % url
201 sys.stdout.flush() 208 sys.stdout.flush()
209 sys.stderr.write('@@@STEP_LINK@download@%s@@@\n' % url)
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/build_projects.py ('k') | native_client_sdk/src/build_tools/generate_index.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698