@@ -60,7 +60,8 @@ def _process_non_include(self, line, file_level):
6060 self ._output .append (line )
6161
6262 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 )
6465
6566 if self ._output and self ._output [- 1 ].startswith ('#line' ):
6667 # Avoid emitting multiple line infos in sequence, just overwrite the last one
@@ -73,6 +74,9 @@ def add_file(self, filename, file_level=0):
7374 self ._log .warning ('Tried to to process an already processed file: "%s"' , filename )
7475 return
7576
77+ if not file_level :
78+ self ._log .debug ('Adding file: "%s"' , filename )
79+
7680 file_level += 1
7781
7882 # mark the start of the new file in the output
@@ -138,7 +142,7 @@ def add_file(self, filename, file_level=0):
138142
139143 self ._log .debug ('[%d] Including: "%s"' ,
140144 file_level , self ._h_files [name ])
141- self .add_file (self ._h_files [name ])
145+ self .add_file (self ._h_files [name ], file_level )
142146
143147 # mark the continuation of the current file in the output
144148 self ._emit_lineinfo (line_idx + 1 , filename )
@@ -207,17 +211,17 @@ def run_merger(args):
207211 h_files .pop (name , '' )
208212
209213 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 )
212216
213217 if args .append_c_files :
214218 # if the input file is in the C files list it should be removed to avoid
215219 # 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 )
218222 c_files .pop (input_name , '' )
219223
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
221225 # not at the beginning.
222226 for fname in sorted (c_files .values (), reverse = True ):
223227 merger .add_file (fname )
@@ -230,12 +234,12 @@ def main():
230234 parser = argparse .ArgumentParser (description = 'Merge source/header files.' )
231235 parser .add_argument ('--base-dir' , metavar = 'DIR' , type = str , dest = 'base_dir' ,
232236 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 = [] )
235239 parser .add_argument ('--output' , metavar = 'FILE' , type = str , dest = 'output_file' ,
236240 help = 'Output source/header file' )
237241 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 ' )
239243 parser .add_argument ('--remove-include' , action = 'append' , default = [])
240244 parser .add_argument ('--push-include' , action = 'append' , default = [])
241245 parser .add_argument ('--verbose' , '-v' , action = 'store_true' , default = False )
0 commit comments