michael@0: #!/usr/bin/env python michael@0: # Copyright (c) 2012 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: michael@0: """Argument-less script to select what to run on the buildbots.""" michael@0: michael@0: michael@0: import os michael@0: import shutil michael@0: import subprocess michael@0: import sys michael@0: michael@0: michael@0: if sys.platform in ['win32', 'cygwin']: michael@0: EXE_SUFFIX = '.exe' michael@0: else: michael@0: EXE_SUFFIX = '' michael@0: michael@0: michael@0: BUILDBOT_DIR = os.path.dirname(os.path.abspath(__file__)) michael@0: TRUNK_DIR = os.path.dirname(BUILDBOT_DIR) michael@0: ROOT_DIR = os.path.dirname(TRUNK_DIR) michael@0: OUT_DIR = os.path.join(TRUNK_DIR, 'out') michael@0: michael@0: michael@0: def GypTestFormat(title, format=None, msvs_version=None): michael@0: """Run the gyp tests for a given format, emitting annotator tags. michael@0: michael@0: See annotator docs at: michael@0: https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-build-infrastructure/buildbot-annotations michael@0: Args: michael@0: format: gyp format to test. michael@0: Returns: michael@0: 0 for sucesss, 1 for failure. michael@0: """ michael@0: if not format: michael@0: format = title michael@0: michael@0: print '@@@BUILD_STEP ' + title + '@@@' michael@0: sys.stdout.flush() michael@0: env = os.environ.copy() michael@0: # TODO(bradnelson): remove this when this issue is resolved: michael@0: # http://code.google.com/p/chromium/issues/detail?id=108251 michael@0: if format == 'ninja': michael@0: env['NOGOLD'] = '1' michael@0: if msvs_version: michael@0: env['GYP_MSVS_VERSION'] = msvs_version michael@0: retcode = subprocess.call(' '.join( michael@0: [sys.executable, 'trunk/gyptest.py', michael@0: '--all', michael@0: '--passed', michael@0: '--format', format, michael@0: '--chdir', 'trunk', michael@0: '--path', '../scons']), michael@0: cwd=ROOT_DIR, env=env, shell=True) michael@0: if retcode: michael@0: # Emit failure tag, and keep going. michael@0: print '@@@STEP_FAILURE@@@' michael@0: return 1 michael@0: return 0 michael@0: michael@0: michael@0: def GypBuild(): michael@0: # Dump out/ directory. michael@0: print '@@@BUILD_STEP cleanup@@@' michael@0: print 'Removing %s...' % OUT_DIR michael@0: shutil.rmtree(OUT_DIR, ignore_errors=True) michael@0: print 'Done.' michael@0: michael@0: retcode = 0 michael@0: if sys.platform.startswith('linux'): michael@0: retcode += GypTestFormat('ninja') michael@0: retcode += GypTestFormat('scons') michael@0: retcode += GypTestFormat('make') michael@0: elif sys.platform == 'darwin': michael@0: retcode += GypTestFormat('ninja') michael@0: retcode += GypTestFormat('xcode') michael@0: retcode += GypTestFormat('make') michael@0: elif sys.platform == 'win32': michael@0: retcode += GypTestFormat('ninja') michael@0: retcode += GypTestFormat('msvs-2008', format='msvs', msvs_version='2008') michael@0: if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64': michael@0: retcode += GypTestFormat('msvs-2010', format='msvs', msvs_version='2010') michael@0: else: michael@0: raise Exception('Unknown platform') michael@0: if retcode: michael@0: # TODO(bradnelson): once the annotator supports a postscript (section for michael@0: # after the build proper that could be used for cumulative failures), michael@0: # use that instead of this. This isolates the final return value so michael@0: # that it isn't misattributed to the last stage. michael@0: print '@@@BUILD_STEP failures@@@' michael@0: sys.exit(retcode) michael@0: michael@0: michael@0: if __name__ == '__main__': michael@0: GypBuild()