Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | # Copyright (c) 2012 Google Inc. All rights reserved. |
michael@0 | 3 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | # found in the LICENSE file. |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | """Argument-less script to select what to run on the buildbots.""" |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | import os |
michael@0 | 11 | import shutil |
michael@0 | 12 | import subprocess |
michael@0 | 13 | import sys |
michael@0 | 14 | |
michael@0 | 15 | |
michael@0 | 16 | if sys.platform in ['win32', 'cygwin']: |
michael@0 | 17 | EXE_SUFFIX = '.exe' |
michael@0 | 18 | else: |
michael@0 | 19 | EXE_SUFFIX = '' |
michael@0 | 20 | |
michael@0 | 21 | |
michael@0 | 22 | BUILDBOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
michael@0 | 23 | TRUNK_DIR = os.path.dirname(BUILDBOT_DIR) |
michael@0 | 24 | ROOT_DIR = os.path.dirname(TRUNK_DIR) |
michael@0 | 25 | OUT_DIR = os.path.join(TRUNK_DIR, 'out') |
michael@0 | 26 | |
michael@0 | 27 | |
michael@0 | 28 | def GypTestFormat(title, format=None, msvs_version=None): |
michael@0 | 29 | """Run the gyp tests for a given format, emitting annotator tags. |
michael@0 | 30 | |
michael@0 | 31 | See annotator docs at: |
michael@0 | 32 | https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-build-infrastructure/buildbot-annotations |
michael@0 | 33 | Args: |
michael@0 | 34 | format: gyp format to test. |
michael@0 | 35 | Returns: |
michael@0 | 36 | 0 for sucesss, 1 for failure. |
michael@0 | 37 | """ |
michael@0 | 38 | if not format: |
michael@0 | 39 | format = title |
michael@0 | 40 | |
michael@0 | 41 | print '@@@BUILD_STEP ' + title + '@@@' |
michael@0 | 42 | sys.stdout.flush() |
michael@0 | 43 | env = os.environ.copy() |
michael@0 | 44 | # TODO(bradnelson): remove this when this issue is resolved: |
michael@0 | 45 | # http://code.google.com/p/chromium/issues/detail?id=108251 |
michael@0 | 46 | if format == 'ninja': |
michael@0 | 47 | env['NOGOLD'] = '1' |
michael@0 | 48 | if msvs_version: |
michael@0 | 49 | env['GYP_MSVS_VERSION'] = msvs_version |
michael@0 | 50 | retcode = subprocess.call(' '.join( |
michael@0 | 51 | [sys.executable, 'trunk/gyptest.py', |
michael@0 | 52 | '--all', |
michael@0 | 53 | '--passed', |
michael@0 | 54 | '--format', format, |
michael@0 | 55 | '--chdir', 'trunk', |
michael@0 | 56 | '--path', '../scons']), |
michael@0 | 57 | cwd=ROOT_DIR, env=env, shell=True) |
michael@0 | 58 | if retcode: |
michael@0 | 59 | # Emit failure tag, and keep going. |
michael@0 | 60 | print '@@@STEP_FAILURE@@@' |
michael@0 | 61 | return 1 |
michael@0 | 62 | return 0 |
michael@0 | 63 | |
michael@0 | 64 | |
michael@0 | 65 | def GypBuild(): |
michael@0 | 66 | # Dump out/ directory. |
michael@0 | 67 | print '@@@BUILD_STEP cleanup@@@' |
michael@0 | 68 | print 'Removing %s...' % OUT_DIR |
michael@0 | 69 | shutil.rmtree(OUT_DIR, ignore_errors=True) |
michael@0 | 70 | print 'Done.' |
michael@0 | 71 | |
michael@0 | 72 | retcode = 0 |
michael@0 | 73 | if sys.platform.startswith('linux'): |
michael@0 | 74 | retcode += GypTestFormat('ninja') |
michael@0 | 75 | retcode += GypTestFormat('scons') |
michael@0 | 76 | retcode += GypTestFormat('make') |
michael@0 | 77 | elif sys.platform == 'darwin': |
michael@0 | 78 | retcode += GypTestFormat('ninja') |
michael@0 | 79 | retcode += GypTestFormat('xcode') |
michael@0 | 80 | retcode += GypTestFormat('make') |
michael@0 | 81 | elif sys.platform == 'win32': |
michael@0 | 82 | retcode += GypTestFormat('ninja') |
michael@0 | 83 | retcode += GypTestFormat('msvs-2008', format='msvs', msvs_version='2008') |
michael@0 | 84 | if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64': |
michael@0 | 85 | retcode += GypTestFormat('msvs-2010', format='msvs', msvs_version='2010') |
michael@0 | 86 | else: |
michael@0 | 87 | raise Exception('Unknown platform') |
michael@0 | 88 | if retcode: |
michael@0 | 89 | # TODO(bradnelson): once the annotator supports a postscript (section for |
michael@0 | 90 | # after the build proper that could be used for cumulative failures), |
michael@0 | 91 | # use that instead of this. This isolates the final return value so |
michael@0 | 92 | # that it isn't misattributed to the last stage. |
michael@0 | 93 | print '@@@BUILD_STEP failures@@@' |
michael@0 | 94 | sys.exit(retcode) |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | if __name__ == '__main__': |
michael@0 | 98 | GypBuild() |