2013-03-21 15:25:38 +00:00
|
|
|
#!/usr/bin/python
|
2011-10-05 04:52:33 +00:00
|
|
|
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""Dart client buildbot steps
|
|
|
|
|
2015-05-12 11:07:48 +00:00
|
|
|
Calls a script in tools/bots whose name is based on the name of the bot.
|
|
|
|
|
2011-10-05 04:52:33 +00:00
|
|
|
"""
|
|
|
|
|
2013-08-06 10:52:57 +00:00
|
|
|
import imp
|
2011-10-05 04:52:33 +00:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import socket
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
BUILDER_NAME = 'BUILDBOT_BUILDERNAME'
|
2012-08-16 05:58:24 +00:00
|
|
|
BUILDER_CLOBBER = 'BUILDBOT_CLOBBER'
|
2013-08-06 10:52:57 +00:00
|
|
|
|
2015-05-12 11:07:48 +00:00
|
|
|
def GetName():
|
|
|
|
"""Returns the name of the bot.
|
2011-10-05 04:52:33 +00:00
|
|
|
"""
|
|
|
|
name = None
|
|
|
|
# Populate via builder environment variables.
|
|
|
|
name = os.environ.get(BUILDER_NAME)
|
|
|
|
|
|
|
|
# Fall back if not on builder.
|
|
|
|
if not name:
|
|
|
|
name = socket.gethostname().split('.')[0]
|
2015-05-12 11:07:48 +00:00
|
|
|
return name
|
2013-06-14 08:26:59 +00:00
|
|
|
|
|
|
|
def ProcessBot(name, target, custom_env=None):
|
2011-10-25 01:41:19 +00:00
|
|
|
'''
|
2012-10-25 22:14:43 +00:00
|
|
|
Build and test the named bot target (compiler, android, pub). We look for
|
|
|
|
the supporting script in tools/bots/ to run the tests and build.
|
2011-10-25 01:41:19 +00:00
|
|
|
'''
|
2012-10-25 22:14:43 +00:00
|
|
|
print 'Process%s' % target.capitalize()
|
2013-06-14 08:26:59 +00:00
|
|
|
has_shell = False
|
|
|
|
environment = custom_env or os.environ
|
2012-10-24 17:53:06 +00:00
|
|
|
if '-win' in name:
|
|
|
|
# In Windows we need to run in the shell, so that we have all the
|
|
|
|
# environment variables available.
|
2013-06-14 08:26:59 +00:00
|
|
|
has_shell = True
|
2012-10-24 17:53:06 +00:00
|
|
|
return subprocess.call([sys.executable,
|
2012-10-25 22:14:43 +00:00
|
|
|
os.path.join('tools', 'bots', target + '.py')],
|
2013-06-14 08:26:59 +00:00
|
|
|
env=environment, shell=has_shell)
|
2011-10-25 01:41:19 +00:00
|
|
|
|
2012-08-16 05:55:09 +00:00
|
|
|
def ClobberBuilder():
|
|
|
|
""" Clobber the builder before we do the build.
|
|
|
|
"""
|
|
|
|
cmd = [sys.executable,
|
|
|
|
'./tools/clean_output_directory.py']
|
|
|
|
print 'Clobbering %s' % (' '.join(cmd))
|
2012-08-16 06:06:50 +00:00
|
|
|
return subprocess.call(cmd)
|
2012-08-16 05:55:09 +00:00
|
|
|
|
|
|
|
def GetShouldClobber():
|
|
|
|
return os.environ.get(BUILDER_CLOBBER) == "1"
|
2012-06-20 15:30:40 +00:00
|
|
|
|
2011-10-05 04:52:33 +00:00
|
|
|
def main():
|
|
|
|
if len(sys.argv) == 0:
|
|
|
|
print 'Script pathname not known, giving up.'
|
|
|
|
return 1
|
|
|
|
|
|
|
|
scriptdir = os.path.dirname(sys.argv[0])
|
2011-11-02 14:21:23 +00:00
|
|
|
# Get at the top-level directory. This script is in client/tools
|
|
|
|
os.chdir(os.path.abspath(os.path.join(scriptdir, os.pardir, os.pardir)))
|
2011-10-05 04:52:33 +00:00
|
|
|
|
2012-08-16 05:55:09 +00:00
|
|
|
if GetShouldClobber():
|
|
|
|
print '@@@BUILD_STEP Clobber@@@'
|
|
|
|
status = ClobberBuilder()
|
|
|
|
if status != 0:
|
|
|
|
print '@@@STEP_FAILURE@@@'
|
|
|
|
return status
|
|
|
|
|
2015-05-12 11:07:48 +00:00
|
|
|
name = GetName()
|
2015-05-08 06:44:51 +00:00
|
|
|
if name.startswith('pub-'):
|
2012-10-25 22:14:43 +00:00
|
|
|
status = ProcessBot(name, 'pub')
|
|
|
|
elif name.startswith('vm-android'):
|
|
|
|
status = ProcessBot(name, 'android')
|
2015-05-11 13:41:00 +00:00
|
|
|
elif name.startswith('dart-sdk'):
|
|
|
|
status = ProcessBot(name, 'dart_sdk')
|
2013-05-17 09:35:32 +00:00
|
|
|
elif name.startswith('cross') or name.startswith('target'):
|
2015-05-12 11:07:48 +00:00
|
|
|
status = ProcessBot(name, 'cross-vm')
|
2014-03-20 10:43:08 +00:00
|
|
|
elif name.startswith('linux-distribution-support'):
|
|
|
|
status = ProcessBot(name, 'linux_distribution_support')
|
2014-05-05 11:07:16 +00:00
|
|
|
elif name.startswith('version-checker'):
|
|
|
|
status = ProcessBot(name, 'version_checker')
|
2014-08-26 11:05:58 +00:00
|
|
|
elif name.startswith('dart2js-dump-info'):
|
|
|
|
status = ProcessBot(name, 'dart2js_dump_info')
|
2011-10-05 04:52:33 +00:00
|
|
|
else:
|
2012-10-25 22:14:43 +00:00
|
|
|
status = ProcessBot(name, 'compiler')
|
2011-10-05 04:52:33 +00:00
|
|
|
|
|
|
|
if status:
|
|
|
|
print '@@@STEP_FAILURE@@@'
|
|
|
|
|
|
|
|
return status
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|