@@ -60,7 +60,8 @@ def _process_non_include(self, line, file_level):
60
60
self ._output .append (line )
61
61
62
62
def _emit_lineinfo (self , line_number , filename ):
63
- line_info = '#line %d "%s"\n ' % (line_number , filename )
63
+ normalized_path = repr (os .path .normpath (filename ))[1 :- 1 ]
64
+ line_info = '#line %d "%s"\n ' % (line_number , normalized_path )
64
65
65
66
if self ._output and self ._output [- 1 ].startswith ('#line' ):
66
67
# Avoid emitting multiple line infos in sequence, just overwrite the last one
@@ -73,6 +74,9 @@ def add_file(self, filename, file_level=0):
73
74
self ._log .warning ('Tried to to process an already processed file: "%s"' , filename )
74
75
return
75
76
77
+ if not file_level :
78
+ self ._log .debug ('Adding file: "%s"' , filename )
79
+
76
80
file_level += 1
77
81
78
82
# mark the start of the new file in the output
@@ -138,7 +142,7 @@ def add_file(self, filename, file_level=0):
138
142
139
143
self ._log .debug ('[%d] Including: "%s"' ,
140
144
file_level , self ._h_files [name ])
141
- self .add_file (self ._h_files [name ])
145
+ self .add_file (self ._h_files [name ], file_level )
142
146
143
147
# mark the continuation of the current file in the output
144
148
self ._emit_lineinfo (line_idx + 1 , filename )
@@ -207,17 +211,17 @@ def run_merger(args):
207
211
h_files .pop (name , '' )
208
212
209
213
merger = SourceMerger (h_files , args .push_include , args .remove_include )
210
- if args .input_file :
211
- merger .add_file (args . input_file )
214
+ for input_file in args .input_files :
215
+ merger .add_file (input_file )
212
216
213
217
if args .append_c_files :
214
218
# if the input file is in the C files list it should be removed to avoid
215
219
# double inclusion of the file
216
- if args .input_file :
217
- input_name = os .path .basename (args . input_file )
220
+ for input_file in args .input_files :
221
+ input_name = os .path .basename (input_file )
218
222
c_files .pop (input_name , '' )
219
223
220
- # Add the C files in reverse the order to make sure that builtins are
224
+ # Add the C files in reverse order to make sure that builtins are
221
225
# not at the beginning.
222
226
for fname in sorted (c_files .values (), reverse = True ):
223
227
merger .add_file (fname )
@@ -230,12 +234,12 @@ def main():
230
234
parser = argparse .ArgumentParser (description = 'Merge source/header files.' )
231
235
parser .add_argument ('--base-dir' , metavar = 'DIR' , type = str , dest = 'base_dir' ,
232
236
help = '' , default = os .path .curdir )
233
- parser .add_argument ('--input' , metavar = 'FILE ' , type = str , dest = 'input_file ' ,
234
- help = 'Main input source/header file' )
237
+ parser .add_argument ('--input' , metavar = 'FILES ' , type = str , action = 'append' , dest = 'input_files ' ,
238
+ help = 'Main input source/header files' , default = [] )
235
239
parser .add_argument ('--output' , metavar = 'FILE' , type = str , dest = 'output_file' ,
236
240
help = 'Output source/header file' )
237
241
parser .add_argument ('--append-c-files' , dest = 'append_c_files' , default = False ,
238
- action = 'store_true' , help = 'das ' )
242
+ action = 'store_true' , help = 'Enable auto inclusion of c files under the base-dir ' )
239
243
parser .add_argument ('--remove-include' , action = 'append' , default = [])
240
244
parser .add_argument ('--push-include' , action = 'append' , default = [])
241
245
parser .add_argument ('--verbose' , '-v' , action = 'store_true' , default = False )
0 commit comments