Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / buildbot_run.py
blob5971a58c1647c36a2a851a979d4b0ba0bee38fc5
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. 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 """Main entry point for the NaCl SDK buildbot.
8 The entry point used to be build_sdk.py itself, but we want
9 to be able to simplify build_sdk (for example separating out
10 the test code into test_sdk) and change its default behaviour
11 while being able to separately control excactly what the bots
12 run.
13 """
15 import argparse
16 import buildbot_common
17 import os
18 import subprocess
19 import sys
21 from buildbot_common import Run
22 from build_paths import SRC_DIR, SDK_SRC_DIR, SCRIPT_DIR
23 import getos
26 def StepArmRunHooks():
27 if getos.GetPlatform() != 'linux':
28 return
29 # Run 'gclient runhooks' for arm, as some arm specific tools are only
30 # installed in that case.
31 buildbot_common.BuildStep('gclient runhooks for arm')
32 env = dict(os.environ)
33 env['GYP_DEFINES'] = 'target_arch=arm'
34 Run(['gclient', 'runhooks'], env=env, cwd=SDK_SRC_DIR)
37 def StepRunUnittests():
38 buildbot_common.BuildStep('Run unittests')
40 # Our tests shouldn't be using the proxy; they should all be connecting to
41 # localhost. Some slaves can't route HTTP traffic through the proxy to
42 # localhost (we get 504 gateway errors), so we clear it here.
43 env = dict(os.environ)
44 if 'http_proxy' in env:
45 del env['http_proxy']
47 Run([sys.executable, 'test_all.py', '-v'], env=env, cwd=SDK_SRC_DIR)
50 def StepBuildSDK():
51 is_win = getos.GetPlatform() == 'win'
53 # Windows has a path length limit of 255 characters, after joining cwd with a
54 # relative path. Use subst before building to keep the path lengths short.
55 if is_win:
56 subst_drive = 'S:'
57 root_dir = os.path.dirname(SRC_DIR)
58 new_root_dir = subst_drive + '\\'
59 subprocess.check_call(['subst', subst_drive, root_dir])
60 new_script_dir = os.path.join(new_root_dir,
61 os.path.relpath(SCRIPT_DIR, root_dir))
62 else:
63 new_script_dir = SCRIPT_DIR
65 args = [sys.executable, 'build_sdk.py']
66 if 'bionic' in os.getenv('BUILDBOT_BUILDERNAME', ''):
67 args.append('--bionic')
69 try:
70 Run(args, cwd=new_script_dir)
71 finally:
72 if is_win:
73 subprocess.check_call(['subst', '/D', subst_drive])
76 def StepTestSDK():
77 cmd = []
78 if getos.GetPlatform() == 'linux':
79 # Run all of test_sdk.py under xvfb-run; it's startup time leaves something
80 # to be desired, so only start it up once.
81 # We also need to make sure that there are at least 24 bits per pixel.
82 # https://code.google.com/p/chromium/issues/detail?id=316687
83 cmd.extend([
84 'xvfb-run',
85 '--auto-servernum',
86 '--server-args', '-screen 0 1024x768x24'
89 cmd.extend([sys.executable, 'test_sdk.py'])
91 # TODO(noelallen): crbug 386332
92 # For Bionic SDK, only build do a build test until we have hardware.
93 if 'bionic' in os.getenv('BUILDBOT_BUILDERNAME', ''):
94 cmd.extend(['build_examples', 'copy_tests', 'build_tests'])
95 Run(cmd, cwd=SCRIPT_DIR)
98 def main(args):
99 # Don't write out .pyc files in the source tree. Without this, incremental
100 # builds can fail when .py files are moved/deleted, since python could load
101 # orphaned .pyc files generated by a previous run.
102 os.environ['PYTHONDONTWRITEBYTECODE'] = '1'
104 parser = argparse.ArgumentParser(description=__doc__)
105 parser.add_argument('--build-only', action='store_true',
106 help='Only build the SDK, don\'t build or run tests.')
107 parser.add_argument('--build-properties',
108 help='JSON properties passed by buildbot. Currently ignored.')
109 parser.add_argument('--factory-properties',
110 help='JSON properties passed by buildbot. Currently ignored.')
111 options = parser.parse_args(args)
113 # Skip the testing phase if we are running on a build-only bots.
114 if not options.build_only:
115 # Infer build-only from bot name.
116 # TODO(sbc): Remove this once buildbot script have been updated
117 # to pass --build-only argument.
118 if os.getenv('BUILDBOT_BUILDERNAME', '').endswith('build'):
119 options.build_only = True
121 StepArmRunHooks()
122 StepRunUnittests()
123 StepBuildSDK()
124 if not options.build_only:
125 StepTestSDK()
127 return 0
130 if __name__ == '__main__':
131 try:
132 sys.exit(main(sys.argv[1:]))
133 except KeyboardInterrupt:
134 buildbot_common.ErrorExit('buildbot_run: interrupted')