media/webrtc/trunk/tools/gyp/buildbot/buildbot_run.py

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rwxr-xr-x

Integrate suggestion from review to improve consistency with existing code.

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

mercurial