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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 | 346 |
347 # How many times to try before giving up. | 347 # How many times to try before giving up. |
348 ATTEMPTS = 5 | 348 ATTEMPTS = 5 |
349 | 349 |
350 # Find deps2git | 350 # Find deps2git |
351 DEPS2GIT_DIR_PATH = path.join(SCRIPTS_DIR, 'tools', 'deps2git') | 351 DEPS2GIT_DIR_PATH = path.join(SCRIPTS_DIR, 'tools', 'deps2git') |
352 DEPS2GIT_PATH = path.join(DEPS2GIT_DIR_PATH, 'deps2git.py') | 352 DEPS2GIT_PATH = path.join(DEPS2GIT_DIR_PATH, 'deps2git.py') |
353 S2G_INTERNAL_PATH = path.join(SCRIPTS_DIR, 'tools', 'deps2git_internal', | 353 S2G_INTERNAL_PATH = path.join(SCRIPTS_DIR, 'tools', 'deps2git_internal', |
354 'svn_to_git_internal.py') | 354 'svn_to_git_internal.py') |
355 | |
356 # ../../cache_dir aka /b/build/slave/cache_dir | |
357 GIT_CACHE_PATH = path.join(DEPOT_TOOLS_DIR, 'git_cache.py') | 355 GIT_CACHE_PATH = path.join(DEPOT_TOOLS_DIR, 'git_cache.py') |
358 CACHE_DIR = path.join(SLAVE_DIR, 'cache_dir') | |
359 # Because we print CACHE_DIR out into a .gclient file, and then later run | |
360 # eval() on it, backslashes need to be escaped, otherwise "E:\b\build" gets | |
361 # parsed as "E:[\x08][\x08]uild". | |
362 if sys.platform.startswith('win'): | |
363 CACHE_DIR = CACHE_DIR.replace('\\', '\\\\') | |
364 | 356 |
365 # Find the patch tool. | 357 # Find the patch tool. |
366 if sys.platform.startswith('win'): | 358 if sys.platform.startswith('win'): |
367 if not BUILD_INTERNAL_DIR: | 359 if not BUILD_INTERNAL_DIR: |
368 print 'Warning: could not find patch tool because there is no ' | 360 print 'Warning: could not find patch tool because there is no ' |
369 print 'build_internal present.' | 361 print 'build_internal present.' |
370 PATCH_TOOL = None | 362 PATCH_TOOL = None |
371 else: | 363 else: |
372 PATCH_TOOL = path.join(BUILD_INTERNAL_DIR, 'tools', 'patch.EXE') | 364 PATCH_TOOL = path.join(BUILD_INTERNAL_DIR, 'tools', 'patch.EXE') |
373 else: | 365 else: |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 else: | 510 else: |
519 git_executable = 'git' | 511 git_executable = 'git' |
520 # On windows, subprocess doesn't fuzzy-match 'git' to 'git.bat', so we | 512 # On windows, subprocess doesn't fuzzy-match 'git' to 'git.bat', so we |
521 # have to do it explicitly. This is better than passing shell=True. | 513 # have to do it explicitly. This is better than passing shell=True. |
522 if sys.platform.startswith('win'): | 514 if sys.platform.startswith('win'): |
523 git_executable += '.bat' | 515 git_executable += '.bat' |
524 cmd = (git_executable,) + args | 516 cmd = (git_executable,) + args |
525 return call(*cmd, **kwargs) | 517 return call(*cmd, **kwargs) |
526 | 518 |
527 | 519 |
528 def get_gclient_spec(solutions, target_os, target_os_only): | 520 def get_gclient_spec(solutions, target_os, target_os_only, git_cache_dir): |
529 return GCLIENT_TEMPLATE % { | 521 return GCLIENT_TEMPLATE % { |
530 'solutions': pprint.pformat(solutions, indent=4), | 522 'solutions': pprint.pformat(solutions, indent=4), |
531 'cache_dir': '"%s"' % CACHE_DIR, | 523 'cache_dir': '"%s"' % git_cache_dir, |
532 'target_os': ('\ntarget_os=%s' % target_os) if target_os else '', | 524 'target_os': ('\ntarget_os=%s' % target_os) if target_os else '', |
533 'target_os_only': '\ntarget_os_only=%s' % target_os_only | 525 'target_os_only': '\ntarget_os_only=%s' % target_os_only |
534 } | 526 } |
535 | 527 |
536 | 528 |
537 def check_enabled(master, builder, slave): | 529 def check_enabled(master, builder, slave): |
538 if master in ENABLED_MASTERS: | 530 if master in ENABLED_MASTERS: |
539 return True | 531 return True |
540 builder_list = ENABLED_BUILDERS.get(master) | 532 builder_list = ENABLED_BUILDERS.get(master) |
541 if builder_list and builder in builder_list: | 533 if builder_list and builder in builder_list: |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 if scm_dirname != '*': | 685 if scm_dirname != '*': |
694 prefix = '%s detected in checkout, ' % scm_dirname | 686 prefix = '%s detected in checkout, ' % scm_dirname |
695 | 687 |
696 for filename in os.listdir(build_dir): | 688 for filename in os.listdir(build_dir): |
697 deletion_target = path.join(build_dir, filename) | 689 deletion_target = path.join(build_dir, filename) |
698 print '%sdeleting %s...' % (prefix, deletion_target), | 690 print '%sdeleting %s...' % (prefix, deletion_target), |
699 remove(deletion_target) | 691 remove(deletion_target) |
700 print 'done' | 692 print 'done' |
701 | 693 |
702 | 694 |
703 def gclient_configure(solutions, target_os, target_os_only): | 695 def gclient_configure(solutions, target_os, target_os_only, git_cache_dir): |
704 """Should do the same thing as gclient --spec='...'.""" | 696 """Should do the same thing as gclient --spec='...'.""" |
705 with codecs.open('.gclient', mode='w', encoding='utf-8') as f: | 697 with codecs.open('.gclient', mode='w', encoding='utf-8') as f: |
706 f.write(get_gclient_spec(solutions, target_os, target_os_only)) | 698 f.write(get_gclient_spec( |
| 699 solutions, target_os, target_os_only, git_cache_dir)) |
707 | 700 |
708 | 701 |
709 def gclient_sync(with_branch_heads, shallow): | 702 def gclient_sync(with_branch_heads, shallow): |
710 # We just need to allocate a filename. | 703 # We just need to allocate a filename. |
711 fd, gclient_output_file = tempfile.mkstemp(suffix='.json') | 704 fd, gclient_output_file = tempfile.mkstemp(suffix='.json') |
712 os.close(fd) | 705 os.close(fd) |
713 gclient_bin = 'gclient.bat' if sys.platform.startswith('win') else 'gclient' | 706 gclient_bin = 'gclient.bat' if sys.platform.startswith('win') else 'gclient' |
714 cmd = [gclient_bin, 'sync', '--verbose', '--reset', '--force', | 707 cmd = [gclient_bin, 'sync', '--verbose', '--reset', '--force', |
715 '--ignore_locks', '--output-json', gclient_output_file, | 708 '--ignore_locks', '--output-json', gclient_output_file, |
716 '--nohooks', '--noprehooks', '--delete_unversioned_trees'] | 709 '--nohooks', '--noprehooks', '--delete_unversioned_trees'] |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 last_known_deps_git_ref = _last_commit_for_file(deps_git_file, repo_base) | 828 last_known_deps_git_ref = _last_commit_for_file(deps_git_file, repo_base) |
836 merge_base_ref = git('merge-base', last_known_deps_ref, | 829 merge_base_ref = git('merge-base', last_known_deps_ref, |
837 last_known_deps_git_ref, cwd=repo_base).strip() | 830 last_known_deps_git_ref, cwd=repo_base).strip() |
838 | 831 |
839 # If the merge base of the last DEPS and last .DEPS.git file is not | 832 # If the merge base of the last DEPS and last .DEPS.git file is not |
840 # equivilent to the hash of the last DEPS file, that means the DEPS file | 833 # equivilent to the hash of the last DEPS file, that means the DEPS file |
841 # was committed after the last .DEPS.git file. | 834 # was committed after the last .DEPS.git file. |
842 return last_known_deps_ref != merge_base_ref | 835 return last_known_deps_ref != merge_base_ref |
843 | 836 |
844 | 837 |
845 def ensure_deps2git(solution, shallow): | 838 def ensure_deps2git(solution, shallow, git_cache_dir): |
846 repo_base = path.join(os.getcwd(), solution['name']) | 839 repo_base = path.join(os.getcwd(), solution['name']) |
847 deps_file = path.join(repo_base, 'DEPS') | 840 deps_file = path.join(repo_base, 'DEPS') |
848 deps_git_file = path.join(repo_base, '.DEPS.git') | 841 deps_git_file = path.join(repo_base, '.DEPS.git') |
849 if (not git('ls-files', 'DEPS', cwd=repo_base).strip() or | 842 if (not git('ls-files', 'DEPS', cwd=repo_base).strip() or |
850 not git('ls-files', '.DEPS.git', cwd=repo_base).strip()): | 843 not git('ls-files', '.DEPS.git', cwd=repo_base).strip()): |
851 return | 844 return |
852 | 845 |
853 print 'Checking if %s is newer than %s' % (deps_file, deps_git_file) | 846 print 'Checking if %s is newer than %s' % (deps_file, deps_git_file) |
854 if not need_to_run_deps2git(repo_base, deps_file, deps_git_file): | 847 if not need_to_run_deps2git(repo_base, deps_file, deps_git_file): |
855 return | 848 return |
856 | 849 |
857 print '===DEPS file modified, need to run deps2git===' | 850 print '===DEPS file modified, need to run deps2git===' |
858 cmd = [sys.executable, DEPS2GIT_PATH, | 851 cmd = [sys.executable, DEPS2GIT_PATH, |
859 '--workspace', os.getcwd(), | 852 '--workspace', os.getcwd(), |
860 '--cache_dir', CACHE_DIR, | 853 '--cache_dir', git_cache_dir, |
861 '--deps', deps_file, | 854 '--deps', deps_file, |
862 '--out', deps_git_file] | 855 '--out', deps_git_file] |
863 if 'chrome-internal.googlesource' in solution['url']: | 856 if 'chrome-internal.googlesource' in solution['url']: |
864 cmd.extend(['--extra-rules', S2G_INTERNAL_PATH]) | 857 cmd.extend(['--extra-rules', S2G_INTERNAL_PATH]) |
865 if shallow: | 858 if shallow: |
866 cmd.append('--shallow') | 859 cmd.append('--shallow') |
867 call(*cmd) | 860 call(*cmd) |
868 | 861 |
869 | 862 |
870 def emit_log_lines(name, lines): | 863 def emit_log_lines(name, lines): |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 # rev_num is really a svn revision number, convert it into a git hash. | 918 # rev_num is really a svn revision number, convert it into a git hash. |
926 git_ref = get_git_hash(int(revision), branch, folder_name) | 919 git_ref = get_git_hash(int(revision), branch, folder_name) |
927 else: | 920 else: |
928 # rev_num is actually a git hash or ref, we can just use it. | 921 # rev_num is actually a git hash or ref, we can just use it. |
929 git_ref = revision | 922 git_ref = revision |
930 git('checkout', '--force', git_ref, cwd=folder_name) | 923 git('checkout', '--force', git_ref, cwd=folder_name) |
931 else: | 924 else: |
932 ref = branch if branch.startswith('refs/') else 'origin/%s' % branch | 925 ref = branch if branch.startswith('refs/') else 'origin/%s' % branch |
933 git('checkout', '--force', ref, cwd=folder_name) | 926 git('checkout', '--force', ref, cwd=folder_name) |
934 | 927 |
935 def git_checkout(solutions, revisions, shallow, refs): | 928 def git_checkout(solutions, revisions, shallow, refs, git_cache_dir): |
936 build_dir = os.getcwd() | 929 build_dir = os.getcwd() |
937 # Before we do anything, break all git_cache locks. | 930 # Before we do anything, break all git_cache locks. |
938 if path.isdir(CACHE_DIR): | 931 if path.isdir(git_cache_dir): |
939 git('cache', 'unlock', '-vv', '--force', '--all', '--cache-dir', CACHE_DIR) | 932 git('cache', 'unlock', '-vv', '--force', '--all', |
940 for item in os.listdir(CACHE_DIR): | 933 '--cache-dir', git_cache_dir) |
941 filename = os.path.join(CACHE_DIR, item) | 934 for item in os.listdir(git_cache_dir): |
| 935 filename = os.path.join(git_cache_dir, item) |
942 if item.endswith('.lock'): | 936 if item.endswith('.lock'): |
943 raise Exception('%s exists after cache unlock' % filename) | 937 raise Exception('%s exists after cache unlock' % filename) |
944 first_solution = True | 938 first_solution = True |
945 for sln in solutions: | 939 for sln in solutions: |
946 # This is so we can loop back and try again if we need to wait for the | 940 # This is so we can loop back and try again if we need to wait for the |
947 # git mirrors to update from SVN. | 941 # git mirrors to update from SVN. |
948 done = False | 942 done = False |
949 tries_left = 60 | 943 tries_left = 60 |
950 while not done: | 944 while not done: |
951 name = sln['name'] | 945 name = sln['name'] |
952 url = sln['url'] | 946 url = sln['url'] |
953 if url == CHROMIUM_SRC_URL or url + '.git' == CHROMIUM_SRC_URL: | 947 if url == CHROMIUM_SRC_URL or url + '.git' == CHROMIUM_SRC_URL: |
954 # Experiments show there's little to be gained from | 948 # Experiments show there's little to be gained from |
955 # a shallow clone of src. | 949 # a shallow clone of src. |
956 shallow = False | 950 shallow = False |
957 sln_dir = path.join(build_dir, name) | 951 sln_dir = path.join(build_dir, name) |
958 s = ['--shallow'] if shallow else [] | 952 s = ['--shallow'] if shallow else [] |
959 populate_cmd = (['cache', 'populate', '--ignore_locks', '-v', | 953 populate_cmd = (['cache', 'populate', '--ignore_locks', '-v', |
960 '--cache-dir', CACHE_DIR] + s + [url]) | 954 '--cache-dir', git_cache_dir] + s + [url]) |
961 for ref in refs: | 955 for ref in refs: |
962 populate_cmd.extend(['--ref', ref]) | 956 populate_cmd.extend(['--ref', ref]) |
963 git(*populate_cmd) | 957 git(*populate_cmd) |
964 mirror_dir = git( | 958 mirror_dir = git( |
965 'cache', 'exists', '--quiet', '--cache-dir', CACHE_DIR, url).strip() | 959 'cache', 'exists', '--quiet', |
| 960 '--cache-dir', git_cache_dir, url).strip() |
966 clone_cmd = ( | 961 clone_cmd = ( |
967 'clone', '--no-checkout', '--local', '--shared', mirror_dir, sln_dir) | 962 'clone', '--no-checkout', '--local', '--shared', mirror_dir, sln_dir) |
968 | 963 |
969 try: | 964 try: |
970 if not path.isdir(sln_dir): | 965 if not path.isdir(sln_dir): |
971 git(*clone_cmd) | 966 git(*clone_cmd) |
972 else: | 967 else: |
973 git('remote', 'set-url', 'origin', mirror_dir, cwd=sln_dir) | 968 git('remote', 'set-url', 'origin', mirror_dir, cwd=sln_dir) |
974 git('fetch', 'origin', cwd=sln_dir) | 969 git('fetch', 'origin', cwd=sln_dir) |
975 for ref in refs: | 970 for ref in refs: |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 continue | 1288 continue |
1294 # TODO(hinoka): Catch SVNRevisionNotFound error maybe? | 1289 # TODO(hinoka): Catch SVNRevisionNotFound error maybe? |
1295 git('fetch', 'origin', cwd=deps_name) | 1290 git('fetch', 'origin', cwd=deps_name) |
1296 force_revision(deps_name, revision) | 1291 force_revision(deps_name, revision) |
1297 | 1292 |
1298 | 1293 |
1299 def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, | 1294 def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, |
1300 patch_root, issue, patchset, patch_url, rietveld_server, | 1295 patch_root, issue, patchset, patch_url, rietveld_server, |
1301 gerrit_repo, gerrit_ref, revision_mapping, | 1296 gerrit_repo, gerrit_ref, revision_mapping, |
1302 apply_issue_email_file, apply_issue_key_file, buildspec, | 1297 apply_issue_email_file, apply_issue_key_file, buildspec, |
1303 gyp_env, shallow, runhooks, refs): | 1298 gyp_env, shallow, runhooks, refs, git_cache_dir): |
1304 # Get a checkout of each solution, without DEPS or hooks. | 1299 # Get a checkout of each solution, without DEPS or hooks. |
1305 # Calling git directly because there is no way to run Gclient without | 1300 # Calling git directly because there is no way to run Gclient without |
1306 # invoking DEPS. | 1301 # invoking DEPS. |
1307 print 'Fetching Git checkout' | 1302 print 'Fetching Git checkout' |
1308 | 1303 |
1309 git_ref = git_checkout(solutions, revisions, shallow, refs) | 1304 git_ref = git_checkout(solutions, revisions, shallow, refs, git_cache_dir) |
1310 | 1305 |
1311 patches = None | 1306 patches = None |
1312 if patch_url: | 1307 if patch_url: |
1313 patches = get_svn_patch(patch_url) | 1308 patches = get_svn_patch(patch_url) |
1314 | 1309 |
1315 already_patched = [] | 1310 already_patched = [] |
1316 patch_root = patch_root or '' | 1311 patch_root = patch_root or '' |
1317 for solution in solutions: | 1312 for solution in solutions: |
1318 if (patch_root == solution['name'] or | 1313 if (patch_root == solution['name'] or |
1319 solution['name'].startswith(patch_root + '/')): | 1314 solution['name'].startswith(patch_root + '/')): |
1320 relative_root = solution['name'][len(patch_root) + 1:] | 1315 relative_root = solution['name'][len(patch_root) + 1:] |
1321 target = '/'.join([relative_root, 'DEPS']).lstrip('/') | 1316 target = '/'.join([relative_root, 'DEPS']).lstrip('/') |
1322 if patches: | 1317 if patches: |
1323 apply_svn_patch(patch_root, patches, whitelist=[target]) | 1318 apply_svn_patch(patch_root, patches, whitelist=[target]) |
1324 already_patched.append(target) | 1319 already_patched.append(target) |
1325 elif issue: | 1320 elif issue: |
1326 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, | 1321 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, |
1327 revision_mapping, git_ref, apply_issue_email_file, | 1322 revision_mapping, git_ref, apply_issue_email_file, |
1328 apply_issue_key_file, whitelist=[target]) | 1323 apply_issue_key_file, whitelist=[target]) |
1329 already_patched.append(target) | 1324 already_patched.append(target) |
1330 | 1325 |
1331 if not buildspec: | 1326 if not buildspec: |
1332 # Run deps2git if there is a DEPS change after the last .DEPS.git commit. | 1327 # Run deps2git if there is a DEPS change after the last .DEPS.git commit. |
1333 for solution in solutions: | 1328 for solution in solutions: |
1334 ensure_deps2git(solution, shallow) | 1329 ensure_deps2git(solution, shallow, git_cache_dir) |
1335 | 1330 |
1336 # Ensure our build/ directory is set up with the correct .gclient file. | 1331 # Ensure our build/ directory is set up with the correct .gclient file. |
1337 gclient_configure(solutions, target_os, target_os_only) | 1332 gclient_configure(solutions, target_os, target_os_only, git_cache_dir) |
1338 | 1333 |
1339 # Let gclient do the DEPS syncing. | 1334 # Let gclient do the DEPS syncing. |
1340 # The branch-head refspec is a special case because its possible Chrome | 1335 # The branch-head refspec is a special case because its possible Chrome |
1341 # src, which contains the branch-head refspecs, is DEPSed in. | 1336 # src, which contains the branch-head refspecs, is DEPSed in. |
1342 gclient_output = gclient_sync(buildspec or BRANCH_HEADS_REFSPEC in refs, | 1337 gclient_output = gclient_sync(buildspec or BRANCH_HEADS_REFSPEC in refs, |
1343 shallow) | 1338 shallow) |
1344 | 1339 |
1345 # Now that gclient_sync has finished, we should revert any .DEPS.git so that | 1340 # Now that gclient_sync has finished, we should revert any .DEPS.git so that |
1346 # presubmit doesn't complain about it being modified. | 1341 # presubmit doesn't complain about it being modified. |
1347 if (not buildspec and | 1342 if (not buildspec and |
(...skipping 16 matching lines...) Expand all Loading... |
1364 elif issue: | 1359 elif issue: |
1365 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, | 1360 apply_rietveld_issue(issue, patchset, patch_root, rietveld_server, |
1366 revision_mapping, git_ref, apply_issue_email_file, | 1361 revision_mapping, git_ref, apply_issue_email_file, |
1367 apply_issue_key_file, blacklist=already_patched) | 1362 apply_issue_key_file, blacklist=already_patched) |
1368 elif gerrit_ref: | 1363 elif gerrit_ref: |
1369 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root) | 1364 apply_gerrit_ref(gerrit_repo, gerrit_ref, patch_root) |
1370 | 1365 |
1371 # Reset the deps_file point in the solutions so that hooks get run properly. | 1366 # Reset the deps_file point in the solutions so that hooks get run properly. |
1372 for sln in solutions: | 1367 for sln in solutions: |
1373 sln['deps_file'] = sln.get('deps_file', 'DEPS').replace('.DEPS.git', 'DEPS') | 1368 sln['deps_file'] = sln.get('deps_file', 'DEPS').replace('.DEPS.git', 'DEPS') |
1374 gclient_configure(solutions, target_os, target_os_only) | 1369 gclient_configure(solutions, target_os, target_os_only, git_cache_dir) |
1375 | 1370 |
1376 return gclient_output | 1371 return gclient_output |
1377 | 1372 |
1378 | 1373 |
1379 def parse_revisions(revisions, root): | 1374 def parse_revisions(revisions, root): |
1380 """Turn a list of revision specs into a nice dictionary. | 1375 """Turn a list of revision specs into a nice dictionary. |
1381 | 1376 |
1382 We will always return a dict with {root: something}. By default if root | 1377 We will always return a dict with {root: something}. By default if root |
1383 is unspecified, or if revisions is [], then revision will be assigned 'HEAD' | 1378 is unspecified, or if revisions is [], then revision will be assigned 'HEAD' |
1384 """ | 1379 """ |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 help='Bypass disk detection and never shallow clone. ' | 1482 help='Bypass disk detection and never shallow clone. ' |
1488 'Does not override the --shallow flag') | 1483 'Does not override the --shallow flag') |
1489 parse.add_option('--no_runhooks', action='store_true', | 1484 parse.add_option('--no_runhooks', action='store_true', |
1490 help='Do not run hooks on official builder.') | 1485 help='Do not run hooks on official builder.') |
1491 parse.add_option('--refs', action='append', | 1486 parse.add_option('--refs', action='append', |
1492 help='Also fetch this refspec for the main solution(s). ' | 1487 help='Also fetch this refspec for the main solution(s). ' |
1493 'Eg. +refs/branch-heads/*') | 1488 'Eg. +refs/branch-heads/*') |
1494 parse.add_option('--with_branch_heads', action='store_true', | 1489 parse.add_option('--with_branch_heads', action='store_true', |
1495 help='Always pass --with_branch_heads to gclient. This ' | 1490 help='Always pass --with_branch_heads to gclient. This ' |
1496 'does the same thing as --refs +refs/branch-heads/*') | 1491 'does the same thing as --refs +refs/branch-heads/*') |
| 1492 parse.add_option('--git-cache-dir', default=path.join(SLAVE_DIR, 'cache_dir'), |
| 1493 help='Path to git cache directory.') |
1497 | 1494 |
1498 | 1495 |
1499 options, args = parse.parse_args() | 1496 options, args = parse.parse_args() |
1500 | 1497 |
1501 if not options.refs: | 1498 if not options.refs: |
1502 options.refs = [] | 1499 options.refs = [] |
1503 | 1500 |
1504 if options.with_branch_heads: | 1501 if options.with_branch_heads: |
1505 options.refs.append(BRANCH_HEADS_REFSPEC) | 1502 options.refs.append(BRANCH_HEADS_REFSPEC) |
1506 del options.with_branch_heads | 1503 del options.with_branch_heads |
1507 | 1504 |
1508 try: | 1505 try: |
1509 if options.revision_mapping_file: | 1506 if options.revision_mapping_file: |
1510 if options.revision_mapping: | 1507 if options.revision_mapping: |
1511 print ('WARNING: Ignoring --revision_mapping: --revision_mapping_file ' | 1508 print ('WARNING: Ignoring --revision_mapping: --revision_mapping_file ' |
1512 'was set at the same time as --revision_mapping?') | 1509 'was set at the same time as --revision_mapping?') |
1513 with open(options.revision_mapping_file, 'r') as f: | 1510 with open(options.revision_mapping_file, 'r') as f: |
1514 options.revision_mapping = json.load(f) | 1511 options.revision_mapping = json.load(f) |
1515 elif options.revision_mapping: | 1512 elif options.revision_mapping: |
1516 options.revision_mapping = json.loads(options.revision_mapping) | 1513 options.revision_mapping = json.loads(options.revision_mapping) |
1517 except Exception as e: | 1514 except Exception as e: |
1518 print ( | 1515 print ( |
1519 'WARNING: Caught execption while parsing revision_mapping*: %s' | 1516 'WARNING: Caught execption while parsing revision_mapping*: %s' |
1520 % (str(e),) | 1517 % (str(e),) |
1521 ) | 1518 ) |
1522 | 1519 |
| 1520 # Because we print CACHE_DIR out into a .gclient file, and then later run |
| 1521 # eval() on it, backslashes need to be escaped, otherwise "E:\b\build" gets |
| 1522 # parsed as "E:[\x08][\x08]uild". |
| 1523 if sys.platform.startswith('win'): |
| 1524 options.git_cache_dir = options.git_cache_dir.replace('\\', '\\\\') |
| 1525 |
1523 return options, args | 1526 return options, args |
1524 | 1527 |
1525 | 1528 |
1526 def prepare(options, git_slns, active): | 1529 def prepare(options, git_slns, active): |
1527 """Prepares the target folder before we checkout.""" | 1530 """Prepares the target folder before we checkout.""" |
1528 dir_names = [sln.get('name') for sln in git_slns if 'name' in sln] | 1531 dir_names = [sln.get('name') for sln in git_slns if 'name' in sln] |
1529 # If we're active now, but the flag file doesn't exist (we weren't active | 1532 # If we're active now, but the flag file doesn't exist (we weren't active |
1530 # last run) or vice versa, blow away all checkouts. | 1533 # last run) or vice versa, blow away all checkouts. |
1531 if bool(active) != bool(check_flag(options.flag_file)): | 1534 if bool(active) != bool(check_flag(options.flag_file)): |
1532 ensure_no_checkout(dir_names, '*') | 1535 ensure_no_checkout(dir_names, '*') |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 apply_issue_email_file=options.apply_issue_email_file, | 1601 apply_issue_email_file=options.apply_issue_email_file, |
1599 apply_issue_key_file=options.apply_issue_key_file, | 1602 apply_issue_key_file=options.apply_issue_key_file, |
1600 | 1603 |
1601 # For official builders. | 1604 # For official builders. |
1602 buildspec=buildspec, | 1605 buildspec=buildspec, |
1603 gyp_env=options.gyp_env, | 1606 gyp_env=options.gyp_env, |
1604 runhooks=not options.no_runhooks, | 1607 runhooks=not options.no_runhooks, |
1605 | 1608 |
1606 # Finally, extra configurations such as shallowness of the clone. | 1609 # Finally, extra configurations such as shallowness of the clone. |
1607 shallow=options.shallow, | 1610 shallow=options.shallow, |
1608 refs=options.refs) | 1611 refs=options.refs, |
| 1612 git_cache_dir=options.git_cache_dir) |
1609 gclient_output = ensure_checkout(**checkout_parameters) | 1613 gclient_output = ensure_checkout(**checkout_parameters) |
1610 except GclientSyncFailed: | 1614 except GclientSyncFailed: |
1611 print 'We failed gclient sync, lets delete the checkout and retry.' | 1615 print 'We failed gclient sync, lets delete the checkout and retry.' |
1612 ensure_no_checkout(dir_names, '*') | 1616 ensure_no_checkout(dir_names, '*') |
1613 gclient_output = ensure_checkout(**checkout_parameters) | 1617 gclient_output = ensure_checkout(**checkout_parameters) |
1614 except PatchFailed as e: | 1618 except PatchFailed as e: |
1615 if options.output_json: | 1619 if options.output_json: |
1616 # Tell recipes information such as root, got_revision, etc. | 1620 # Tell recipes information such as root, got_revision, etc. |
1617 emit_json(options.output_json, | 1621 emit_json(options.output_json, |
1618 did_run=True, | 1622 did_run=True, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 except Exception: | 1748 except Exception: |
1745 # Unexpected failure. | 1749 # Unexpected failure. |
1746 emit_flag(options.flag_file) | 1750 emit_flag(options.flag_file) |
1747 raise | 1751 raise |
1748 else: | 1752 else: |
1749 emit_flag(options.flag_file) | 1753 emit_flag(options.flag_file) |
1750 | 1754 |
1751 | 1755 |
1752 if __name__ == '__main__': | 1756 if __name__ == '__main__': |
1753 sys.exit(main()) | 1757 sys.exit(main()) |
OLD | NEW |