OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 """Argument-less script to select what to run on the buildbots.""" | 7 """Argument-less script to select what to run on the buildbots.""" |
8 | 8 |
9 | 9 |
10 import filecmp | |
10 import os | 11 import os |
11 import shutil | 12 import shutil |
12 import subprocess | 13 import subprocess |
13 import sys | 14 import sys |
14 | 15 |
15 | 16 |
16 if sys.platform in ['win32', 'cygwin']: | 17 if sys.platform in ['win32', 'cygwin']: |
17 EXE_SUFFIX = '.exe' | 18 EXE_SUFFIX = '.exe' |
18 else: | 19 else: |
19 EXE_SUFFIX = '' | 20 EXE_SUFFIX = '' |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 76 |
76 _ANDROID_SETUP = 'source build/envsetup.sh && lunch full-eng' | 77 _ANDROID_SETUP = 'source build/envsetup.sh && lunch full-eng' |
77 | 78 |
78 | 79 |
79 def PrepareAndroidTree(): | 80 def PrepareAndroidTree(): |
80 """Prepare an Android tree to run 'android' format tests.""" | 81 """Prepare an Android tree to run 'android' format tests.""" |
81 if os.environ['BUILDBOT_CLOBBER'] == '1': | 82 if os.environ['BUILDBOT_CLOBBER'] == '1': |
82 print '@@@BUILD_STEP Clobber Android checkout@@@' | 83 print '@@@BUILD_STEP Clobber Android checkout@@@' |
83 shutil.rmtree(ANDROID_DIR) | 84 shutil.rmtree(ANDROID_DIR) |
84 | 85 |
85 # The release of Android we use is static, so there's no need to do anything | 86 # (Re)create the directory so that the following steps will succeed. |
86 # if the directory already exists. | 87 if not os.path.isdir(ANDROID_DIR): |
87 if os.path.isdir(ANDROID_DIR): | 88 os.mkdir(ANDROID_DIR) |
89 | |
90 # We use a manifest from the gyp project listing pinned revisions of AOSP to | |
91 # use, to ensure that we test against a stable target. This needs to be | |
92 # updated to pick up new build system changes sometimes, so we must test if | |
93 # it has changed. | |
94 manifest_filename = 'aosp_manifest.xml' | |
95 gyp_manifest = os.path.join(BUILDBOT_DIR, manifest_filename) | |
96 android_manifest = os.path.join(ANDROID_DIR, '.repo', 'manifests', | |
97 manifest_filename) | |
98 manifest_is_current = (os.path.isfile(android_manifest) and | |
99 filecmp.cmp(gyp_manifest, android_manifest)) | |
100 if not manifest_is_current: | |
101 # It's safe to repeat these steps, so just do them again to make sure we are | |
102 # in a good state. | |
103 print '@@@BUILD_STEP Initialize Android checkout@@@' | |
104 CallSubProcess(['git', 'config', '--global', 'user.name', 'trybot']) | |
jbudorick
2014/08/22 05:10:48
Ha, I think I wound up trying to upload a CL as "t
Primiano Tucci (use gerrit)
2014/08/22 11:18:16
Actually turns out that we don't need this at all
| |
105 CallSubProcess(['git', 'config', '--global', | |
106 'user.email', 'chrome-bot@google.com']) | |
107 CallSubProcess(['git', 'config', '--global', 'color.ui', 'false']) | |
108 CallSubProcess( | |
109 ['repo', 'init', | |
110 '-u', 'https://android.googlesource.com/platform/manifest', | |
111 '-b', 'master', | |
112 '-g', 'all,-notdefault,-device,-darwin,-mips,-x86'], | |
113 cwd=ANDROID_DIR) | |
114 shutil.copy(gyp_manifest, android_manifest) | |
115 | |
116 print '@@@BUILD_STEP Sync Android@@@' | |
117 CallSubProcess(['repo', 'sync', '-j4', '-m', manifest_filename], | |
118 cwd=ANDROID_DIR) | |
119 | |
120 # If we already built the system image successfully and didn't sync to a new | |
121 # version of the source, skip running the build again as it's expensive even | |
122 # when there's nothing to do. | |
123 system_img = os.path.join(ANDROID_DIR, 'out', 'target', 'product', 'generic', | |
124 'system.img') | |
125 if manifest_is_current and os.path.isfile(system_img): | |
88 return | 126 return |
89 | 127 |
90 print '@@@BUILD_STEP Initialize Android checkout@@@' | |
91 os.mkdir(ANDROID_DIR) | |
92 CallSubProcess(['git', 'config', '--global', 'user.name', 'trybot']) | |
93 CallSubProcess(['git', 'config', '--global', | |
94 'user.email', 'chrome-bot@google.com']) | |
95 CallSubProcess(['git', 'config', '--global', 'color.ui', 'false']) | |
96 CallSubProcess( | |
97 ['repo', 'init', | |
98 '-u', 'https://android.googlesource.com/platform/manifest', | |
99 '-b', 'android-4.2.1_r1', | |
100 '-g', 'all,-notdefault,-device,-darwin,-mips,-x86'], | |
101 cwd=ANDROID_DIR) | |
102 | |
103 print '@@@BUILD_STEP Sync Android@@@' | |
104 CallSubProcess(['repo', 'sync', '-j4'], cwd=ANDROID_DIR) | |
105 | |
106 print '@@@BUILD_STEP Build Android@@@' | 128 print '@@@BUILD_STEP Build Android@@@' |
107 CallSubProcess( | 129 CallSubProcess( |
108 ['/bin/bash', | 130 ['/bin/bash', |
109 '-c', '%s && make -j4' % _ANDROID_SETUP], | 131 '-c', '%s && make -j4' % _ANDROID_SETUP], |
110 cwd=ANDROID_DIR) | 132 cwd=ANDROID_DIR) |
111 | 133 |
112 | 134 |
113 def StartAndroidEmulator(): | 135 def StartAndroidEmulator(): |
114 """Start an android emulator from the built android tree.""" | 136 """Start an android emulator from the built android tree.""" |
115 print '@@@BUILD_STEP Start Android emulator@@@' | 137 print '@@@BUILD_STEP Start Android emulator@@@' |
116 android_host_bin = '$ANDROID_HOST_OUT/bin' | 138 |
139 CallSubProcess(['/bin/bash', '-c', | |
140 '%s && adb kill-server ' % _ANDROID_SETUP], | |
141 cwd=ANDROID_DIR) | |
142 | |
143 # If taskset is available, use it to force adbd to run only on one core, as, | |
jbudorick
2014/08/22 05:10:48
yay adb
Primiano Tucci (use gerrit)
2014/08/22 11:18:16
Amazing, isn't it?
| |
144 # sadly, it improves its reliability (see crbug.com/268450). | |
145 adbd_wrapper = '' | |
146 with open(os.devnull, 'w') as devnull_fd: | |
147 if subprocess.call(['which', 'taskset'], stdout=devnull_fd) == 0: | |
148 adbd_wrapper = 'taskset -c 0' | |
149 CallSubProcess(['/bin/bash', '-c', | |
150 '%s && %s adb start-server ' % (_ANDROID_SETUP, adbd_wrapper)], | |
151 cwd=ANDROID_DIR) | |
152 | |
117 subprocess.Popen( | 153 subprocess.Popen( |
118 ['/bin/bash', '-c', | 154 ['/bin/bash', '-c', |
119 '%s && %s/emulator -no-window' % (_ANDROID_SETUP, android_host_bin)], | 155 '%s && emulator -no-window' % _ANDROID_SETUP], |
jbudorick
2014/08/22 05:10:48
I think I asked this on torne's review, but is thi
Primiano Tucci (use gerrit)
2014/08/22 11:18:16
Correct. envsetup / lunch make it so that the corr
| |
120 cwd=ANDROID_DIR) | 156 cwd=ANDROID_DIR) |
121 CallSubProcess( | 157 CallSubProcess( |
122 ['/bin/bash', '-c', | 158 ['/bin/bash', '-c', |
123 '%s && %s/adb wait-for-device' % (_ANDROID_SETUP, android_host_bin)], | 159 '%s && adb wait-for-device' % _ANDROID_SETUP], |
124 cwd=ANDROID_DIR) | 160 cwd=ANDROID_DIR) |
125 | 161 |
126 | 162 |
127 def StopAndroidEmulator(): | 163 def StopAndroidEmulator(): |
128 """Stop all android emulators.""" | 164 """Stop all android emulators.""" |
129 print '@@@BUILD_STEP Stop Android emulator@@@' | 165 print '@@@BUILD_STEP Stop Android emulator@@@' |
130 # If this fails, it's because there is no emulator running. | 166 # If this fails, it's because there is no emulator running. |
131 subprocess.call(['pkill', 'emulator.*']) | 167 subprocess.call(['pkill', 'emulator.*']) |
132 | 168 |
133 | 169 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 # TODO(bradnelson): once the annotator supports a postscript (section for | 250 # TODO(bradnelson): once the annotator supports a postscript (section for |
215 # after the build proper that could be used for cumulative failures), | 251 # after the build proper that could be used for cumulative failures), |
216 # use that instead of this. This isolates the final return value so | 252 # use that instead of this. This isolates the final return value so |
217 # that it isn't misattributed to the last stage. | 253 # that it isn't misattributed to the last stage. |
218 print '@@@BUILD_STEP failures@@@' | 254 print '@@@BUILD_STEP failures@@@' |
219 sys.exit(retcode) | 255 sys.exit(retcode) |
220 | 256 |
221 | 257 |
222 if __name__ == '__main__': | 258 if __name__ == '__main__': |
223 GypBuild() | 259 GypBuild() |
OLD | NEW |