Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from slave import recipe_api | 5 from slave import recipe_api | 
| 6 | 6 | 
| 7 class AndroidApi(recipe_api.RecipeApi): | 7 class AndroidApi(recipe_api.RecipeApi): | 
| 8 def __init__(self, **kwargs): | 8 def __init__(self, **kwargs): | 
| 9 super(AndroidApi, self).__init__(**kwargs) | 9 super(AndroidApi, self).__init__(**kwargs) | 
| 10 self._env = dict() | |
| 11 self._build_internal_android = None | |
| 12 self._internal_dir = None | |
| 13 | |
| 14 def get_env(self): | |
| 15 env_dict = dict(self._env) | |
| 16 for env_var, value in self.c.extra_env.items(): | |
| 
 
iannucci
2013/09/20 21:07:56
iteritems()
 
 | |
| 17 if isinstance(value, list): | |
| 18 env_dict[env_var] = self.m.path.checkout(*value) | |
| 19 else: | |
| 20 env_dict[env_var] = value | |
| 21 # TODO(sivachandra): Use os.pathsep equivalent instead of ':' when it | |
| 22 # provided by one of the recipe modules. | |
| 23 env_dict['PATH'] = (self._build_internal_android + ':' + | |
| 24 self._env.get('PATH', '')) | |
| 25 return env_dict | |
| 10 | 26 | 
| 11 def init_and_sync(self): | 27 def init_and_sync(self): | 
| 12 internal = self.m.properties['internal'] | 28 internal = self.m.properties['internal'] | 
| 13 bot_id = self.m.properties['android_bot_id'] | 29 bot_id = self.m.properties['android_bot_id'] | 
| 14 target = self.m.properties.get('target', 'Debug') | 30 target = self.m.properties.get('target', 'Debug') | 
| 15 repo_name = self.m.properties['repo_name'] | 31 repo_name = self.m.properties['repo_name'] | 
| 16 repo_url = self.m.properties['repo_url'] | 32 repo_url = self.m.properties['repo_url'] | 
| 17 revision = self.m.properties.get('revision') | 33 revision = self.m.properties.get('revision') | 
| 18 gclient_custom_deps = self.m.properties.get('gclient_custom_deps') | 34 gclient_custom_deps = self.m.properties.get('gclient_custom_deps') | 
| 19 | 35 | 
| 20 if internal: | 36 if internal: | 
| 21 self.internal_dir = repo_name.split('/', 1)[-1] | 37 self._internal_dir = repo_name.split('/', 1)[-1] | 
| 22 | 38 | 
| 23 self.set_config(bot_id, | 39 self.set_config(bot_id, | 
| 24 INTERNAL=internal, | 40 INTERNAL=internal, | 
| 25 REPO_NAME=repo_name, | 41 REPO_NAME=repo_name, | 
| 26 REPO_URL=repo_url, | 42 REPO_URL=repo_url, | 
| 27 BUILD_CONFIG=target) | 43 BUILD_CONFIG=target) | 
| 28 | 44 | 
| 29 # TODO(sivachandra): Move the setting of the gclient spec below to an | 45 # TODO(sivachandra): Move the setting of the gclient spec below to an | 
| 30 # internal config extension when they are supported by the recipe system. | 46 # internal config extension when they are supported by the recipe system. | 
| 31 spec = self.m.gclient.make_config('android_bare') | 47 spec = self.m.gclient.make_config('android_bare') | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 42 | 58 | 
| 43 yield self.m.gclient.checkout(spec) | 59 yield self.m.gclient.checkout(spec) | 
| 44 | 60 | 
| 45 # TODO(sivachandra): Manufacture gclient spec such that it contains "src" | 61 # TODO(sivachandra): Manufacture gclient spec such that it contains "src" | 
| 46 # solution + repo_name solution. Then checkout will be automatically | 62 # solution + repo_name solution. Then checkout will be automatically | 
| 47 # correctly set by gclient.checkout | 63 # correctly set by gclient.checkout | 
| 48 manual_checkout_path = self.m.path.slave_build('src') | 64 manual_checkout_path = self.m.path.slave_build('src') | 
| 49 self.m.path.add_checkout(manual_checkout_path) | 65 self.m.path.add_checkout(manual_checkout_path) | 
| 50 self.m.path.choose_checkout(manual_checkout_path) | 66 self.m.path.choose_checkout(manual_checkout_path) | 
| 51 | 67 | 
| 52 self.build_internal_android = self.m.path.build_internal( | 68 self._build_internal_android = self.m.path.build_internal( | 
| 53 'scripts', 'slave', 'android') | 69 'scripts', 'slave', 'android') | 
| 54 | 70 | 
| 55 for env_var, value in self.c.extra_env.items(): | 71 gyp_defs = self.m.chromium.c.gyp_env.GYP_DEFINES | 
| 56 if isinstance(value, list): | 72 for gyp_def, val in gyp_defs.items(): | 
| 57 self.c.extra_env[env_var] = self.m.path.checkout(*value) | 73 if isinstance(val, list): | 
| 74 gyp_defs[gyp_def] = self.m.path.checkout(*val) | |
| 58 | 75 | 
| 59 if internal: | 76 if internal: | 
| 60 yield self.m.step( | 77 yield self.m.step( | 
| 61 'Get AppManifestVars', | 78 'get app_manifest_vars', | 
| 62 [self.m.path.checkout( | 79 [self.m.path.checkout( | 
| 63 self.internal_dir, 'build', 'dump_app_manifest_vars.py'), | 80 self._internal_dir, 'build', 'dump_app_manifest_vars.py'), | 
| 64 '-b', self.m.properties['buildername'], | 81 '-b', self.m.properties['buildername'], | 
| 65 '-v', self.m.path.checkout('chrome', 'VERSION'), | 82 '-v', self.m.path.checkout('chrome', 'VERSION'), | 
| 66 self.m.json.output()] | 83 self.m.json.output()] | 
| 67 ) | 84 ) | 
| 68 | 85 | 
| 69 app_manifest_vars = self.m.step_history.last_step().json.output | 86 app_manifest_vars = self.m.step_history.last_step().json.output | 
| 70 gyp_defs = self.m.chromium.c.gyp_env.GYP_DEFINES | 87 gyp_defs = self.m.chromium.c.gyp_env.GYP_DEFINES | 
| 71 gyp_defs['app_manifest_version_code'] = app_manifest_vars['version_code'] | 88 gyp_defs['app_manifest_version_code'] = app_manifest_vars['version_code'] | 
| 72 gyp_defs['app_manifest_version_name'] = app_manifest_vars['version_name'] | 89 gyp_defs['app_manifest_version_name'] = app_manifest_vars['version_name'] | 
| 73 gyp_defs['chrome_build_id'] = app_manifest_vars['build_id'] | 90 gyp_defs['chrome_build_id'] = app_manifest_vars['build_id'] | 
| 74 | 91 | 
| 75 def envsetup(self): | 92 def envsetup(self): | 
| 76 envsetup_cmd = [self.m.path.checkout('build', 'android', 'envsetup.sh')] | 93 envsetup_cmd = [self.m.path.checkout('build', 'android', 'envsetup.sh')] | 
| 77 if self.c.target_arch: | 94 if self.c.target_arch: | 
| 78 envsetup_cmd += ['--target-arch=%s' % self.c.target_arch] | 95 envsetup_cmd += ['--target-arch=%s' % self.c.target_arch] | 
| 79 | 96 | 
| 80 init_env = {} | |
| 81 if self.m.properties.get('internal'): | |
| 82 init_env = { | |
| 83 'EXTRA_LANDMINES_SCRIPT': self.m.path.checkout( | |
| 84 self.internal_dir, 'build', 'get_internal_landmines.py') | |
| 85 } | |
| 86 init_env.update(self.c.extra_env.as_jsonish()) | |
| 87 | |
| 88 # TODO(sivachandra): make envsetup_cmd_to_json only output salient | |
| 89 # differences in environment. | |
| 90 cmd = ([self.m.path.checkout('build', 'env_dump.py'), | 97 cmd = ([self.m.path.checkout('build', 'env_dump.py'), | 
| 91 self.m.json.output()] + envsetup_cmd) | 98 self.m.json.output()] + envsetup_cmd) | 
| 92 yield self.m.step('envsetup', cmd, env=init_env) | 99 yield self.m.step('envsetup', cmd, env=self.get_env()) | 
| 93 | 100 | 
| 94 self.env = self.m.step_history.last_step().json.output | 101 env_diff = self.m.step_history.last_step().json.output | 
| 95 # TODO(sivachandra): Use os.pathsep equivalent instead of ':' when it | 102 for key, value in env_diff.items(): | 
| 96 # provided by one of the recipe modules. | 103 if key.startswith('GYP_'): | 
| 97 self.env['PATH'] += (self.build_internal_android + ':' + | 104 continue | 
| 98 self.env.get('PATH')) | 105 else: | 
| 106 self._env[key] = value | |
| 99 | 107 | 
| 100 def clean_local_files(self): | 108 def clean_local_files(self): | 
| 101 target = self.m.properties.get('target', 'Debug') | 109 target = self.m.properties.get('target', 'Debug') | 
| 102 debug_info_dumps = self.m.path.checkout('out', target, 'debug_info_dumps') | 110 debug_info_dumps = self.m.path.checkout('out', target, 'debug_info_dumps') | 
| 103 test_logs = self.m.path.checkout('out', target, 'test_logs') | 111 test_logs = self.m.path.checkout('out', target, 'test_logs') | 
| 104 return self.m.python.inline( | 112 return self.m.python.inline( | 
| 105 'clean local files', | 113 'clean local files', | 
| 106 """ | 114 """ | 
| 107 import shutil, sys, os | 115 import shutil, sys, os | 
| 108 shutil.rmtree(sys.argv[1], True) | 116 shutil.rmtree(sys.argv[1], True) | 
| 109 shutil.rmtree(sys.argv[2], True) | 117 shutil.rmtree(sys.argv[2], True) | 
| 110 for base, _dirs, files in os.walk(sys.argv[3]): | 118 for base, _dirs, files in os.walk(sys.argv[3]): | 
| 111 for f in files: | 119 for f in files: | 
| 112 if f.endswith('.pyc'): | 120 if f.endswith('.pyc'): | 
| 113 os.remove(os.path.join(base, f)) | 121 os.remove(os.path.join(base, f)) | 
| 114 """, | 122 """, | 
| 115 args=[debug_info_dumps, test_logs, self.m.path.checkout()], | 123 args=[debug_info_dumps, test_logs, self.m.path.checkout()], | 
| 116 ) | 124 ) | 
| 117 | 125 | 
| 118 def run_tree_truth(self, show_revisions=False): | 126 def run_tree_truth(self, show_revisions=False): | 
| 119 # TODO(sivachandra): The downstream ToT builder will require | 127 # TODO(sivachandra): The downstream ToT builder will require | 
| 120 # 'Show Revisions' step. | 128 # 'Show Revisions' step. | 
| 121 repos = ['src', 'src-internal'] | 129 repos = ['src', 'src-internal'] | 
| 122 if self.c.REPO_NAME not in repos: | 130 if self.c.REPO_NAME not in repos: | 
| 123 repos.append(self.c.REPO_NAME) | 131 repos.append(self.c.REPO_NAME) | 
| 124 # TODO(sivachandra): Disable subannottations after cleaning up | 132 # TODO(sivachandra): Disable subannottations after cleaning up | 
| 125 # tree_truth.sh. | 133 # tree_truth.sh. | 
| 126 yield self.m.step('Tree Truth Steps', | 134 yield self.m.step('tree truth steps', | 
| 127 [self.m.path.checkout('build', 'tree_truth.sh'), | 135 [self.m.path.checkout('build', 'tree_truth.sh'), | 
| 128 self.m.path.checkout()] + repos, | 136 self.m.path.checkout()] + repos, | 
| 129 allow_subannottations=True) | 137 allow_subannottations=True) | 
| 130 | 138 | 
| 131 def runhooks(self): | 139 def runhooks(self): | 
| 132 return self.m.gclient.runhooks(env=self.env) | 140 run_hooks_env = self.get_env() | 
| 141 if self.m.properties.get('internal'): | |
| 142 run_hooks_env['EXTRA_LANDMINES_SCRIPT'] = self.m.path.checkout( | |
| 143 self._internal_dir, 'build', 'get_internal_landmines.py') | |
| 144 return self.m.gclient.runhooks(env=run_hooks_env) | |
| 
 
