summaryrefslogtreecommitdiff
path: root/build/scons_tools
diff options
context:
space:
mode:
Diffstat (limited to 'build/scons_tools')
-rw-r--r--build/scons_tools/tool_jinja2.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/build/scons_tools/tool_jinja2.py b/build/scons_tools/tool_jinja2.py
new file mode 100644
index 0000000..a927285
--- /dev/null
+++ b/build/scons_tools/tool_jinja2.py
@@ -0,0 +1,27 @@
+from SCons.Script import *
+import jinja2
+
+def jinja2_build(target, source, env):
+ template = jinja2.Template(open(str(source[0])).read())
+
+ template_env = env.get('TEMPLATE_ENV', {})
+
+ output = template.render(**template_env) + '\n'
+
+ open(str(target[0]), 'w').write(output)
+
+jinja2_builder = Builder(action = Action(jinja2_build, '$J2COMSTR', varlist = ['TEMPLATE_ENV']))
+
+def Jinja2(env, target, source, **kwargs):
+ return env.Jinja2Build(target, source, TEMPLATE_ENV = kwargs)
+
+
+def exists():
+ return True
+
+def generate(env):
+ env.Append(
+ BUILDERS = {'Jinja2Build': jinja2_builder},
+ )
+
+ env.AddMethod(Jinja2) \ No newline at end of file