Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import os | |
| 6 | |
| 7 try: | |
| 8 import json # pylint: disable=F0401 | |
| 9 except ImportError: | |
| 10 import simplejson as json | |
| 11 | |
| 12 def readDepsFile(deps_file_path): | |
| 13 class FileImplStub(object): | |
| 14 def __init__(self, file_location): | |
| 15 pass | |
| 16 | |
| 17 @staticmethod | |
| 18 def GetPath(): | |
| 19 return '' | |
| 20 | |
| 21 @staticmethod | |
| 22 def GetFilename(): | |
| 23 return '' | |
| 24 | |
| 25 @staticmethod | |
| 26 def GetRevision(): | |
| 27 return None | |
| 28 | |
| 29 def FromStub(__, _=None): | |
| 30 return '' | |
| 31 | |
| 32 class VarImpl(object): | |
| 33 def __init__(self, custom_vars, local_scope): | |
| 34 self._custom_vars = custom_vars | |
| 35 self._local_scope = local_scope | |
| 36 | |
| 37 def Lookup(self, var_name): | |
| 38 """Implements the Var syntax.""" | |
| 39 if var_name in self._custom_vars: | |
| 40 return self._custom_vars[var_name] | |
| 41 elif var_name in self._local_scope.get("vars", {}): | |
| 42 return self._local_scope["vars"][var_name] | |
| 43 raise Exception("Var is not defined: %s" % var_name) | |
| 44 | |
| 45 local_scope = {} | |
| 46 var = VarImpl({}, local_scope) | |
| 47 global_scope = { | |
| 48 'File': FileImplStub, | |
| 49 'From': FromStub, | |
| 50 'Var': var.Lookup, | |
| 51 'deps_os': {}, | |
| 52 } | |
| 53 execfile(deps_file_path, global_scope, local_scope) | |
| 54 deps = local_scope.get('deps', {}) | |
| 55 deps_os = local_scope.get('deps_os', {}) | |
| 56 for os_specific_deps in deps_os.itervalues(): | |
| 57 deps.update(os_specific_deps) | |
| 58 return deps.keys() | |
| 59 | |
| 60 def readWhitelistFile(whitelist_file_path): | |
| 61 whitelisted_deps = open(whitelist_file_path).readlines() | |
| 62 def ignore_filter(line): | |
| 63 return (not line.startswith('#') and line) | |
| 64 return filter(ignore_filter, map(str.strip, whitelisted_deps)) | |
| 65 | |
| 66 def depsBlacklist(deps_file_path, whitelist_file_path): | |
| 67 all_deps = readDepsFile(deps_file_path) | |
| 68 whitelisted_deps = readWhitelistFile(whitelist_file_path) | |
| 69 deps_blacklist = set(all_deps).difference(set(whitelisted_deps)) | |
| 70 return dict(map(lambda(x): (x, None), deps_blacklist)) | |
| 71 | |
| 72 def GetFactoryProperties(api, factory_properties, build_properties): | |
| 73 android_repo_url = factory_properties.get('android_repo_url') | |
| 74 android_repo_sync_flags = factory_properties.get('android_repo_sync_flags', | |
| 75 ['-j16', '-d', '-f']) | |
| 76 android_repo_resync_projects = factory_properties.get( | |
| 77 'android_repo_resync_projects') | |
| 78 android_repo_branch = factory_properties.get('android_repo_branch') | |
| 79 android_ndk_pin_revision = factory_properties.get('android_ndk_pin_revision') | |
| 80 | |
| 81 android_lunch_flavor = 'full-eng' | |
| 82 android_slave_subfolder = 'android-src' | |
| 83 android_slave_build_path = api.slave_build_path(android_slave_subfolder) | |
| 84 android_slave_out_path = api.slave_build_path(android_slave_subfolder, 'out') | |
| 85 chromium_in_android_subpath = 'external/chromium_org' | |
| 86 chromium_in_android_path = api.slave_build_path(android_slave_subfolder, | |
| 87 chromium_in_android_subpath) | |
| 88 | |
| 89 steps = api.Steps(build_properties) | |
| 90 steps.use_mirror = False | |
| 91 | |
| 92 # This depends on __str__ being run delayed (at the time the command is about | |
| 93 # to be executred, not at the time the command stream is generated). | |
| 94 # TODO: better way? | |
| 95 class TrimmedDepsSpec(object): | |
|
mkosiba (inactive)
2013/05/07 13:30:19
would like feedback on this. Is it OK to implement
| |
| 96 def __init__(self): | |
| 97 pass | |
| 98 | |
| 99 def __str__(self): | |
| 100 custom_deps = depsBlacklist( | |
| 101 api.slave_build_path('src', 'DEPS'), | |
| 102 api.slave_build_path('src2', 'android_webview', 'buildbot', | |
| 103 'deps_whitelist')) | |
| 104 trimmed_spec = { | |
| 105 'solutions': [{ | |
| 106 'name' : 'src', | |
| 107 'url' : steps.ChromiumSvnURL('chrome', 'trunk', 'src'), | |
| 108 'safesync_url': '', | |
| 109 'custom_deps': custom_deps, | |
| 110 }], | |
| 111 'target_os': ['android'], | |
| 112 } | |
| 113 return json.dumps(trimmed_spec) | |
| 114 | |
| 115 with_lunch_command = [api.slave_build_path('src2', 'android_webview', | |
| 116 'buildbot', 'with_lunch'), | |
| 117 android_slave_build_path, | |
| 118 android_lunch_flavor] | |
| 119 | |
| 120 # For the android_webview AOSP build we want to only include whitelisted | |
| 121 # DEPS. This is to detect the addition of unexpected new deps to the webview. | |
| 122 spec = { | |
| 123 'solutions': [{ | |
| 124 'name' : 'src', | |
| 125 'url' : steps.ChromiumSvnURL('chrome', 'trunk', 'src'), | |
| 126 'deps_file': '', | |
| 127 'safesync_url': '', | |
| 128 }], | |
| 129 'target_os': ['android'], | |
| 130 } | |
| 131 | |
| 132 sync_with_trimmed_deps_step = [ | |
| 133 steps.step('sync with trimmed deps', | |
| 134 [api.build_path('scripts', 'slave', 'annotated_checkout.py'), | |
| 135 '--type', 'gclient', | |
| 136 '--spec', TrimmedDepsSpec()]), | |
| 137 ] | |
| 138 | |
| 139 # The version of repo checked into depot_tools doesn't support switching | |
| 140 # between branches correctly due to | |
| 141 # https://code.google.com/p/git-repo/issues/detail?id=46 which is why we need | |
| 142 # to take care to init repo only once. | |
| 143 repo_init_once_step = [] | |
| 144 if not os.path.exists(android_slave_build_path): | |
| 145 repo_init_once_step.append( | |
| 146 steps.step('mkdir android source root', | |
| 147 ['mkdir', android_slave_subfolder], | |
| 148 cwd=api.SLAVE_BUILD_ROOT)) | |
| 149 | |
| 150 if not os.path.exists(api.slave_build_path(android_slave_subfolder, '.repo')): | |
| 151 repo_init_once_step.append( | |
| 152 steps.step('repo init', [ | |
| 153 api.depot_tools_path('repo'), | |
| 154 'init', | |
| 155 '-u', android_repo_url, | |
| 156 '-b', android_repo_branch], | |
| 157 cwd=android_slave_build_path)) | |
| 158 | |
| 159 repo_sync_step = [ | |
| 160 steps.step('repo sync', | |
| 161 [api.depot_tools_path('repo'), 'sync'] + android_repo_sync_flags, | |
| 162 cwd=android_slave_build_path), | |
| 163 ] | |
| 164 | |
| 165 local_manifest_ndk_pin_revision = [] | |
| 166 if android_ndk_pin_revision: | |
| 167 local_manifest_ndk_pin_revision = ['--ndk-revision', | |
| 168 android_ndk_pin_revision] | |
| 169 local_manifest_ndk_pin_revision = ['--ndk-revision', | |
| 170 android_ndk_pin_revision] | |
| 171 generate_local_manifest_step = [ | |
| 172 steps.step('generate local manifest', [ | |
| 173 api.slave_build_path( | |
| 174 'src2', 'android_webview', 'buildbot', | |
| 175 'generate_local_manifest.py'), | |
| 176 android_slave_build_path, chromium_in_android_subpath] + | |
| 177 local_manifest_ndk_pin_revision), | |
| 178 steps.step('repo re-sync', [api.depot_tools_path('repo'), 'sync', '-l'], | |
| 179 cwd=android_slave_build_path), | |
| 180 ] | |
| 181 | |
| 182 # If the repo sync flag override specifies a smart sync manifest, then this | |
| 183 # makes it possible to sync specific projects past the smart sync manifest | |
| 184 # to the most up-to-date version. | |
| 185 android_repo_resync_projects_step = [] | |
| 186 if android_repo_resync_projects: | |
| 187 for project in android_repo_resync_projects: | |
| 188 android_repo_resync_projects_step.append( | |
| 189 steps.step('repo re-sync project ' + project, | |
| 190 [api.depot_tools_path('repo'), 'sync', project], | |
| 191 cwd=android_slave_build_path)) | |
| 192 | |
| 193 | |
| 194 remove_potentially_stale_android_chromium_org = [] | |
| 195 if os.path.exists(chromium_in_android_path): | |
| 196 remove_potentially_stale_android_chromium_org = [ | |
| 197 steps.step('remove potentially stale chromium_org', | |
| 198 ['rm', '-rf', chromium_in_android_path]), | |
| 199 ] | |
| 200 | |
| 201 symlink_chromium_into_android_tree_step = [ | |
| 202 steps.step('symlink chromium source into android tree', | |
| 203 ['ln', '-s', api.slave_build_path('src'), | |
| 204 chromium_in_android_path]), | |
| 205 ] | |
| 206 | |
| 207 gyp_webview_step = [ | |
| 208 steps.step('gyp_webview', with_lunch_command + [ | |
| 209 api.slave_build_path( | |
| 210 android_slave_subfolder, 'external', 'chromium_org', | |
| 211 'android_webview', 'tools', 'gyp_webview')], | |
| 212 cwd=chromium_in_android_path), | |
| 213 ] | |
| 214 | |
| 215 # The Android.mk build system handles deps differently than the 'regular' | |
| 216 # Chromium makefiles which can lead to targets not being rebuilt. | |
| 217 # Fixing this is actually quite hard so we make this bot always clobber. | |
| 218 clobber_step = [ | |
| 219 steps.step('clobber', ['rm', '-rf', android_slave_out_path]), | |
| 220 ] | |
| 221 | |
| 222 compile_compiler_option = [] | |
| 223 if os.path.exists(api.build_path('goma')): | |
| 224 compile_compiler_option = ['--compiler', 'goma', | |
| 225 '--goma-dir', api.build_path('goma')] | |
| 226 compile_step = [ | |
| 227 steps.step('compile', with_lunch_command + | |
| 228 [api.build_path('scripts', 'slave', 'compile.py'), | |
| 229 'libwebviewchromium', 'android_webview_java', | |
| 230 '--build-dir', api.slave_build_path(), | |
| 231 '--src-dir', android_slave_build_path, | |
| 232 '--target-output-dir', android_slave_out_path, | |
| 233 '--build-tool', 'make-android', | |
| 234 '--verbose'] + compile_compiler_option, | |
| 235 cwd=api.SLAVE_BUILD_ROOT), | |
| 236 ] | |
| 237 | |
| 238 return { | |
| 239 'checkout': 'gclient', | |
| 240 'gclient_spec': spec, | |
| 241 'steps': ( | |
| 242 sync_with_trimmed_deps_step + | |
| 243 repo_init_once_step + | |
| 244 repo_sync_step + generate_local_manifest_step + | |
| 245 remove_potentially_stale_android_chromium_org + | |
| 246 symlink_chromium_into_android_tree_step + | |
| 247 gyp_webview_step + | |
| 248 clobber_step + | |
| 249 compile_step | |
| 250 ), | |
| 251 } | |
| 252 | |
| OLD | NEW |