mirror of
https://github.com/amd/blis.git
synced 2026-03-23 02:37:25 +00:00
Minor bugfix to flatten-headers.py.
Details: - Fixed a minor bug in flatten-headers.py whereby the script, upon encountering a #include directive for the root header file, would erroneously recurse and inline the conents of that root header. The script has been modified to avoid recursion into any headers that share the same name as the root-level header that was passed into the script. (Note: this bug didn't actually manifest in BLIS, so it's merely a precaution for usage of flatten-headers.py in other contexts.)
This commit is contained in:
@@ -244,10 +244,24 @@ def flatten_header( inputfile, header_dirpaths, cursp ):
|
||||
# directive.
|
||||
header_path = get_header_path( header, header_dirpaths )
|
||||
|
||||
# If the header was found, we recurse. Otherwise, we output
|
||||
# the #include directive with a comment indicating that it
|
||||
# was skipped.
|
||||
if header_path:
|
||||
# First, check if the header is our root header (and if so, ignore it).
|
||||
# Otherwise, if the header was found, we recurse. Otherwise, we output
|
||||
# the #include directive with a comment indicating that it as skipped
|
||||
if header == root_file_name:
|
||||
|
||||
markl = result.group(1)
|
||||
markr = result.group(3)
|
||||
|
||||
echov2( "%sthis is the root header '%s'; commenting out / skipping." \
|
||||
% ( cursp, header ) )
|
||||
|
||||
# If the header found is our root header, then we cannot
|
||||
# recurse into it lest we enter an infinite loop. Output the
|
||||
# line but make sure it's commented out entirely.
|
||||
ostring += "%s #include %c%s%c %c" \
|
||||
% ( skipstr, markl, header, markr, '\n' )
|
||||
|
||||
elif header_path:
|
||||
|
||||
echov2( "%slocated file '%s'; recursing." \
|
||||
% ( cursp, header_path ) )
|
||||
@@ -327,6 +341,7 @@ strip_comments = None
|
||||
recursive_flag = None
|
||||
verbose_flag = None
|
||||
regex = None
|
||||
root_file_name = None
|
||||
|
||||
def main():
|
||||
|
||||
@@ -336,6 +351,7 @@ def main():
|
||||
global recursive_flag
|
||||
global verbose_flag
|
||||
global regex
|
||||
global root_file_name
|
||||
|
||||
# Obtain the script name.
|
||||
path, script_name = os.path.split(sys.argv[0])
|
||||
@@ -397,6 +413,10 @@ def main():
|
||||
temp_dir = args[2]
|
||||
dir_list = args[3]
|
||||
|
||||
# Save the filename (basename) part of the input file (or root file) into a
|
||||
# global variable that we can access later from within flatten_header().
|
||||
root_file_name = os.path.basename( inputfile )
|
||||
|
||||
# Separate the directories into distinct strings.
|
||||
dir_list = dir_list.split()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user