aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrysn2012-10-23 01:31:30 +0200
committerchrysn2012-10-23 01:31:30 +0200
commit2ad04777bf63a1324afe2b65d689aa210928bfea (patch)
tree8e6cc2a5e64347543cd13b69974b03eb1a33c46d
parent0a1cf977eb2003dd55cee8f5f840f3a2f6e9c0ce (diff)
only generate irq headers on demand
as header file generation is not directly controlled by make (which, by the way, makes the generatedheaders target phony), the script has to take care of not needlessly generating files itself lest to have make rebuild everything everytime
-rw-r--r--Makefile2
-rwxr-xr-xscripts/irq2nvic_h7
2 files changed, 8 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 76c302d..7ebd769 100644
--- a/Makefile
+++ b/Makefile
@@ -88,5 +88,5 @@ clean:
@printf " CLEAN doxygen\n"
$(Q)$(MAKE) -C doc clean
-.PHONY: build lib examples install doc clean
+.PHONY: build lib examples install doc clean generatedheaders
diff --git a/scripts/irq2nvic_h b/scripts/irq2nvic_h
index f84c88e..903af15 100755
--- a/scripts/irq2nvic_h
+++ b/scripts/irq2nvic_h
@@ -125,6 +125,10 @@ def makeparentdir(filename):
# where is my 'mkdir -p'?
pass
+def needs_update(infiles, outfiles):
+ timestamp = lambda filename: os.stat(filename).st_mtime
+ return any(not os.path.exists(o) for o in outfiles) or max(map(timestamp, infiles)) > min(map(timestamp, outfiles))
+
def main():
infile = sys.argv[1]
if not infile.startswith('./include/libopencm3/') or not infile.endswith('/irq.yaml'):
@@ -132,6 +136,9 @@ def main():
nvic_h = infile.replace('irq.yaml', 'nvic.h')
vector_nvic_c = infile.replace('./include/libopencm3/', './lib/').replace('irq.yaml', 'vector_nvic.c')
+ if not needs_update([__file__, infile], [nvic_h, vector_nvic_c]):
+ sys.exit(0)
+
makeparentdir(nvic_h)
makeparentdir(vector_nvic_c)