aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorchrysn2012-10-18 21:12:00 +0200
committerchrysn2012-10-18 21:12:00 +0200
commit41c8c229ccbeea959da096319afe533237b2d74c (patch)
tree3ad325eb910962a1baa2c3a1544f1ff3d0f2dcb0 /scripts
parentc39c5c147dbe9e307298372f80c63570f07e8cd7 (diff)
nvic.h generation script: be on safe side with directories
now tries to mkdir its way to the output files this wouldn't be a problem currently if it wasn't for the efm32 data lingering in the wrong branch, but otoh it's just on the safe side in case we meet architectures that don't need other specializations at all.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/irq2nvic_h13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/irq2nvic_h b/scripts/irq2nvic_h
index 92d63b8..1259864 100755
--- a/scripts/irq2nvic_h
+++ b/scripts/irq2nvic_h
@@ -27,6 +27,8 @@ method to achive the same thing with C preprocessor is known to the author.
(Neither is any non-portable method, for that matter.)"""
import sys
+import os
+import os.path
import yaml
template_nvic_h = '''\
@@ -112,12 +114,23 @@ def convert(infile, outfile_nvic, outfile_vectornvic):
outfile_nvic.write(template_nvic_h.format(**data))
outfile_vectornvic.write(template_vector_nvic_c.format(**data))
+def makeparentdir(filename):
+ try:
+ os.makedirs(os.path.dirname(filename))
+ except OSError:
+ # where is my 'mkdir -p'?
+ pass
+
def main():
infile = sys.argv[1]
if not infile.startswith('./include/libopencm3/') or not infile.endswith('/irq.yaml'):
raise ValueError("Arguent must match ./include/libopencm3/**/irq.yaml")
nvic_h = infile.replace('irq.yaml', 'nvic.h')
vector_nvic_c = infile.replace('./include/libopencm3/', './lib/').replace('irq.yaml', 'vector_nvic.c')
+
+ makeparentdir(nvic_h)
+ makeparentdir(vector_nvic_c)
+
convert(open(infile), open(nvic_h, 'w'), open(vector_nvic_c, 'w'))
if __name__ == "__main__":