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
4 # found in the LICENSE file.
6 """Argument-less script to select what to run on the buildbots."""
14 BUILDBOT_DIR = os.path.dirname(os.path.abspath(__file__))
15 TRUNK_DIR = os.path.dirname(BUILDBOT_DIR)
16 ROOT_DIR = os.path.dirname(TRUNK_DIR)
17 CMAKE_DIR = os.path.join(ROOT_DIR, 'cmake')
18 CMAKE_BIN_DIR = os.path.join(CMAKE_DIR, 'bin')
19 OUT_DIR = os.path.join(TRUNK_DIR, 'out')
22 def CallSubProcess(*args, **kwargs):
23 """Wrapper around subprocess.call which treats errors as build exceptions."""
24 with open(os.devnull) as devnull_fd:
25 retcode = subprocess.call(stdin=devnull_fd, *args, **kwargs)
27 print '@@@STEP_EXCEPTION@@@'
32 """Build CMake 2.8.8 since the version in Precise is 2.8.7."""
33 if os.environ['BUILDBOT_CLOBBER'] == '1':
34 print '@@@BUILD_STEP Clobber CMake checkout@@@'
35 shutil.rmtree(CMAKE_DIR)
37 # We always build CMake 2.8.8, so no need to do anything
38 # if the directory already exists.
39 if os.path.isdir(CMAKE_DIR):
42 print '@@@BUILD_STEP Initialize CMake checkout@@@'
45 print '@@@BUILD_STEP Sync CMake@@@'
52 'git://cmake.org/cmake.git',
56 print '@@@BUILD_STEP Build CMake@@@'
58 ['/bin/bash', 'bootstrap', '--prefix=%s' % CMAKE_DIR],
61 CallSubProcess( ['make', 'cmake'], cwd=CMAKE_DIR)
64 def GypTestFormat(title, format=None, msvs_version=None, tests=[]):
65 """Run the gyp tests for a given format, emitting annotator tags.
67 See annotator docs at:
68 https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-build-infrastructure/buildbot-annotations
70 format: gyp format to test.
72 0 for sucesss, 1 for failure.
77 print '@@@BUILD_STEP ' + title + '@@@'
79 env = os.environ.copy()
81 env['GYP_MSVS_VERSION'] = msvs_version
83 [sys.executable, 'gyp/gyptest.py',
87 '--path', CMAKE_BIN_DIR,
88 '--chdir', 'gyp'] + tests)
89 retcode = subprocess.call(command, cwd=ROOT_DIR, env=env, shell=True)
91 # Emit failure tag, and keep going.
92 print '@@@STEP_FAILURE@@@'
98 # Dump out/ directory.
99 print '@@@BUILD_STEP cleanup@@@'
100 print 'Removing %s...' % OUT_DIR
101 shutil.rmtree(OUT_DIR, ignore_errors=True)
105 if sys.platform.startswith('linux'):
106 retcode += GypTestFormat('ninja')
107 retcode += GypTestFormat('make')
109 retcode += GypTestFormat('cmake')
110 elif sys.platform == 'darwin':
111 retcode += GypTestFormat('ninja')
112 retcode += GypTestFormat('xcode')
113 retcode += GypTestFormat('make')
114 elif sys.platform == 'win32':
115 retcode += GypTestFormat('ninja')
116 if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64':
117 retcode += GypTestFormat('msvs-ninja-2013', format='msvs-ninja',
120 r'test\generator-output\gyptest-actions.py',
121 r'test\generator-output\gyptest-relocate.py',
122 r'test\generator-output\gyptest-rules.py'])
123 retcode += GypTestFormat('msvs-2013', format='msvs', msvs_version='2013')
125 raise Exception('Unknown platform')
127 # TODO(bradnelson): once the annotator supports a postscript (section for
128 # after the build proper that could be used for cumulative failures),
129 # use that instead of this. This isolates the final return value so
130 # that it isn't misattributed to the last stage.
131 print '@@@BUILD_STEP failures@@@'
135 if __name__ == '__main__':