iannucci
2013/09/20 21:07:56
We should make this self.m.chromium.runhooks so th
 
 | |
| 133 | 145 | 
| 134 def compile(self, target='Debug'): | 146 def compile(self, target='Debug'): | 
| 135 return self.m.chromium.compile(env=self.env) | 147 return self.m.chromium.compile(env=self.get_env()) | 
| 136 | 148 | 
| 137 def findbugs(self): | 149 def findbugs(self): | 
| 138 cmd = [self.m.path.checkout('build', 'android', 'findbugs_diff.py')] | 150 cmd = [self.m.path.checkout('build', 'android', 'findbugs_diff.py')] | 
| 139 if self.c.INTERNAL: | 151 if self.c.INTERNAL: | 
| 140 cmd.extend( | 152 cmd.extend( | 
| 141 ['-b', | 153 ['-b', | 
| 142 self.m.path.checkout(self.internal_dir, 'bin', 'findbugs_filter'), | 154 self.m.path.checkout(self._internal_dir, 'bin', 'findbugs_filter'), | 
| 143 '-o', 'com.google.android.apps.chrome.-,org.chromium.-']) | 155 '-o', 'com.google.android.apps.chrome.-,org.chromium.-']) | 
| 144 | 156 return self.m.step('findbugs internal', cmd, env=self.get_env()) | 
| 145 return self.m.step('findbugs_internal', cmd, env=self.env) | |
| 146 | 157 | 
| 147 def checkdeps(self): | 158 def checkdeps(self): | 
| 148 return self.m.step( | 159 return self.m.step( | 
| 149 'checkdeps', | 160 'checkdeps', | 
| 150 [self.m.path.checkout('tools', 'checkdeps', 'checkdeps.py'), | 161 [self.m.path.checkout('tools', 'checkdeps', 'checkdeps.py'), | 
| 151 '--root=%s' % self.internal_dir], | 162 '--root=%s' % self._internal_dir], | 
| 152 env=self.env) | 163 env=self.get_env()) | 
| 153 | 164 | 
| 154 def lint(self): | 165 def lint(self): | 
| 155 if self.c.INTERNAL: | 166 if self.c.INTERNAL: | 
| 156 return self.m.step( | 167 return self.m.step( | 
| 157 'lint', | 168 'lint', | 
| 158 [self.m.path.checkout(self.internal_dir, 'bin', 'lint.py')], | 169 [self.m.path.checkout(self._internal_dir, 'bin', 'lint.py')], | 
| 159 env=self.env) | 170 env=self.get_env()) | 
| OLD | NEW |