Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: tools/auto_bisect/fetch_build.py

Issue 866573003: Add builder_type to fetch builds for android-chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """This module contains functions for fetching and extracting archived builds. 5 """This module contains functions for fetching and extracting archived builds.
6 6
7 The builds may be stored in different places by different types of builders; 7 The builds may be stored in different places by different types of builders;
8 for example, builders on tryserver.chromium.perf stores builds in one place, 8 for example, builders on tryserver.chromium.perf stores builds in one place,
9 while builders on chromium.linux store builds in another. 9 while builders on chromium.linux store builds in another.
10 10
(...skipping 12 matching lines...) Expand all
23 import zipfile 23 import zipfile
24 24
25 # Telemetry (src/tools/telemetry) is expected to be in the PYTHONPATH. 25 # Telemetry (src/tools/telemetry) is expected to be in the PYTHONPATH.
26 from telemetry.util import cloud_storage 26 from telemetry.util import cloud_storage
27 27
28 import bisect_utils 28 import bisect_utils
29 29
30 # Possible builder types. 30 # Possible builder types.
31 PERF_BUILDER = 'perf' 31 PERF_BUILDER = 'perf'
32 FULL_BUILDER = 'full' 32 FULL_BUILDER = 'full'
33 ANDROID_CHROME_PERF_BUILDER = 'android-chrome-perf'
33 34
34 35
35 def GetBucketAndRemotePath(revision, builder_type=PERF_BUILDER, 36 def GetBucketAndRemotePath(revision, builder_type=PERF_BUILDER,
36 target_arch='ia32', target_platform='chromium', 37 target_arch='ia32', target_platform='chromium',
37 deps_patch_sha=None): 38 deps_patch_sha=None, extra_src=None):
38 """Returns the location where a build archive is expected to be. 39 """Returns the location where a build archive is expected to be.
39 40
40 Args: 41 Args:
41 revision: Revision string, e.g. a git commit hash or SVN revision. 42 revision: Revision string, e.g. a git commit hash or SVN revision.
42 builder_type: Type of build archive. 43 builder_type: Type of build archive.
43 target_arch: Architecture, e.g. "ia32". 44 target_arch: Architecture, e.g. "ia32".
44 target_platform: Platform name, e.g. "chromium" or "android". 45 target_platform: Platform name, e.g. "chromium" or "android".
45 deps_patch_sha: SHA1 hash which identifies a particular combination of 46 deps_patch_sha: SHA1 hash which identifies a particular combination of
46 custom revisions for dependency repositories. 47 custom revisions for dependency repositories.
48 extra_src: Path to a script which can be used to modify the bisect script's
49 behavior.
47 50
48 Returns: 51 Returns:
49 A pair of strings (bucket, path), where the archive is expected to be. 52 A pair of strings (bucket, path), where the archive is expected to be.
50 """ 53 """
51 build_archive = BuildArchive.Create( 54 build_archive = BuildArchive.Create(
52 builder_type, target_arch=target_arch, target_platform=target_platform) 55 builder_type, target_arch=target_arch, target_platform=target_platform,
56 extra_src=extra_src)
53 bucket = build_archive.BucketName() 57 bucket = build_archive.BucketName()
54 remote_path = build_archive.FilePath(revision, deps_patch_sha=deps_patch_sha) 58 remote_path = build_archive.FilePath(revision, deps_patch_sha=deps_patch_sha)
55 return bucket, remote_path 59 return bucket, remote_path
56 60
57 61
58 class BuildArchive(object): 62 class BuildArchive(object):
59 """Represents a place where builds of some type are stored. 63 """Represents a place where builds of some type are stored.
60 64
61 There are two pieces of information required to locate a file in Google 65 There are two pieces of information required to locate a file in Google
62 Cloud Storage, bucket name and file path. Subclasses of this class contain 66 Cloud Storage, bucket name and file path. Subclasses of this class contain
63 specific logic about which bucket names and paths should be used to fetch 67 specific logic about which bucket names and paths should be used to fetch
64 a build. 68 a build.
65 """ 69 """
66 70
67 @staticmethod 71 @staticmethod
68 def Create(builder_type, target_arch='ia32', target_platform='chromium'): 72 def Create(builder_type, target_arch='ia32', target_platform='chromium',
73 extra_src=None):
69 if builder_type == PERF_BUILDER: 74 if builder_type == PERF_BUILDER:
70 return PerfBuildArchive(target_arch, target_platform) 75 return PerfBuildArchive(target_arch, target_platform)
71 if builder_type == FULL_BUILDER: 76 if builder_type == FULL_BUILDER:
72 return FullBuildArchive(target_arch, target_platform) 77 return FullBuildArchive(target_arch, target_platform)
78 if builder_type == ANDROID_CHROME_PERF_BUILDER:
79 try:
80 # Load and initialize a module in extra source file and
81 # return its module object to access android-chrome specific data.
82 loaded_extra_src = bisect_utils.LoadExtraSrc(extra_src)
83 return AndroidChromeBuildArchive(
84 target_arch, target_platform, loaded_extra_src)
85 except (IOError, TypeError, ImportError):
86 raise RuntimeError('Invalid or missing --extra_src. [%s]' % extra_src)
73 raise NotImplementedError('Builder type "%s" not supported.' % builder_type) 87 raise NotImplementedError('Builder type "%s" not supported.' % builder_type)
74 88
75 def __init__(self, target_arch='ia32', target_platform='chromium'): 89 def __init__(self, target_arch='ia32', target_platform='chromium',
90 extra_src=None):
91 self._extra_src = extra_src
76 if bisect_utils.IsLinuxHost() and target_platform == 'android': 92 if bisect_utils.IsLinuxHost() and target_platform == 'android':
77 self._platform = 'android' 93 self._platform = 'android'
78 elif bisect_utils.IsLinuxHost(): 94 elif bisect_utils.IsLinuxHost():
79 self._platform = 'linux' 95 self._platform = 'linux'
80 elif bisect_utils.IsMacHost(): 96 elif bisect_utils.IsMacHost():
81 self._platform = 'mac' 97 self._platform = 'mac'
82 elif bisect_utils.Is64BitWindows() and target_arch == 'x64': 98 elif bisect_utils.Is64BitWindows() and target_arch == 'x64':
83 self._platform = 'win64' 99 self._platform = 'win64'
84 elif bisect_utils.IsWindowsHost(): 100 elif bisect_utils.IsWindowsHost():
85 self._platform = 'win' 101 self._platform = 'win'
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 'android': 'android_main_rel', 196 'android': 'android_main_rel',
181 'linux': 'chromium.linux/Linux Builder', 197 'linux': 'chromium.linux/Linux Builder',
182 'mac': 'chromium.mac/Mac Builder', 198 'mac': 'chromium.mac/Mac Builder',
183 'win64': 'chromium.win/Win x64 Builder', 199 'win64': 'chromium.win/Win x64 Builder',
184 'win': 'chromium.win/Win Builder', 200 'win': 'chromium.win/Win Builder',
185 } 201 }
186 assert self._platform in platform_to_directory 202 assert self._platform in platform_to_directory
187 return platform_to_directory.get(self._platform) 203 return platform_to_directory.get(self._platform)
188 204
189 205
206 class AndroidChromeBuildArchive(BuildArchive):
207 """Represents a place where builds of android-chrome type are stored.
208
209 If AndroidChromeBuildArchive is used, it is assumed that the --extra_src
210 is a valid Python module which contains the module-level functions
211 GetBucketName and GetArchiveDirectory.
212 """
213
214 def BucketName(self):
215 return self._extra_src.GetBucketName()
216
217 def _ZipFileName(self, revision, deps_patch_sha=None):
218 """Gets the file name of a zip archive on android-chrome.
219
220 This returns a file name of the form build_product_<revision>.zip,
221 which is a format used by android-chrome.
222
223 Args:
224 revision: A git commit hash or other revision string.
225 deps_patch_sha: SHA1 hash of a DEPS file patch.
226
227 Returns:
228 The archive file name.
229 """
230 if deps_patch_sha:
231 revision = '%s_%s' % (revision, deps_patch_sha)
232 return 'build_product_%s.zip' % revision
233
234 def FilePath(self, revision, deps_patch_sha=None):
235 return '%s/%s' % (self._ArchiveDirectory(),
236 self._ZipFileName(revision, deps_patch_sha))
237
238 def _ArchiveDirectory(self):
239 """Returns the directory name to download builds from."""
240 return self._extra_src.GetArchiveDirectory()
241
242
190 def BuildIsAvailable(bucket_name, remote_path): 243 def BuildIsAvailable(bucket_name, remote_path):
191 """Checks whether a build is currently archived at some place.""" 244 """Checks whether a build is currently archived at some place."""
192 logging.info('Checking existance: gs://%s/%s' % (bucket_name, remote_path)) 245 logging.info('Checking existance: gs://%s/%s' % (bucket_name, remote_path))
193 try: 246 try:
194 exists = cloud_storage.Exists(bucket_name, remote_path) 247 exists = cloud_storage.Exists(bucket_name, remote_path)
195 logging.info('Exists? %s' % exists) 248 logging.info('Exists? %s' % exists)
196 return exists 249 return exists
197 except cloud_storage.CloudStorageError: 250 except cloud_storage.CloudStorageError:
198 return False 251 return False
199 252
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return 1 408 return 1
356 409
357 FetchFromCloudStorage(bucket_name, remote_path, args.output_dir) 410 FetchFromCloudStorage(bucket_name, remote_path, args.output_dir)
358 print 'Build has been downloaded to and extracted in %s.' % args.output_dir 411 print 'Build has been downloaded to and extracted in %s.' % args.output_dir
359 return 0 412 return 0
360 413
361 414
362 if __name__ == '__main__': 415 if __name__ == '__main__':
363 sys.exit(Main(sys.argv)) 416 sys.exit(Main(sys.argv))
364 417
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698