ldgen: use user input filename for processed template

Previously ldgen determines the output file name on its own. This commit
makes it so that user can dictate what the output file name will be
for the processed template, if the user needs it for something else.
This commit is contained in:
Renz Christian Bagaporo
2019-05-31 11:30:44 +08:00
parent 70dfcb35d4
commit f0f861ccd9
4 changed files with 16 additions and 9 deletions

View File

@@ -19,6 +19,8 @@ import argparse
import sys
import tempfile
import subprocess
import os
import errno
from fragments import FragmentFile
from sdkconfig import SDKConfig
@@ -111,6 +113,14 @@ def main():
with tempfile.TemporaryFile("w+") as output:
script_model.write(output)
output.seek(0)
if not os.path.exists(os.path.dirname(output_path)):
try:
os.makedirs(os.path.dirname(output_path))
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
with open(output_path, "w") as f: # only create output file after generation has suceeded
f.write(output.read())
except LdGenFailure as e: