Skip to content

Exporters: make jinja engine strict #3608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/export/cmsis/cpdsc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<project name="{{name}}" documentation="">
<target Dendian="{{device.dendian}}" Dfpu="{{device.dfpu}}" Dname="{{device.dname}}" Dvendor="{{device.dvendor}}">
<output debug="1" name="{{name}}" type="exe"/>
<debugProbe name="{{device.debug_interface}}" protocol="jtag"/>
<debugProbe name="{{device.debug}}" protocol="jtag"/>
</target>
{{project_files}}
</project>
</create>
</package>
</package>
7 changes: 4 additions & 3 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from os.path import join, dirname, relpath, basename, realpath, normpath
from itertools import groupby
from jinja2 import FileSystemLoader
from jinja2 import FileSystemLoader, StrictUndefined
from jinja2.environment import Environment
import copy

Expand Down Expand Up @@ -111,11 +111,12 @@ def get_source_paths(self):
source_files.extend(getattr(self.resources, key))
return list(set([os.path.dirname(src) for src in source_files]))

def gen_file(self, template_file, data, target_file):
def gen_file(self, template_file, data, target_file, **kwargs):
"""Generates a project file from a template using jinja"""
jinja_loader = FileSystemLoader(
os.path.dirname(os.path.abspath(__file__)))
jinja_environment = Environment(loader=jinja_loader)
jinja_environment = Environment(loader=jinja_loader,
undefined=StrictUndefined, **kwargs)

template = jinja_environment.get_template(template_file)
target_text = template.render(data)
Expand Down
2 changes: 2 additions & 0 deletions tools/export/iar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ def iar_device(self):
"GFPUCoreSlave": '',
"GFPUCoreSlave2": 40,
"GBECoreSlave": 35,
"GBECoreSlave2": '',
"FPU2": 0,
"NrRegs": 0,
"NEON": '',
}

iar_defaults.update(device_info)
Expand Down
2 changes: 1 addition & 1 deletion tools/export/iar/ewp.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<option>
<name>GBECoreSlave</name>
<version>24</version>
<state>{{GBECoreSlave}}</state>
<state>{{device.GBECoreSlave}}</state>
</option>
<option>
<name>OGUseCmsis</name>
Expand Down