| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """An auto-roller for GN binaries into Chromium. | 5 """An auto-roller for GN binaries into Chromium. |
| 6 | 6 |
| 7 This script is used to update the GN binaries that a Chromium | 7 This script is used to update the GN binaries that a Chromium |
| 8 checkout uses. In order to update the binaries, one must follow | 8 checkout uses. In order to update the binaries, one must follow |
| 9 four steps in order: | 9 four steps in order: |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 def MakeDummyDepsChange(self): | 172 def MakeDummyDepsChange(self): |
| 173 with open('DEPS') as fp: | 173 with open('DEPS') as fp: |
| 174 deps_content = fp.read() | 174 deps_content = fp.read() |
| 175 new_deps = deps_content.replace("'buildtools_revision':", | 175 new_deps = deps_content.replace("'buildtools_revision':", |
| 176 "'buildtools_revision': ") | 176 "'buildtools_revision': ") |
| 177 | 177 |
| 178 with open('DEPS', 'w') as fp: | 178 with open('DEPS', 'w') as fp: |
| 179 fp.write(new_deps) | 179 fp.write(new_deps) |
| 180 | 180 |
| 181 def WaitForBuildToFinish(self): | 181 def WaitForBuildToFinish(self): |
| 182 ret = self.CheckoutBuildBranch() |
| 183 if ret: |
| 184 return ret |
| 185 |
| 182 print('Checking build') | 186 print('Checking build') |
| 183 results = self.CheckBuild() | 187 results = self.CheckBuild() |
| 184 while (len(results) < 3 or | 188 while (len(results) < 3 or |
| 185 any(r['state'] in ('pending', 'started') | 189 any(r['state'] in ('pending', 'started') |
| 186 for r in results.values())): | 190 for r in results.values())): |
| 187 print() | 191 print() |
| 188 print('Sleeping for 30 seconds') | 192 print('Sleeping for 30 seconds') |
| 189 time.sleep(30) | 193 time.sleep(30) |
| 190 print('Checking build') | 194 print('Checking build') |
| 191 results = self.CheckBuild() | 195 results = self.CheckBuild() |
| 192 | 196 |
| 193 ret = 0 if all(r['state'] == 'success' for r in results.values()) else 1 | 197 ret = 0 if all(r['state'] == 'success' for r in results.values()) else 1 |
| 194 if ret: | 198 if ret: |
| 195 print('Build failed.') | 199 print('Build failed.') |
| 196 else: | 200 else: |
| 197 print('Builds ready.') | 201 print('Builds ready.') |
| 198 | 202 |
| 199 # Close the build CL and move off of the build branch back to whatever | 203 # Close the build CL and move off of the build branch back to whatever |
| 200 # we were on before. | 204 # we were on before. |
| 201 self.Call('git-cl set-close') | 205 self.Call('git-cl set-close') |
| 202 self.MoveToLastHead() | 206 self.MoveToLastHead() |
| 203 | 207 |
| 204 return ret | 208 return ret |
| 205 | 209 |
| 210 def CheckoutBuildBranch(self): |
| 211 ret, out, err = self.Call('git checkout build_gn_%s' % self.new_gn_version) |
| 212 if ret: |
| 213 print('Failed to check out build_gn_%s' % self.new_gn_version) |
| 214 if out: |
| 215 print(out) |
| 216 if err: |
| 217 print(err, file=sys.stderr) |
| 218 return ret |
| 219 |
| 206 def CheckBuild(self): | 220 def CheckBuild(self): |
| 207 _, out, _ = self.Call('git-cl issue') | 221 _, out, _ = self.Call('git-cl issue') |
| 208 | 222 |
| 209 issue = int(out.split()[2]) | 223 issue = int(out.split()[2]) |
| 210 | 224 |
| 211 _, out, _ = self.Call('git config user.email') | 225 _, out, _ = self.Call('git config user.email') |
| 212 email = '' | 226 email = '' |
| 213 rpc_server = upload.GetRpcServer(CODE_REVIEW_SERVER, email) | 227 rpc_server = upload.GetRpcServer(CODE_REVIEW_SERVER, email) |
| 214 try: | 228 try: |
| 215 props = json.loads(rpc_server.Send('/api/%d' % issue)) | 229 props = json.loads(rpc_server.Send('/api/%d' % issue)) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 print(platform) | 283 print(platform) |
| 270 print(' sha1: %s' % r['sha1']) | 284 print(' sha1: %s' % r['sha1']) |
| 271 print(' state: %s' % r['state']) | 285 print(' state: %s' % r['state']) |
| 272 print(' build: %s' % r['build']) | 286 print(' build: %s' % r['build']) |
| 273 print(' url: %s' % r['url']) | 287 print(' url: %s' % r['url']) |
| 274 print() | 288 print() |
| 275 | 289 |
| 276 return results | 290 return results |
| 277 | 291 |
| 278 def RollBuildtools(self): | 292 def RollBuildtools(self): |
| 293 ret = self.CheckoutBuildBranch() |
| 294 if ret: |
| 295 return ret |
| 296 |
| 279 results = self.CheckBuild() | 297 results = self.CheckBuild() |
| 280 if (len(results) < 3 or | 298 if (len(results) < 3 or |
| 281 not all(r['state'] == 'success' for r in results.values())): | 299 not all(r['state'] == 'success' for r in results.values())): |
| 282 print("Roll isn't done or didn't succeed, exiting:") | 300 print("Roll isn't done or didn't succeed, exiting:") |
| 283 return 1 | 301 return 1 |
| 284 | 302 |
| 285 desc = self.GetBuildtoolsDesc() | 303 desc = self.GetBuildtoolsDesc() |
| 286 | 304 |
| 287 self.Call('git new-branch roll_buildtools_gn_%s' % self.new_gn_version, | 305 self.Call('git new-branch roll_buildtools_gn_%s' % self.new_gn_version, |
| 288 cwd=self.buildtools_dir) | 306 cwd=self.buildtools_dir) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 def Call(self, cmd, cwd=None): | 452 def Call(self, cmd, cwd=None): |
| 435 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, | 453 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, |
| 436 cwd=(cwd or self.chromium_src_dir)) | 454 cwd=(cwd or self.chromium_src_dir)) |
| 437 out, err = proc.communicate() | 455 out, err = proc.communicate() |
| 438 return proc.returncode, out, err | 456 return proc.returncode, out, err |
| 439 | 457 |
| 440 | 458 |
| 441 if __name__ == '__main__': | 459 if __name__ == '__main__': |
| 442 roller = GNRoller() | 460 roller = GNRoller() |
| 443 sys.exit(roller.Roll()) | 461 sys.exit(roller.Roll()) |
| OLD | NEW |