From 0c3f02af895a7b153d0f0ff1bfe744d3172b19fc Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sat, 12 Oct 2019 16:55:47 -0700 Subject: [PATCH] efrocache trial run 2 --- Makefile | 2 +- tools/efrotools/efrocache.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ff5ae037..dea8051d 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ all: help # Tell make which of these targets don't represent files. .PHONY: all -build/testfile: $(PROJ_DIR)/.efrocachemap +build/testfile: .efrocachemap tools/snippets efrocache_get $@ diff --git a/tools/efrotools/efrocache.py b/tools/efrotools/efrocache.py index 829f1413..4d26599d 100644 --- a/tools/efrotools/efrocache.py +++ b/tools/efrotools/efrocache.py @@ -98,7 +98,15 @@ def get_target(path: str) -> None: def filter_makefile(makefile_dir: str, contents: str) -> str: """Filter makefile contents to use efrocache lookups.""" - cachemap = '$(PROJ_DIR)/.efrocachemap' + + if makefile_dir: + # Assuming just one level deep at the moment; can revisit later. + assert '/' not in makefile_dir + to_proj_root = '..' + else: + to_proj_root = '' + + cachemap = os.path.join(to_proj_root, '.efrocachemap') lines = contents.splitlines() snippets = 'tools/snippets' @@ -120,7 +128,7 @@ def filter_makefile(makefile_dir: str, contents: str) -> str: del lines[index:endindex] lines.insert(index, tname + ': ' + cachemap) target = (makefile_dir + '/' + '$@') if makefile_dir else '$@' - pre = 'cd $(PROJ_DIR) && ' if makefile_dir else '' + pre = 'cd {to_proj_root} && ' if makefile_dir else '' lines.insert(index + 1, f'\t{pre}{snippets} efrocache_get {target}') return '\n'.join(lines) + '\n'