OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # TODO(hinoka): Use logging. | 6 # TODO(hinoka): Use logging. |
7 | 7 |
8 import cStringIO | 8 import cStringIO |
9 import codecs | 9 import codecs |
10 import collections | 10 import collections |
(...skipping 24 matching lines...) Expand all Loading... |
35 # Relative to the current working directory. | 35 # Relative to the current working directory. |
36 CURRENT_DIR = path.abspath(os.getcwd()) | 36 CURRENT_DIR = path.abspath(os.getcwd()) |
37 BUILDER_DIR = path.dirname(CURRENT_DIR) | 37 BUILDER_DIR = path.dirname(CURRENT_DIR) |
38 SLAVE_DIR = path.dirname(BUILDER_DIR) | 38 SLAVE_DIR = path.dirname(BUILDER_DIR) |
39 | 39 |
40 # Relative to this script's filesystem path. | 40 # Relative to this script's filesystem path. |
41 THIS_DIR = path.dirname(path.abspath(__file__)) | 41 THIS_DIR = path.dirname(path.abspath(__file__)) |
42 SCRIPTS_DIR = path.dirname(THIS_DIR) | 42 SCRIPTS_DIR = path.dirname(THIS_DIR) |
43 BUILD_DIR = path.dirname(SCRIPTS_DIR) | 43 BUILD_DIR = path.dirname(SCRIPTS_DIR) |
44 ROOT_DIR = path.dirname(BUILD_DIR) | 44 ROOT_DIR = path.dirname(BUILD_DIR) |
45 BUILD_INTERNAL_DIR = path.join(ROOT_DIR, 'build_internal') | |
46 DEPOT_TOOLS_DIR = path.join(ROOT_DIR, 'depot_tools') | 45 DEPOT_TOOLS_DIR = path.join(ROOT_DIR, 'depot_tools') |
47 | 46 |
| 47 # TODO(luqui): This is a horrible hack to identify build_internal when build |
| 48 # is a recipe dependency. bot_update should not be depending on internal, |
| 49 # rather the arrow should go the other way (or just be destroyed). |
| 50 def check_build_internal(d): |
| 51 d = path.abspath(d) |
| 52 if path.basename(d) == 'build_internal' and path.isdir(d): |
| 53 return d |
| 54 else: |
| 55 return None |
| 56 |
| 57 BUILD_INTERNAL_DIR = ( |
| 58 check_build_internal(path.join(ROOT_DIR, 'build_internal')) or |
| 59 check_build_internal(path.join(ROOT_DIR, # .recipe_deps |
| 60 path.pardir, # slave |
| 61 path.pardir, # scripts |
| 62 path.pardir))) # build_internal |
| 63 |
48 | 64 |
49 CHROMIUM_GIT_HOST = 'https://chromium.googlesource.com' | 65 CHROMIUM_GIT_HOST = 'https://chromium.googlesource.com' |
50 CHROMIUM_SRC_URL = CHROMIUM_GIT_HOST + '/chromium/src.git' | 66 CHROMIUM_SRC_URL = CHROMIUM_GIT_HOST + '/chromium/src.git' |
51 | 67 |
52 # Official builds use buildspecs, so this is a special case. | 68 # Official builds use buildspecs, so this is a special case. |
53 BUILDSPEC_TYPE = collections.namedtuple('buildspec', | 69 BUILDSPEC_TYPE = collections.namedtuple('buildspec', |
54 ('container', 'version')) | 70 ('container', 'version')) |
55 BUILDSPEC_RE = (r'^/chrome-internal/trunk/tools/buildspec/' | 71 BUILDSPEC_RE = (r'^/chrome-internal/trunk/tools/buildspec/' |
56 '(build|branches|releases)/(.+)$') | 72 '(build|branches|releases)/(.+)$') |
57 GIT_BUILDSPEC_PATH = ('https://chrome-internal.googlesource.com/chrome/tools/' | 73 GIT_BUILDSPEC_PATH = ('https://chrome-internal.googlesource.com/chrome/tools/' |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 196 |
181 GCLIENT_TEMPLATE = """solutions = %(solutions)s | 197 GCLIENT_TEMPLATE = """solutions = %(solutions)s |
182 | 198 |
183 cache_dir = r%(cache_dir)s | 199 cache_dir = r%(cache_dir)s |
184 %(target_os)s | 200 %(target_os)s |
185 %(target_os_only)s | 201 %(target_os_only)s |
186 """ | 202 """ |
187 | 203 |
188 | 204 |
189 internal_data = {} | 205 internal_data = {} |
190 if os.path.isdir(BUILD_INTERNAL_DIR): | 206 if BUILD_INTERNAL_DIR: |
191 local_vars = {} | 207 local_vars = {} |
192 try: | 208 try: |
193 execfile(os.path.join( | 209 execfile(os.path.join( |
194 BUILD_INTERNAL_DIR, 'scripts', 'slave', 'bot_update_cfg.py'), | 210 BUILD_INTERNAL_DIR, 'scripts', 'slave', 'bot_update_cfg.py'), |
195 local_vars) | 211 local_vars) |
196 except Exception: | 212 except Exception: |
197 # Same as if BUILD_INTERNAL_DIR didn't exist in the first place. | 213 # Same as if BUILD_INTERNAL_DIR didn't exist in the first place. |
198 print 'Warning: unable to read internal configuration file.' | 214 print 'Warning: unable to read internal configuration file.' |
199 print 'If this is an internal bot, this step may be erroneously inactive.' | 215 print 'If this is an internal bot, this step may be erroneously inactive.' |
200 internal_data = local_vars | 216 internal_data = local_vars |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 GIT_CACHE_PATH = path.join(DEPOT_TOOLS_DIR, 'git_cache.py') | 325 GIT_CACHE_PATH = path.join(DEPOT_TOOLS_DIR, 'git_cache.py') |
310 CACHE_DIR = path.join(SLAVE_DIR, 'cache_dir') | 326 CACHE_DIR = path.join(SLAVE_DIR, 'cache_dir') |
311 # Because we print CACHE_DIR out into a .gclient file, and then later run | 327 # Because we print CACHE_DIR out into a .gclient file, and then later run |
312 # eval() on it, backslashes need to be escaped, otherwise "E:\b\build" gets | 328 # eval() on it, backslashes need to be escaped, otherwise "E:\b\build" gets |
313 # parsed as "E:[\x08][\x08]uild". | 329 # parsed as "E:[\x08][\x08]uild". |
314 if sys.platform.startswith('win'): | 330 if sys.platform.startswith('win'): |
315 CACHE_DIR = CACHE_DIR.replace('\\', '\\\\') | 331 CACHE_DIR = CACHE_DIR.replace('\\', '\\\\') |
316 | 332 |
317 # Find the patch tool. | 333 # Find the patch tool. |
318 if sys.platform.startswith('win'): | 334 if sys.platform.startswith('win'): |
319 PATCH_TOOL = path.join(BUILD_INTERNAL_DIR, 'tools', 'patch.EXE') | 335 if not BUILD_INTERNAL_DIR: |
| 336 print 'Warning: could not find patch tool because there is no ' |
| 337 print 'build_internal present.' |
| 338 PATCH_TOOL = None |
| 339 else: |
| 340 PATCH_TOOL = path.join(BUILD_INTERNAL_DIR, 'tools', 'patch.EXE') |
320 else: | 341 else: |
321 PATCH_TOOL = '/usr/bin/patch' | 342 PATCH_TOOL = '/usr/bin/patch' |
322 | 343 |
323 # If there is less than 100GB of disk space on the system, then we do | 344 # If there is less than 100GB of disk space on the system, then we do |
324 # a shallow checkout. | 345 # a shallow checkout. |
325 SHALLOW_CLONE_THRESHOLD = 100 * 1024 * 1024 * 1024 | 346 SHALLOW_CLONE_THRESHOLD = 100 * 1024 * 1024 * 1024 |
326 | 347 |
327 | 348 |
328 class SubprocessFailed(Exception): | 349 class SubprocessFailed(Exception): |
329 def __init__(self, message, code, output): | 350 def __init__(self, message, code, output): |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 except Exception: | 1690 except Exception: |
1670 # Unexpected failure. | 1691 # Unexpected failure. |
1671 emit_flag(options.flag_file) | 1692 emit_flag(options.flag_file) |
1672 raise | 1693 raise |
1673 else: | 1694 else: |
1674 emit_flag(options.flag_file) | 1695 emit_flag(options.flag_file) |
1675 | 1696 |
1676 | 1697 |
1677 if __name__ == '__main__': | 1698 if __name__ == '__main__': |
1678 sys.exit(main()) | 1699 sys.exit(main()) |
OLD | NEW |