diff options
author | simonhatch@chromium.org <simonhatch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-10 23:49:42 +0000 |
---|---|---|
committer | simonhatch@chromium.org <simonhatch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-10 23:49:42 +0000 |
commit | bda7af447e05d67e293169a9f9cf9e782adfe53e (patch) | |
tree | c7a54717ba34cc5dbe1047d56a5a1310da05654e /tools | |
parent | 949536b580e9e884f5b5aafce54aa9c20a3f247c (diff) | |
download | chromium_src-bda7af447e05d67e293169a9f9cf9e782adfe53e.zip chromium_src-bda7af447e05d67e293169a9f9cf9e782adfe53e.tar.gz chromium_src-bda7af447e05d67e293169a9f9cf9e782adfe53e.tar.bz2 |
First pass android support in bisect script.
BUG=245361
Review URL: https://chromiumcodereview.appspot.com/16132012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/bisect-perf-regression.py | 75 | ||||
-rw-r--r-- | tools/bisect_utils.py | 67 | ||||
-rwxr-xr-x | tools/prepare-bisect-perf-regression.py | 8 | ||||
-rwxr-xr-x | tools/run-bisect-perf-regression.py | 8 |
4 files changed, 133 insertions, 25 deletions
diff --git a/tools/bisect-perf-regression.py b/tools/bisect-perf-regression.py index 83a75d0..f73603e 100755 --- a/tools/bisect-perf-regression.py +++ b/tools/bisect-perf-regression.py @@ -362,6 +362,52 @@ class DesktopBuilder(Builder): return build_success +class AndroidBuilder(Builder): + """AndroidBuilder is used to build on android.""" + def InstallAPK(self, opts): + """Installs apk to device. + + Args: + opts: The options parsed from the command line. + + Returns: + True if successful. + """ + path_to_tool = os.path.join('build', 'android', 'adb_install_apk.py') + cmd = [path_to_tool, '--apk', 'ContentShell.apk', '--apk_package', + 'org.chromium.content_shell_apk', '--release'] + (_, return_code) = RunProcess(cmd, opts.output_buildbot_annotations) + return not return_code + + def Build(self, depot, opts): + """Builds the android content shell and other necessary tools using options + passed into the script. + + Args: + depot: Current depot being bisected. + opts: The options parsed from the command line. + + Returns: + True if build was successful. + """ + targets = ['content_shell_apk', 'forwarder2', 'md5sum'] + threads = 16 + if opts.use_goma: + threads = 64 + + build_success = False + if opts.build_preference == 'ninja': + build_success = BuildWithNinja(threads, targets, + opts.output_buildbot_annotations) + else: + assert False, 'No build system defined.' + + if build_success: + build_success = self.InstallAPK(opts) + + return build_success + + class CrosBuilder(Builder): """CrosBuilder is used to build and image ChromeOS/Chromium when cros is the target platform.""" @@ -728,6 +774,8 @@ class BisectPerformanceMetrics(object): if opts.target_platform == 'cros': self.builder = CrosBuilder() + elif opts.target_platform == 'android': + self.builder = AndroidBuilder() else: self.builder = DesktopBuilder() @@ -1297,7 +1345,7 @@ class BisectPerformanceMetrics(object): return depot_revision_list - def GatherReferenceValues(self, good_rev, bad_rev, cmd, metric): + def GatherReferenceValues(self, good_rev, bad_rev, cmd, metric, target_depot): """Gathers reference values by running the performance tests on the known good and bad revisions. @@ -1312,7 +1360,7 @@ class BisectPerformanceMetrics(object): A tuple with the results of building and running each revision. """ bad_run_results = self.SyncBuildAndRunRevision(bad_rev, - self.opts.target_platform, + target_depot, cmd, metric) @@ -1320,7 +1368,7 @@ class BisectPerformanceMetrics(object): if not bad_run_results[1]: good_run_results = self.SyncBuildAndRunRevision(good_rev, - self.opts.target_platform, + target_depot, cmd, metric) @@ -1536,7 +1584,8 @@ class BisectPerformanceMetrics(object): (bad_results, good_results) = self.GatherReferenceValues(good_revision, bad_revision, command_to_run, - metric) + metric, + target_depot) if self.opts.output_buildbot_annotations: bisect_utils.OutputAnnotationStepClosed() @@ -2076,11 +2125,12 @@ def main(): 'are msvs/ninja.') parser.add_option('--target_platform', type='choice', - choices=['chromium', 'cros'], + choices=['chromium', 'cros', 'android'], default='chromium', - help='The target platform. Choices are "default" (current ' - 'platform, or "cros". If choosing "cros", you ' - 'must be properly set up to build.') + help='The target platform. Choices are "chromium" (current ' + 'platform), "cros", or "android". If you specify something ' + 'other than "chromium", you must be properly set up to ' + 'build that platform.') parser.add_option('--cros_board', type='str', help='The cros board type to build.') @@ -2167,11 +2217,10 @@ def main(): if bisect_utils.CreateBisectDirectoryAndSetupDepot(opts): return 1 - if opts.target_platform == 'cros': - if not bisect_utils.SetupCrosRepo(): - print 'Error: Failed to grab cros source.' - print - return 1 + if not bisect_utils.SetupPlatformBuildEnvironment(opts): + print 'Error: Failed to set platform environment.' + print + return 1 os.chdir(os.path.join(os.getcwd(), 'src')) diff --git a/tools/bisect_utils.py b/tools/bisect_utils.py index 28fd958..1a78bdc 100644 --- a/tools/bisect_utils.py +++ b/tools/bisect_utils.py @@ -10,6 +10,7 @@ import errno import os import shutil import subprocess +import sys GCLIENT_SPEC = """ @@ -30,6 +31,7 @@ solutions = [ ] """ GCLIENT_SPEC = ''.join([l for l in GCLIENT_SPEC.splitlines()]) +GCLIENT_SPEC_ANDROID = GCLIENT_SPEC + "\ntarget_os = ['android']" FILE_DEPS_GIT = '.DEPS.git' REPO_PARAMS = [ @@ -142,14 +144,21 @@ def RunRepoSyncAtTimestamp(timestamp): return RunRepo(cmd) -def RunGClientAndCreateConfig(): +def RunGClientAndCreateConfig(opts): """Runs gclient and creates a config containing both src and src-internal. + Args: + opts: The options parsed from the command line through parse_args(). + Returns: The return code of the call. """ + spec = GCLIENT_SPEC + if opts.target_platform == 'android': + spec = GCLIENT_SPEC_ANDROID + return_code = RunGClient( - ['config', '--spec=%s' % GCLIENT_SPEC, '--git-deps']) + ['config', '--spec=%s' % spec, '--git-deps']) return return_code @@ -190,17 +199,18 @@ def RunGClientAndSync(reset): Returns: The return code of the call. """ - params = ['sync', '--verbose'] + params = ['sync', '--verbose', '--nohooks'] if reset: params.extend(['--reset', '--force', '--delete_unversioned_trees']) return RunGClient(params) -def SetupGitDepot(output_buildbot_annotations, reset): +def SetupGitDepot(opts, reset): """Sets up the depot for the bisection. The depot will be located in a subdirectory called 'bisect'. Args: + opts: The options parsed from the command line through parse_args(). reset: Whether to reset any changes to the depot. Returns: @@ -209,12 +219,12 @@ def SetupGitDepot(output_buildbot_annotations, reset): """ name = 'Setting up Bisection Depot' - if output_buildbot_annotations: + if opts.output_buildbot_annotations: OutputAnnotationStepStart(name) passed = False - if not RunGClientAndCreateConfig(): + if not RunGClientAndCreateConfig(opts): passed_deps_check = True if os.path.isfile(os.path.join('src', FILE_DEPS_GIT)): cwd = os.getcwd() @@ -228,7 +238,7 @@ def SetupGitDepot(output_buildbot_annotations, reset): if passed_deps_check and not RunGClientAndSync(reset): passed = True - if output_buildbot_annotations: + if opts.output_buildbot_annotations: print OutputAnnotationStepClosed() @@ -261,6 +271,47 @@ def SetupCrosRepo(): return passed +def SetupAndroidBuildEnvironment(opts): + """Sets up the android build environment. + + Args: + opts: The options parsed from the command line through parse_args(). + path_to_file: Path to the bisect script's directory. + + Returns: + True if successful. + """ + path_to_file = os.path.join('build', 'android', 'envsetup.sh') + proc = subprocess.Popen(['bash', '-c', 'source %s && env' % path_to_file], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd='src') + (out, _) = proc.communicate() + + for line in out.splitlines(): + (k, _, v) = line.partition('=') + os.environ[k] = v + return not proc.returncode + + +def SetupPlatformBuildEnvironment(opts): + """Performs any platform specific setup. + + Args: + opts: The options parsed from the command line through parse_args(). + path_to_file: Path to the bisect script's directory. + + Returns: + True if successful. + """ + if opts.target_platform == 'android': + return SetupAndroidBuildEnvironment(opts) + elif opts.target_platform == 'cros': + return SetupCrosRepo() + + return False + + def CreateBisectDirectoryAndSetupDepot(opts, reset=False): """Sets up a subdirectory 'bisect' and then retrieves a copy of the depot there using gclient. @@ -277,7 +328,7 @@ def CreateBisectDirectoryAndSetupDepot(opts, reset=False): print return 1 - if not SetupGitDepot(opts.output_buildbot_annotations, reset): + if not SetupGitDepot(opts, reset): print 'Error: Failed to grab source.' print return 1 diff --git a/tools/prepare-bisect-perf-regression.py b/tools/prepare-bisect-perf-regression.py index fbecafd..a98a42e 100755 --- a/tools/prepare-bisect-perf-regression.py +++ b/tools/prepare-bisect-perf-regression.py @@ -41,6 +41,14 @@ def main(): parser.add_option('--output_buildbot_annotations', action="store_true", help='Add extra annotation output for buildbot.') + parser.add_option('--target_platform', + type='choice', + choices=['chromium', 'cros', 'android'], + default='chromium', + help='The target platform. Choices are "chromium" (current ' + 'platform), "cros", or "android". If you specify something ' + 'other than "chromium", you must be properly set up to ' + 'build that platform.') (opts, args) = parser.parse_args() if not opts.working_directory: diff --git a/tools/run-bisect-perf-regression.py b/tools/run-bisect-perf-regression.py index 42e27a3..77f1748 100755 --- a/tools/run-bisect-perf-regression.py +++ b/tools/run-bisect-perf-regression.py @@ -81,10 +81,7 @@ def RunBisectionScript(config, working_directory, path_to_file, path_to_goma): if config['max_time_minutes']: cmd.extend(['--repeat_test_max_time', config['max_time_minutes']]) - if os.name == 'nt': - cmd.extend(['--build_preference', 'ninja']) - else: - cmd.extend(['--build_preference', 'make']) + cmd.extend(['--build_preference', 'ninja']) if '--browser=cros' in config['command']: cmd.extend(['--target_platform', 'cros']) @@ -98,6 +95,9 @@ def RunBisectionScript(config, working_directory, path_to_file, path_to_goma): print return 1 + if '--browser=android' in config['command']: + cmd.extend(['--target_platform', 'android']) + goma_file = '' if path_to_goma: path_to_goma = os.path.abspath(path_to_goma) |