Skip to content

Commit d2e032e

Browse files
committed
Move from archive to reference for local git repos to save space
1 parent 99abb09 commit d2e032e

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

build_ocaml_hash.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
parser.add_argument('basedir', type=str, help='location to put the source and the build')
1212
parser.add_argument('--configure_args', type=str, help='additional configure arguments', default=None)
1313
parser.add_argument('--repo', type=str, help='alternate URL for the repo', default=REPO)
14-
parser.add_argument('--use_archive', action='store_true', help='use archive to get just the source (only works on local repos)', default=False)
14+
parser.add_argument('--use_reference', action='store_true', help='use reference to clone the source (only works on local repos)', default=False)
1515
parser.add_argument('--no_clean', action='store_true', default=False)
1616
parser.add_argument('-j', '--jobs', type=int, help='number of jobs for make in build', default=1)
1717
parser.add_argument('-v', '--verbose', action='store_true', default=False)
@@ -34,16 +34,14 @@ def shell_exec(cmd, verbose=args.verbose, check=True):
3434
os.mkdir(srcdir)
3535

3636

37-
if args.use_archive:
38-
# go to the repo and archive out of it
39-
os.chdir(args.repo)
40-
shell_exec('git archive --format=tar %s | tar x -C %s'%(args.hash, srcdir))
41-
os.chdir(srcdir)
37+
if args.use_reference:
38+
shell_exec('git clone --reference %s %s %s'%(args.repo, args.repo, srcdir))
4239
else:
43-
# get git source and checkout the hash
4440
shell_exec('git clone %s %s'%(args.repo, srcdir))
45-
os.chdir(srcdir)
46-
shell_exec('git checkout %s'%args.hash)
41+
42+
os.chdir(srcdir)
43+
shell_exec('git checkout %s'%args.hash)
44+
shell_exec('git clean -f -d -x')
4745

4846
# build the source
4947
xtra_args = "" if args.configure_args is None else args.configure_args

run_backfill.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_script_dir():
2525
parser.add_argument('--branch', type=str, help='git branch for the compiler (default: %s)'%DEFAULT_BRANCH, default=DEFAULT_BRANCH)
2626
parser.add_argument('--main_branch', type=str, help='name of mainline git branch for compiler (default: %s)'%DEFAULT_MAIN_BRANCH, default=DEFAULT_MAIN_BRANCH)
2727
parser.add_argument('--repo_pull', action='store_true', help="do a pull on the git repo before selecting hashes", default=False)
28-
parser.add_argument('--use_repo_archive', action='store_true', help="use archive to get source out of repo to save space", default=False)
28+
parser.add_argument('--use_repo_reference', action='store_true', help="use reference to clone a local git repo", default=False)
2929
parser.add_argument('--no_first_parent', action='store_true', help="By default we use first-parent on git logs (to keep date ordering sane); this option turns it off", default=False)
3030
parser.add_argument('--commit_choice_method', type=str, help='commit choice method (version_tags, status_success, hash=XXX, delay=00:05:00, all)', default='version_tags')
3131
parser.add_argument('--commit_after', type=str, help='select commits after the specified date (e.g. 2017-10-02)', default=None)
@@ -184,8 +184,8 @@ def get_hash_status(h):
184184
print('Skipping build for %s as already built'%h)
185185
else:
186186
log_fname = os.path.join(hashdir, 'build_%s.log'%run_timestamp)
187-
use_archive_opt = '--use_archive' if args.use_repo_archive else ''
188-
completed_proc = shell_exec_redirect('%s/build_ocaml_hash.py --repo %s %s -j %d --configure_args="%s" %s %s %s'%(SCRIPTDIR, repo_path, use_archive_opt, args.jobs, configure_args, verbose_args, h, builddir), log_fname)
187+
use_reference_opt = '--use_reference' if args.use_repo_reference else ''
188+
completed_proc = shell_exec_redirect('%s/build_ocaml_hash.py --repo %s %s -j %d --configure_args="%s" %s %s %s'%(SCRIPTDIR, repo_path, use_reference_opt, args.jobs, configure_args, verbose_args, h, builddir), log_fname)
189189
if completed_proc.returncode != 0:
190190
print('ERROR[%d] in build_ocaml_hash for %s (see %s)'%(completed_proc.returncode, h, log_fname))
191191
continue

0 commit comments

Comments
 (0)