OLD | NEW |
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 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll | 64 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll |
65 # fake enough of that here to work. | 65 # fake enough of that here to work. |
66 class FakeContext(object): | 66 class FakeContext(object): |
67 def __init__(self): | 67 def __init__(self): |
68 self.env = os.environ | 68 self.env = os.environ |
69 | 69 |
70 def GetEnv(self, key): | 70 def GetEnv(self, key): |
71 return self.env[key] | 71 return self.env[key] |
72 | 72 |
73 def __getitem__(self, key): | 73 def __getitem__(self, key): |
| 74 # The nacl side script now needs gyp_vars to return a list. |
| 75 if key == 'gyp_vars': |
| 76 return [] |
74 return self.env[key] | 77 return self.env[key] |
75 | 78 |
76 def SetEnv(self, key, value): | 79 def SetEnv(self, key, value): |
77 self.env[key] = value | 80 self.env[key] = value |
78 | 81 |
79 def __setitem__(self, key, value): | 82 def __setitem__(self, key, value): |
80 self.env[key] = value | 83 self.env[key] = value |
81 | 84 |
82 context = FakeContext() | 85 context = FakeContext() |
83 context['gyp_vars'] = [] | |
84 buildbot_standard.SetupWindowsEnvironment(context) | 86 buildbot_standard.SetupWindowsEnvironment(context) |
85 | 87 |
86 # buildbot_standard.SetupWindowsEnvironment adds the directory which contains | 88 # buildbot_standard.SetupWindowsEnvironment adds the directory which contains |
87 # vcvarsall.bat to the path, but not the directory which contains cl.exe, | 89 # vcvarsall.bat to the path, but not the directory which contains cl.exe, |
88 # link.exe, etc. | 90 # link.exe, etc. |
89 # Running vcvarsall.bat adds the correct directories to the path, which we | 91 # Running vcvarsall.bat adds the correct directories to the path, which we |
90 # extract below. | 92 # extract below. |
91 process = subprocess.Popen('vcvarsall.bat x86 > NUL && set', | 93 process = subprocess.Popen('vcvarsall.bat x86 > NUL && set', |
92 stdout=subprocess.PIPE, env=context.env, shell=True) | 94 stdout=subprocess.PIPE, env=context.env, shell=True) |
93 stdout, _ = process.communicate() | 95 stdout, _ = process.communicate() |
94 | 96 |
95 # Parse environment from "set" command above. | 97 # Parse environment from "set" command above. |
96 # It looks like this: | 98 # It looks like this: |
97 # KEY1=VALUE1\r\n | 99 # KEY1=VALUE1\r\n |
98 # KEY2=VALUE2\r\n | 100 # KEY2=VALUE2\r\n |
99 # ... | 101 # ... |
100 return dict(line.split('=') for line in stdout.split('\r\n')[:-1]) | 102 return dict(line.split('=', 1) for line in stdout.split('\r\n')[:-1]) |
101 | 103 |
102 | 104 |
103 def BuildStep(name): | 105 def BuildStep(name): |
104 """Annotate a buildbot build step.""" | 106 """Annotate a buildbot build step.""" |
105 sys.stdout.flush() | 107 sys.stdout.flush() |
106 sys.stderr.write('\n@@@BUILD_STEP %s@@@\n' % name) | 108 sys.stderr.write('\n@@@BUILD_STEP %s@@@\n' % name) |
107 | 109 |
108 | 110 |
109 def Run(args, cwd=None, env=None, shell=False): | 111 def Run(args, cwd=None, env=None, shell=False): |
110 """Start a process with the provided arguments. | 112 """Start a process with the provided arguments. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 # Without shell=True the windows implementation of subprocess.call will not | 203 # Without shell=True the windows implementation of subprocess.call will not |
202 # search the PATH for the executable: http://bugs.python.org/issue8557 | 204 # search the PATH for the executable: http://bugs.python.org/issue8557 |
203 shell = getos.GetPlatform() == 'win' | 205 shell = getos.GetPlatform() == 'win' |
204 | 206 |
205 cmd = [GetGsutil(), 'cp', '-a', 'public-read', filename, full_dst] | 207 cmd = [GetGsutil(), 'cp', '-a', 'public-read', filename, full_dst] |
206 Run(cmd, shell=shell, cwd=cwd) | 208 Run(cmd, shell=shell, cwd=cwd) |
207 url = 'https://storage.googleapis.com/%s/%s' % (bucket_path, filename) | 209 url = 'https://storage.googleapis.com/%s/%s' % (bucket_path, filename) |
208 if step_link: | 210 if step_link: |
209 sys.stdout.flush() | 211 sys.stdout.flush() |
210 sys.stderr.write('@@@STEP_LINK@download@%s@@@\n' % url) | 212 sys.stderr.write('@@@STEP_LINK@download@%s@@@\n' % url) |
OLD | NEW |