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
15 import buildbot_common
21 from buildbot_common
import Run
22 from build_paths
import SRC_DIR
, SDK_SRC_DIR
, SCRIPT_DIR
26 def StepArmRunHooks():
27 if getos
.GetPlatform() != 'linux':
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
:
47 Run([sys
.executable
, 'test_all.py'], env
=env
, cwd
=SDK_SRC_DIR
)
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.
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
))
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')
70 Run(args
, cwd
=new_script_dir
)
73 subprocess
.check_call(['subst', '/D', subst_drive
])
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
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
)
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
= optparse
.OptionParser(description
=__doc__
)
105 parser
.add_option('--build-only', action
='store_true',
106 help='Only build the SDK, don\'t build or run tests.')
107 parser
.add_option('--build-properties',
108 help='JSON properties passed by buildbot. Currently ignored.')
109 parser
.add_option('--factory-properties',
110 help='JSON properties passed by buildbot. Currently ignored.')
111 options
, args
= 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
124 if not options
.build_only
:
130 if __name__
== '__main__':
132 sys
.exit(main(sys
.argv
[1:]))
133 except KeyboardInterrupt:
134 buildbot_common
.ErrorExit('buildbot_run: interrupted')