Prevent invoking Jinja templating unecessarily

This commit is contained in:
Dag Sverre Seljebotn 2015-04-22 14:23:39 +02:00
parent 0a0cad34aa
commit ea8671c2ec
4 changed files with 10 additions and 6 deletions

View file

@ -54,10 +54,10 @@ perftest: compile_all
$(BINDIR)/sharp_testsuite test gauss 4095 -1 -1 8192 0 1 && \
$(BINDIR)/sharp_testsuite test gauss 8191 -1 -1 16384 0 1
# Jinja templates
%.c: %.c.in
./runjinja.py < $< > $@
# Only do this if the md5sum changed, in order to avoid Python and Jinja
# dependency when not modifying the c.in file
grep `md5sum $< | cut -d ' ' -f 1` $@ || ./runjinja.py < $< > $@
genclean:
rm libsharp/sharp_legendre.c || exit 0

View file

@ -1,4 +1,4 @@
/*
/* DO NOT EDIT. md5sum of source: 88eec944ab6fbfdc7f391fbb58df3bf1 *//*
NOTE NOTE NOTE
@ -1303,3 +1303,5 @@ void sharp_legendre_transform_s(float *bl,
}
}

View file

@ -160,4 +160,3 @@ void sharp_legendre_transform{{T}}({{scalar}} *bl,
}
}
/*{ endfor }*/

View file

@ -5,6 +5,7 @@ Preprocesses foo.c.in to foo.c. Reads STDIN and writes STDOUT.
"""
import sys
import hashlib
from jinja2 import Template, Environment
env = Environment(block_start_string='/*{',
@ -13,4 +14,6 @@ env = Environment(block_start_string='/*{',
variable_end_string='}}')
extra_vars = dict(len=len)
sys.stdout.write(env.from_string(sys.stdin.read()).render(**extra_vars))
input = sys.stdin.read()
sys.stdout.write('/* DO NOT EDIT. md5sum of source: %s */' % hashlib.md5(input).hexdigest())
sys.stdout.write(env.from_string(input).render(**extra_vars))