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.
This commit is contained in:
parent
c39c5c147d
commit
41c8c229cc
@ -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__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user