From 1f36c2eea158c48e3409356902a5797810850c11 Mon Sep 17 00:00:00 2001 From: Matthew Sotoudeh Date: Wed, 16 Sep 2020 13:59:36 -0700 Subject: Simple build caching --- run_latex.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'run_latex.py') diff --git a/run_latex.py b/run_latex.py index 9f4b75e..64220c0 100644 --- a/run_latex.py +++ b/run_latex.py @@ -21,6 +21,11 @@ import shutil import subprocess import sys +# Copy any existing build cache here. +cache_dir = "/tmp/bazel-latex.cache" +if os.path.exists(cache_dir) and os.path.isdir(cache_dir): + shutil.copytree(cache_dir, "latex.out") + texlive, latexrun, job_name, main_file, output_file = sys.argv[1:6] sources = sys.argv[6:] if output_file == "--": @@ -56,6 +61,11 @@ return_code = subprocess.call( env=env, ) +# Copy back to the build cache. +if os.path.exists(cache_dir): + shutil.rmtree(cache_dir) +shutil.copytree("latex.out", cache_dir) + if return_code != 0: sys.exit(return_code) -- cgit v1.2.3