diff --git a/stm-firmware/create-c-file-with-header.py b/stm-firmware/create-c-file-with-header.py index 67176c1..5ad8c48 100755 --- a/stm-firmware/create-c-file-with-header.py +++ b/stm-firmware/create-c-file-with-header.py @@ -2,6 +2,7 @@ import os import sys +import pathlib license_header = """/* Reflow Oven Controller * @@ -22,7 +23,6 @@ license_header = """/* Reflow Oven Controller * along with the reflow oven controller project. * If not, see . */ - """ project_dir = os.path.dirname(os.path.realpath(__file__)) @@ -37,19 +37,23 @@ cpath = os.path.join(project_dir, sys.argv[1]+'.c') hfile = sys.argv[1]+'.h' hpath = os.path.join(module_include_dir, hfile) -h_define = '__'+hfile.replace('.', '_').replace('-', '_').upper()+'__' +h_define = '__'+hfile.replace('.', '_').replace('-', '_').replace('/', '_').upper()+'__' if os.path.exists(cpath) or os.path.exists(hpath): print("File already exists! Abort!") sys.exit() print('Creating C file: %s' % (cpath)) +cfile_folder = os.path.dirname(cpath) +pathlib.Path(cfile_folder).mkdir(parents=True, exist_ok=True) with open(cpath, 'x') as f: f.write(license_header) f.write('\n') f.write('#include <%s>' % (os.path.join(include_prefix, hfile))) print('Creating H file: %s' % (hpath)) +hfile_folder = os.path.dirname(hpath) +pathlib.Path(hfile_folder).mkdir(parents=True, exist_ok=True) with open(hpath, 'x') as f: f.write(license_header) f.write('\n')