diff options
author | Thomas "Cakeisalie5" Touhey <thomas@touhey.fr> | 2017-07-14 01:21:55 +0200 |
---|---|---|
committer | Thomas "Cakeisalie5" Touhey <thomas@touhey.fr> | 2017-07-14 01:21:55 +0200 |
commit | e59bb3f483b5bf7962c0a79c96c9f75d4c41ef9f (patch) | |
tree | 8855b0000ae2388a2187887b6aa3e09fcdd07e52 | |
parent | e457dcdb5e9d806cfeef2c27330d01eba0e82c58 (diff) |
Corrected bits option management, added behaviour of removing unknown headers in makeinc.
-rwxr-xr-x | tools/makeinc.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/makeinc.py b/tools/makeinc.py index 6bc3c7c..69756cc 100755 --- a/tools/makeinc.py +++ b/tools/makeinc.py @@ -11,13 +11,16 @@ from argparse import ArgumentParser argparser = ArgumentParser(prog='makeinc.py') argparser.add_argument('out', help='The output include folder.') argparser.add_argument('path', help='The include directories.', nargs='*') -argparser.add_argument('--bits', help='The bits path', default='') +argparser.add_argument('--bits', help='The bits path', action='append') # Parse the arguments. args = argparser.parse_args() # Correct the bits path. -args.bits = args.bits.split(':') if args.bits else [] +bits = [] +for arg in args.bits: + bits += arg.split(':') +args.bits = bits #*****************************************************************************# # Useful function # #*****************************************************************************# @@ -185,7 +188,17 @@ for base in args.path: %(nm, dirs[names.index(nm)], base)) exit(1) -# Hello. +# Check for the intruders. +if os.path.isdir(args.out): + lst = [] + for root, _, nms in os.walk(args.out): + lst += [os.path.join(root, name)[len(os.path.join(args.out, '')):] \ + for name in nms] + for nm in lst: + if not nm in names: + os.remove(os.path.join(args.out, nm)) + +# Make the includes. for path in zip(dirs, names): localpath = os.path.join(args.out, path[1]) @@ -193,3 +206,5 @@ for path in zip(dirs, names): except: pass make_header(path[0], path[1], open(localpath, 'w')) + +# End of file. |