Fix / Workaround for issue #11224. (cont.)

* Extended script "boost_mpl_preprocess.py" to automatically call script
  "fix_boost_mpl_preprocess.py" prior to pre-processing and thereby
  automatically fix issue #11224.
* Extended script "fix_boost_mpl_preprocess.py" to just allow checking
  if the selected Boost source-directory requires fixing because of
  issue #11224.
* Adjusted the "README.txt" accordingly.

Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
This commit is contained in:
Deniz Bahadir
2015-05-01 17:46:59 +02:00
parent 7cd0559ce8
commit 0e262c22a0
3 changed files with 133 additions and 16 deletions

View File

@ -26,19 +26,36 @@ Fixing pre-processing of MPL-containers
Sadly, pre-processing of MPL-containers might fail, if the source-files
used as input are missing some header-comments required during the pre-
processing step.
In such a case call the script "fix_boost_mpl_preprocess.py" like this:
However, the script "boost_mpl_preprocess.py" makes sure to patch these
input source-files prior to pre-processing (by implicitly calling script
"fix_boost_mpl_preprocess.py" with the chosen settings). It only patches
the source-files needed for pre-processing the selected MPL-container
types and their selected form ('numbered' or 'variadic').
If calling it with a single argument (as in the former section) all input
source-files will be patched automatically.
Instead of fixing the input-files implicitly during pre-processing one
can also fix them explicitly by calling "fix_boost_mpl_preprocess.py"
directly.
If you just want to test if any fixing is needed call it like this:
python fix_boost_mpl_preprocess.py --check-only <path-to-boost-sourcedir>
This will tell you if any fixing is needed. In such a case call the script
"fix_boost_mpl_preprocess.py" like this:
python fix_boost_mpl_preprocess.py <path-to-boost-sourcedir>
This will fix the header-comments of all the source-files needed during
pre-processing. Calling "boost_mpl_preprocess.py" afterwards should then
successfully pre-process the MPL-containers.
successfully pre-process the MPL-containers (without the need of implicitly
fixing any files again).
Note:
If pre-processing failed can be checked by examining at least one of the
Failure of pre-processing can be checked by examining at least one of the
following directories in which automatically generated files will be put
during pre-processing. If at least one file in these directories (or sub-
directories therein) has a size of zero bytes, the fix is needed.
directories therein) has a size of zero bytes, fixing is needed.
<path-to-boost-sourcedir>/boost/mpl/vector/aux_/preprocessed/
<path-to-boost-sourcedir>/boost/mpl/list/aux_/preprocessed/

View File

@ -8,6 +8,7 @@
# See http://stackoverflow.com/a/20660264/3115457 for further information.
# See http://stackoverflow.com/a/29627158/3115457 for further information.
import fix_boost_mpl_preprocess as fixmpl
import argparse
import sys
import os
@ -164,9 +165,20 @@ def main():
if args.want_map:
containers.append('map')
if containers == []:
print "Nothing to do. (Why did you prevent generating pre-processed headers for all Boost.MPL container types?"
print "Nothing to do."
print "(Why did you prevent generating pre-processed headers for all Boost.MPL container types?)"
sys.exit(0)
# Possibly fix the header-comments of input-files needed for pre-processing.
if args.verbose:
print "Checking if prior to pre-processing some input-files need fixing."
needFixing = fixmpl.check_input_files(headerDir, sourceDir, containers, args.seqType, args.verbose)
if needFixing:
if args.verbose:
print "Fixing of some input-files prior to pre-processing is needed."
print "Will fix them now!"
fixmpl.fix_input_files(headerDir, sourceDir, containers, args.seqType, args.verbose)
# Some verbose debug output.
if args.verbose:
print "Containers for which to pre-process headers: ", containers

View File

