Skip to content

Commit ea8671c

Browse files
author
Dag Sverre Seljebotn
committed
Prevent invoking Jinja templating unecessarily
1 parent 0a0cad3 commit ea8671c

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ perftest: compile_all
5454
$(BINDIR)/sharp_testsuite test gauss 4095 -1 -1 8192 0 1 && \
5555
$(BINDIR)/sharp_testsuite test gauss 8191 -1 -1 16384 0 1
5656

57-
# Jinja templates
58-
5957
%.c: %.c.in
60-
./runjinja.py < $< > $@
58+
# Only do this if the md5sum changed, in order to avoid Python and Jinja
59+
# dependency when not modifying the c.in file
60+
grep `md5sum $< | cut -d ' ' -f 1` $@ || ./runjinja.py < $< > $@
6161

6262
genclean:
6363
rm libsharp/sharp_legendre.c || exit 0

libsharp/sharp_legendre.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/* DO NOT EDIT. md5sum of source: 88eec944ab6fbfdc7f391fbb58df3bf1 *//*
22
33
NOTE NOTE NOTE
44
@@ -1303,3 +1303,5 @@ void sharp_legendre_transform_s(float *bl,
13031303
}
13041304
}
13051305

1306+
1307+

libsharp/sharp_legendre.c.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,3 @@ void sharp_legendre_transform{{T}}({{scalar}} *bl,
160160
}
161161
}
162162
/*{ endfor }*/
163-

runjinja.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import sys
8+
import hashlib
89
from jinja2 import Template, Environment
910

1011
env = Environment(block_start_string='/*{',
@@ -13,4 +14,6 @@
1314
variable_end_string='}}')
1415

1516
extra_vars = dict(len=len)
16-
sys.stdout.write(env.from_string(sys.stdin.read()).render(**extra_vars))
17+
input = sys.stdin.read()
18+
sys.stdout.write('/* DO NOT EDIT. md5sum of source: %s */' % hashlib.md5(input).hexdigest())
19+
sys.stdout.write(env.from_string(input).render(**extra_vars))

0 commit comments

Comments
 (0)