Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions build/flatten-headers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# BLIS
# BLIS
# An object-based framework for developing high-performance BLAS-like
# libraries.
#
Expand Down Expand Up @@ -215,9 +215,19 @@ def flatten_header( inputfile, header_dirpaths, cursp ):
# Open the input file to process.
ifile = open( inputfile, "r" )

# A counter to track the line number being parsed within the current file.
# This counter, when selectively encoded into the flattened header via #line
# directives, facilitates easier debugging. (When the compiler finds an
# issue, it will be able to refer to the line number within the constituent
# header file rather than the flattened one.)
lineno = 0

# Iterate over the lines in the file.
while True:

# Increment the line number.
lineno += 1

# Read a line in the file.
line = ifile.readline()

Expand Down Expand Up @@ -268,12 +278,14 @@ def flatten_header( inputfile, header_dirpaths, cursp ):

# Mark the beginning of the header being inserted.
ostring += "%s%s%c" % ( beginstr, header, '\n' )
ostring += "#line %d \"%s\"%c\n" % ( 1, header_path, '\n' )

# Recurse on the header, accumulating the string.
ostring += flatten_header( header_path, header_dirpaths, cursp + " " )

# Mark the end of the header being inserted.
ostring += "%s%s%c" % ( endstr, header, '\n' )
ostring += "#line %d \"%s\"%c\n" % ( lineno+1, inputfile, '\n' )

echov2( "%sheader file '%s' fully processed." \
% ( cursp, header_path ) )
Expand All @@ -300,7 +312,7 @@ def flatten_header( inputfile, header_dirpaths, cursp ):
# endif

# endwhile

# Close the input file.
ifile.close()

Expand Down Expand Up @@ -330,7 +342,6 @@ def find_header_dirs( dirpath ):
#endfor

return header_dirpaths


# ------------------------------------------------------------------------------

Expand Down