@ -16,6 +16,79 @@ import datetime
import glob
def check_header_comment(filename):
"""Checks if the header-comment of the given file needs fixing."""
# Check input file.
name = os.path.basename( filename )
# Read content of input file.
sourcefile = open( filename, "rU" )
content = sourcefile.read()
sourcefile.close()
# Search content for '$Id$'.
match = re.search(r'\$Id\$', content)
if match == None:
# Make sure that the correct value for '$Id$' was already set.
match = re.search(r'\$Id: ' + name + r'\s+[^$]+\$', content)
if match != None:
# The given file needs no fixing.
return False
# The given file needs fixing.
return True
def check_input_files_for_variadic_seq(headerDir, sourceDir):
"""Checks if files, used as input when pre-processing MPL-containers in their variadic form, need fixing."""
# Check input files in include/source-directories.
files = glob.glob( os.path.join( headerDir, "*.hpp" ) )
files += glob.glob( os.path.join( headerDir, "aux_", "*.hpp" ) )
files += glob.glob( os.path.join( sourceDir, "src", "*" ) )
for currentFile in sorted( files ):
if check_header_comment( currentFile ):
return True
return False
def check_input_files_for_numbered_seq(sourceDir, suffix, containers):
"""Check if files, used as input when pre-processing MPL-containers in their numbered form, need fixing."""
# Check input files for each MPL-container type.
for container in containers:
files = glob.glob( os.path.join( sourceDir, container, container + '*' + suffix ) )
for currentFile in sorted( files ):
if check_header_comment( currentFile ):
return True
return False
def check_input_files(headerDir, sourceDir, containers=['vector', 'list', 'set', 'map'],
seqType='both', verbose=False):
"""Checks if source- and header-files, used as input when pre-processing MPL-containers, need fixing."""
# Check the input files for containers in their variadic form.
result1 = False
if seqType == "both" or seqType == "variadic":
if verbose:
print "Check if input files for pre-processing Boost.MPL variadic containers need fixing."
result1 = check_input_files_for_variadic_seq(headerDir, sourceDir)
if verbose:
if result1:
print " At least one input file needs fixing!"
else:
print " No input file needs fixing!"
# Check the input files for containers in their numbered form.
result2 = False
result3 = False
if seqType == "both" or seqType == "numbered":
if verbose:
print "Check input files for pre-processing Boost.MPL numbered containers."
result2 = check_input_files_for_numbered_seq(headerDir, ".hpp", containers)
result3 = check_input_files_for_numbered_seq(sourceDir, ".cpp", containers)
if verbose:
if result2 or result3:
print " At least one input file needs fixing!"
else:
print " No input file needs fixing!"
# Return result.
return result1 or result2 or result3
def fix_header_comment(filename, timestamp):
"""Fixes the header-comment of the given file."""
# Fix input file.
@ -47,18 +120,22 @@ def fix_input_files_for_numbered_seq(sourceDir, suffix, timestamp, containers):
fix_header_comment( currentFile, timestamp )
def fix_input_files(headerDir, sourceDir, containers=['vector', 'list', 'set', 'map'], verbose='false'):
def fix_input_files(headerDir, sourceDir, containers=['vector', 'list', 'set', 'map'],
seqType='both', verbose=False):
"""Fixes source- and header-files used as input when pre-processing MPL-containers."""
# The new modification time.
timestamp = datetime.datetime.now();
# Fix the input files.
if verbose:
print "Fix input files for pre-processing Boost.MPL variadic containers."
fix_input_files_for_variadic_seq(headerDir, sourceDir, timestamp)
if verbose:
print "Fix input files for pre-processing Boost.MPL numbered containers."
fix_input_files_for_numbered_seq(headerDir, ".hpp", timestamp, containers)
fix_input_files_for_numbered_seq(sourceDir, ".cpp", timestamp, containers)
# Fix the input files for containers in their variadic form.
if seqType == "both" or seqType == "variadic":
if verbose:
print "Fix input files for pre-processing Boost.MPL variadic containers."
fix_input_files_for_variadic_seq(headerDir, sourceDir, timestamp)
# Fix the input files for containers in their numbered form.
if seqType == "both" or seqType == "numbered":
if verbose:
print "Fix input files for pre-processing Boost.MPL numbered containers."
fix_input_files_for_numbered_seq(headerDir, ".hpp", timestamp, containers)
fix_input_files_for_numbered_seq(sourceDir, ".cpp", timestamp, containers)
def to_existing_absolute_path(string):
@ -78,6 +155,8 @@ def main():
description="Fixes the input files used for pre-processing of Boost.MPL headers.")
cmdlineParser.add_argument("-v", "--verbose", dest='verbose', action='store_true',
help="Be a little bit more verbose.")
cmdlineParser.add_argument("--check-only", dest='checkonly', action='store_true',
help="Only checks if fixing is required.")
cmdlineParser.add_argument(dest='sourceDir', metavar="<source-dir>",
type=to_existing_absolute_path,
help="The source-directory of Boost.")
@ -87,6 +166,7 @@ def main():
if args.verbose:
print "Arguments extracted from command-line:"
print " verbose = ", args.verbose
print " check-only = ", args.checkonly
print " source directory = ", args.sourceDir
# The directories for header- and source files of Boost.MPL.
@ -109,8 +189,16 @@ def main():
print "Chosen header-directory: ", headerDir
print "Chosen source-directory: ", sourceDir
# Fix input file for generating pre-processed headers.
fix_input_files(headerDir, sourceDir, verbose = args.verbose)
if args.checkonly:
# Check input files for generating pre-processed headers.
result = check_input_files(headerDir, sourceDir, verbose = args.verbose)
if result:
print "Fixing the input-files used for pre-processing of Boost.MPL headers IS required."
else:
print "Fixing the input-files used for pre-processing of Boost.MPL headers is NOT required."
else:
# Fix input files for generating pre-processed headers.
fix_input_files(headerDir, sourceDir, verbose = args.verbose)
if __name__ == '__main__':