| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 Google Inc. All rights reserved. | 2 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Argument-less script to select what to run on the buildbots.""" | 6 """Argument-less script to select what to run on the buildbots.""" |
| 7 | 7 |
| 8 from __future__ import print_function |
| 9 |
| 8 import os | 10 import os |
| 9 import shutil | 11 import shutil |
| 10 import subprocess | 12 import subprocess |
| 11 import sys | 13 import sys |
| 12 | 14 |
| 13 | 15 |
| 14 BUILDBOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 16 BUILDBOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 15 TRUNK_DIR = os.path.dirname(BUILDBOT_DIR) | 17 TRUNK_DIR = os.path.dirname(BUILDBOT_DIR) |
| 16 ROOT_DIR = os.path.dirname(TRUNK_DIR) | 18 ROOT_DIR = os.path.dirname(TRUNK_DIR) |
| 17 CMAKE_DIR = os.path.join(ROOT_DIR, 'cmake') | 19 CMAKE_DIR = os.path.join(ROOT_DIR, 'cmake') |
| 18 CMAKE_BIN_DIR = os.path.join(CMAKE_DIR, 'bin') | 20 CMAKE_BIN_DIR = os.path.join(CMAKE_DIR, 'bin') |
| 19 OUT_DIR = os.path.join(TRUNK_DIR, 'out') | 21 OUT_DIR = os.path.join(TRUNK_DIR, 'out') |
| 20 | 22 |
| 21 | 23 |
| 22 def CallSubProcess(*args, **kwargs): | 24 def CallSubProcess(*args, **kwargs): |
| 23 """Wrapper around subprocess.call which treats errors as build exceptions.""" | 25 """Wrapper around subprocess.call which treats errors as build exceptions.""" |
| 24 with open(os.devnull) as devnull_fd: | 26 with open(os.devnull) as devnull_fd: |
| 25 retcode = subprocess.call(stdin=devnull_fd, *args, **kwargs) | 27 retcode = subprocess.call(stdin=devnull_fd, *args, **kwargs) |
| 26 if retcode != 0: | 28 if retcode != 0: |
| 27 print '@@@STEP_EXCEPTION@@@' | 29 print('@@@STEP_EXCEPTION@@@') |
| 28 sys.exit(1) | 30 sys.exit(1) |
| 29 | 31 |
| 30 | 32 |
| 31 def PrepareCmake(): | 33 def PrepareCmake(): |
| 32 """Build CMake 2.8.8 since the version in Precise is 2.8.7.""" | 34 """Build CMake 2.8.8 since the version in Precise is 2.8.7.""" |
| 33 if os.environ['BUILDBOT_CLOBBER'] == '1': | 35 if os.environ['BUILDBOT_CLOBBER'] == '1': |
| 34 print '@@@BUILD_STEP Clobber CMake checkout@@@' | 36 print('@@@BUILD_STEP Clobber CMake checkout@@@') |
| 35 shutil.rmtree(CMAKE_DIR) | 37 shutil.rmtree(CMAKE_DIR) |
| 36 | 38 |
| 37 # We always build CMake 2.8.8, so no need to do anything | 39 # We always build CMake 2.8.8, so no need to do anything |
| 38 # if the directory already exists. | 40 # if the directory already exists. |
| 39 if os.path.isdir(CMAKE_DIR): | 41 if os.path.isdir(CMAKE_DIR): |
| 40 return | 42 return |
| 41 | 43 |
| 42 print '@@@BUILD_STEP Initialize CMake checkout@@@' | 44 print('@@@BUILD_STEP Initialize CMake checkout@@@') |
| 43 os.mkdir(CMAKE_DIR) | 45 os.mkdir(CMAKE_DIR) |
| 44 | 46 |
| 45 print '@@@BUILD_STEP Sync CMake@@@' | 47 print('@@@BUILD_STEP Sync CMake@@@') |
| 46 CallSubProcess( | 48 CallSubProcess( |
| 47 ['git', 'clone', | 49 ['git', 'clone', |
| 48 '--depth', '1', | 50 '--depth', '1', |
| 49 '--single-branch', | 51 '--single-branch', |
| 50 '--branch', 'v2.8.8', | 52 '--branch', 'v2.8.8', |
| 51 '--', | 53 '--', |
| 52 'git://cmake.org/cmake.git', | 54 'git://cmake.org/cmake.git', |
| 53 CMAKE_DIR], | 55 CMAKE_DIR], |
| 54 cwd=CMAKE_DIR) | 56 cwd=CMAKE_DIR) |
| 55 | 57 |
| 56 print '@@@BUILD_STEP Build CMake@@@' | 58 print('@@@BUILD_STEP Build CMake@@@') |
| 57 CallSubProcess( | 59 CallSubProcess( |
| 58 ['/bin/bash', 'bootstrap', '--prefix=%s' % CMAKE_DIR], | 60 ['/bin/bash', 'bootstrap', '--prefix=%s' % CMAKE_DIR], |
| 59 cwd=CMAKE_DIR) | 61 cwd=CMAKE_DIR) |
| 60 | 62 |
| 61 CallSubProcess( ['make', 'cmake'], cwd=CMAKE_DIR) | 63 CallSubProcess( ['make', 'cmake'], cwd=CMAKE_DIR) |
| 62 | 64 |
| 63 | 65 |
| 64 def GypTestFormat(title, format=None, msvs_version=None, tests=[]): | 66 def GypTestFormat(title, format=None, msvs_version=None, tests=[]): |
| 65 """Run the gyp tests for a given format, emitting annotator tags. | 67 """Run the gyp tests for a given format, emitting annotator tags. |
| 66 | 68 |
| 67 See annotator docs at: | 69 See annotator docs at: |
| 68 https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-buil
d-infrastructure/buildbot-annotations | 70 https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-buil
d-infrastructure/buildbot-annotations |
| 69 Args: | 71 Args: |
| 70 format: gyp format to test. | 72 format: gyp format to test. |
| 71 Returns: | 73 Returns: |
| 72 0 for sucesss, 1 for failure. | 74 0 for sucesss, 1 for failure. |
| 73 """ | 75 """ |
| 74 if not format: | 76 if not format: |
| 75 format = title | 77 format = title |
| 76 | 78 |
| 77 print '@@@BUILD_STEP ' + title + '@@@' | 79 print('@@@BUILD_STEP ' + title + '@@@') |
| 78 sys.stdout.flush() | 80 sys.stdout.flush() |
| 79 env = os.environ.copy() | 81 env = os.environ.copy() |
| 80 if msvs_version: | 82 if msvs_version: |
| 81 env['GYP_MSVS_VERSION'] = msvs_version | 83 env['GYP_MSVS_VERSION'] = msvs_version |
| 82 command = ' '.join( | 84 command = ' '.join( |
| 83 [sys.executable, 'gyp/gyptest.py', | 85 [sys.executable, 'gyp/gyptest.py', |
| 84 '--all', | 86 '--all', |
| 85 '--passed', | 87 '--passed', |
| 86 '--format', format, | 88 '--format', format, |
| 87 '--path', CMAKE_BIN_DIR, | 89 '--path', CMAKE_BIN_DIR, |
| 88 '--chdir', 'gyp'] + tests) | 90 '--chdir', 'gyp'] + tests) |
| 89 retcode = subprocess.call(command, cwd=ROOT_DIR, env=env, shell=True) | 91 retcode = subprocess.call(command, cwd=ROOT_DIR, env=env, shell=True) |
| 90 if retcode: | 92 if retcode: |
| 91 # Emit failure tag, and keep going. | 93 # Emit failure tag, and keep going. |
| 92 print '@@@STEP_FAILURE@@@' | 94 print('@@@STEP_FAILURE@@@') |
| 93 return 1 | 95 return 1 |
| 94 return 0 | 96 return 0 |
| 95 | 97 |
| 96 | 98 |
| 97 def GypBuild(): | 99 def GypBuild(): |
| 98 # Dump out/ directory. | 100 # Dump out/ directory. |
| 99 print '@@@BUILD_STEP cleanup@@@' | 101 print('@@@BUILD_STEP cleanup@@@') |
| 100 print 'Removing %s...' % OUT_DIR | 102 print('Removing %s...' % OUT_DIR) |
| 101 shutil.rmtree(OUT_DIR, ignore_errors=True) | 103 shutil.rmtree(OUT_DIR, ignore_errors=True) |
| 102 print 'Done.' | 104 print('Done.') |
| 103 | 105 |
| 104 retcode = 0 | 106 retcode = 0 |
| 105 if sys.platform.startswith('linux'): | 107 if sys.platform.startswith('linux'): |
| 106 retcode += GypTestFormat('ninja') | 108 retcode += GypTestFormat('ninja') |
| 107 retcode += GypTestFormat('make') | 109 retcode += GypTestFormat('make') |
| 108 PrepareCmake() | 110 PrepareCmake() |
| 109 retcode += GypTestFormat('cmake') | 111 retcode += GypTestFormat('cmake') |
| 110 elif sys.platform == 'darwin': | 112 elif sys.platform == 'darwin': |
| 111 retcode += GypTestFormat('ninja') | 113 retcode += GypTestFormat('ninja') |
| 112 retcode += GypTestFormat('xcode') | 114 retcode += GypTestFormat('xcode') |
| 113 retcode += GypTestFormat('make') | 115 retcode += GypTestFormat('make') |
| 114 elif sys.platform == 'win32': | 116 elif sys.platform == 'win32': |
| 115 retcode += GypTestFormat('ninja') | 117 retcode += GypTestFormat('ninja') |
| 116 if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64': | 118 if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64': |
| 117 retcode += GypTestFormat('msvs-ninja-2013', format='msvs-ninja', | 119 retcode += GypTestFormat('msvs-ninja-2013', format='msvs-ninja', |
| 118 msvs_version='2013', | 120 msvs_version='2013', |
| 119 tests=[ | 121 tests=[ |
| 120 r'test\generator-output\gyptest-actions.py', | 122 r'test\generator-output\gyptest-actions.py', |
| 121 r'test\generator-output\gyptest-relocate.py', | 123 r'test\generator-output\gyptest-relocate.py', |
| 122 r'test\generator-output\gyptest-rules.py']) | 124 r'test\generator-output\gyptest-rules.py']) |
| 123 retcode += GypTestFormat('msvs-2013', format='msvs', msvs_version='2013') | 125 retcode += GypTestFormat('msvs-2013', format='msvs', msvs_version='2013') |
| 124 else: | 126 else: |
| 125 raise Exception('Unknown platform') | 127 raise Exception('Unknown platform') |
| 126 if retcode: | 128 if retcode: |
| 127 # TODO(bradnelson): once the annotator supports a postscript (section for | 129 # TODO(bradnelson): once the annotator supports a postscript (section for |
| 128 # after the build proper that could be used for cumulative failures), | 130 # after the build proper that could be used for cumulative failures), |
| 129 # use that instead of this. This isolates the final return value so | 131 # use that instead of this. This isolates the final return value so |
| 130 # that it isn't misattributed to the last stage. | 132 # that it isn't misattributed to the last stage. |
| 131 print '@@@BUILD_STEP failures@@@' | 133 print('@@@BUILD_STEP failures@@@') |
| 132 sys.exit(retcode) | 134 sys.exit(retcode) |
| 133 | 135 |
| 134 | 136 |
| 135 if __name__ == '__main__': | 137 if __name__ == '__main__': |
| 136 GypBuild() | 138 GypBuild() |
| OLD | NEW |