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/bisect_utils.py | |
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/bisect_utils.py')
-rw-r--r-- | tools/bisect_utils.py | 67 |
1 files changed, 59 insertions, 8 deletions
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 |