From 41c8c229ccbeea959da096319afe533237b2d74c Mon Sep 17 00:00:00 2001 From: chrysn Date: Thu, 18 Oct 2012 21:12:00 +0200 Subject: [PATCH] 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. --- scripts/irq2nvic_h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/irq2nvic_h b/scripts/irq2nvic_h index 92d63b85..1259864f 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__":