parameters: ()
docstring: The main function.
docstring_summary: The main function.
docstring_tokens: The main function .
function: def main():
      """The main function."""
      
      # Find the current Boost source-directory in which this script is located.
      sourceDir = current_boost_dir()
      if sourceDir == None:
          sourceDir = ""
      
      # Prepare and run cmdline-parser.
      cmdlineParser = argparse.ArgumentParser(description="A generator-script for pre-processed Boost.MPL headers.")
      cmdlineParser.add_argument("-v", "--verbose", dest='verbose', action='store_true',
                                 help="Be a little bit more verbose.")
      cmdlineParser.add_argument("-s", "--sequence-type", dest='seqType', choices=['variadic', 'numbered', 'both'],
                                 default='both',
                                 help="Only update pre-processed headers for the selected sequence types, "
                                      "either 'numbered' sequences, 'variadic' sequences or 'both' sequence "
                                      "types. (Default=both)")
      cmdlineParser.add_argument("--no-vector", dest='want_vector', action='store_false',
                                 help="Do not update pre-processed headers for Boost.MPL Vector.")
      cmdlineParser.add_argument("--no-list", dest='want_list', action='store_false',
                                 help="Do not update pre-processed headers for Boost.MPL List.")
      cmdlineParser.add_argument("--no-set", dest='want_set', action='store_false',
                                 help="Do not update pre-processed headers for Boost.MPL Set.")
      cmdlineParser.add_argument("--no-map", dest='want_map', action='store_false',
                                 help="Do not update pre-processed headers for Boost.MPL Map.")
      cmdlineParser.add_argument("--num-elements", dest='numElements', metavar="<num-elements>",
                                 type=to_positive_multiple_of_10, default=100,
                                 help="The maximal number of elements per container sequence. (Default=100)")
      cmdlineParser.add_argument(dest='sourceDir', metavar="<source-dir>", default=current_boost_dir(), nargs='?',
                                 type=to_existing_absolute_path,
                                 help="The source-directory of Boost. (Default=\"" + sourceDir + "\")")
      args = cmdlineParser.parse_args()
  
      # Some verbose debug output.
      if args.verbose:
          print "Arguments extracted from command-line:"
          print "  verbose          = ", args.verbose
          print "  source directory = ", args.sourceDir
          print "  num elements     = ", args.numElements
          print "  sequence type    = ", args.seqType
          print "  want: vector     = ", args.want_vector
          print "  want: list       = ", args.want_list
          print "  want: set        = ", args.want_set
          print "  want: map        = ", args.want_map
  
      # Verify that we received any source-directory.
      if args.sourceDir == None:
          print "You should specify a valid path to the Boost source-directory."
          sys.exit(0)
  
      # The directories for header- and source files of Boost.MPL.
      # NOTE: Assuming 'args.sourceDir' is the source-directory of the entire boost project.
      headerDir = os.path.join( args.sourceDir, "boost", "mpl" )
      sourceDir = os.path.join( args.sourceDir, "libs", "mpl", "preprocessed" )
      # Check that the header/source-directories exist.
      if not os.path.exists( headerDir ) or not os.path.exists( sourceDir ):
          # Maybe 'args.sourceDir' is not the source-directory of the entire boost project
          # but instead of the Boost.MPL git-directory, only?
          headerDir = os.path.join( args.sourceDir, "include", "boost", "mpl" )
          sourceDir = os.path.join( args.sourceDir, "preprocessed" )
          if not os.path.exists( headerDir ) or not os.path.exists( sourceDir ):
              cmdlineParser.print_usage()
              print "error: Cannot find Boost.MPL header/source files in given Boost source-directory!"
              sys.exit(0)
  
      # Some verbose debug output.
      if args.verbose:
          print "Chosen header-directory: ", headerDir
          print "Chosen source-directory: ", sourceDir
  
      # Create list of containers for which files shall be pre-processed.
      containers = []
      if args.want_vector:
          containers.append('vector')
      if args.want_list:
          containers.append('list')
      if args.want_set:
          containers.append('set')
      if args.want_map:
          containers.append('map')
      if containers == []:
          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
  
      # Create (additional) input files for generating pre-processed headers of numbered sequence MPL containers.
      if args.seqType == "both" or args.seqType == "numbered":
          create_input_for_numbered_sequences(headerDir, sourceDir, containers, args.numElements)
      # Modify settings for generating pre-processed headers of variadic sequence MPL containers.
      if args.seqType == "both" or args.seqType == "variadic":
          adjust_container_limits_for_variadic_sequences(headerDir, containers, args.numElements)
  
      # Generate MPL-preprocessed files.
      os.chdir( sourceDir )
      if args.seqType == "both" or args.seqType == "numbered":
          if args.want_vector:
              if args.verbose:
                  print "Pre-process headers for Boost.MPL numbered vectors."
              os.system( "python " + os.path.join( sourceDir, "preprocess_vector.py" ) + " all " + args.sourceDir )
          if args.want_list:
              if args.verbose:
                  print "Pre-process headers for Boost.MPL numbered lists."
              os.system( "python " + os.path.join( sourceDir, "preprocess_list.py" ) + " all " + args.sourceDir )
          if args.want_set:
              if args.verbose:
                  print "Pre-process headers for Boost.MPL numbered sets."
              os.system( "python " + os.path.join( sourceDir, "preprocess_set.py" ) + " all " + args.sourceDir )
          if args.want_map:
              if args.verbose:
                  print "Pre-process headers for Boost.MPL numbered maps."
              os.system( "python " + os.path.join( sourceDir, "preprocess_map.py" ) + " all " + args.sourceDir )
      if args.seqType == "both" or args.seqType == "variadic":
          if args.verbose:
              print "Pre-process headers for Boost.MPL variadic containers."
          os.system( "python " + os.path.join( sourceDir, "preprocess.py" ) + " all " + args.sourceDir )
function_tokens: def main ( ) : # Find the current Boost source-directory in which this script is located. sourceDir = current_boost_dir ( ) if sourceDir == None : sourceDir = "" # Prepare and run cmdline-parser. cmdlineParser = argparse . ArgumentParser ( description = "A generator-script for pre-processed Boost.MPL headers." ) cmdlineParser . add_argument ( "-v" , "--verbose" , dest = 'verbose' , action = 'store_true' , help = "Be a little bit more verbose." ) cmdlineParser . add_argument ( "-s" , "--sequence-type" , dest = 'seqType' , choices = [ 'variadic' , 'numbered' , 'both' ] , default = 'both' , help = "Only update pre-processed headers for the selected sequence types, " "either 'numbered' sequences, 'variadic' sequences or 'both' sequence " "types. (Default=both)" ) cmdlineParser . add_argument ( "--no-vector" , dest = 'want_vector' , action = 'store_false' , help = "Do not update pre-processed headers for Boost.MPL Vector." ) cmdlineParser . add_argument ( "--no-list" , dest = 'want_list' , action = 'store_false' , help = "Do not update pre-processed headers for Boost.MPL List." ) cmdlineParser . add_argument ( "--no-set" , dest = 'want_set' , action = 'store_false' , help = "Do not update pre-processed headers for Boost.MPL Set." ) cmdlineParser . add_argument ( "--no-map" , dest = 'want_map' , action = 'store_false' , help = "Do not update pre-processed headers for Boost.MPL Map." ) cmdlineParser . add_argument ( "--num-elements" , dest = 'numElements' , metavar = "<num-elements>" , type = to_positive_multiple_of_10 , default = 100 , help = "The maximal number of elements per container sequence. (Default=100)" ) cmdlineParser . add_argument ( dest = 'sourceDir' , metavar = "<source-dir>" , default = current_boost_dir ( ) , nargs = '?' , type = to_existing_absolute_path , help = "The source-directory of Boost. (Default=\"" + sourceDir + "\")" ) args = cmdlineParser . parse_args ( ) # Some verbose debug output. if args . verbose : print "Arguments extracted from command-line:" print "  verbose          = " , args . verbose print "  source directory = " , args . sourceDir print "  num elements     = " , args . numElements print "  sequence type    = " , args . seqType print "  want: vector     = " , args . want_vector print "  want: list       = " , args . want_list print "  want: set        = " , args . want_set print "  want: map        = " , args . want_map # Verify that we received any source-directory. if args . sourceDir == None : print "You should specify a valid path to the Boost source-directory." sys . exit ( 0 ) # The directories for header- and source files of Boost.MPL. # NOTE: Assuming 'args.sourceDir' is the source-directory of the entire boost project. headerDir = os . path . join ( args . sourceDir , "boost" , "mpl" ) sourceDir = os . path . join ( args . sourceDir , "libs" , "mpl" , "preprocessed" ) # Check that the header/source-directories exist. if not os . path . exists ( headerDir ) or not os . path . exists ( sourceDir ) : # Maybe 'args.sourceDir' is not the source-directory of the entire boost project # but instead of the Boost.MPL git-directory, only? headerDir = os . path . join ( args . sourceDir , "include" , "boost" , "mpl" ) sourceDir = os . path . join ( args . sourceDir , "preprocessed" ) if not os . path . exists ( headerDir ) or not os . path . exists ( sourceDir ) : cmdlineParser . print_usage ( ) print "error: Cannot find Boost.MPL header/source files in given Boost source-directory!" sys . exit ( 0 ) # Some verbose debug output. if args . verbose : print "Chosen header-directory: " , headerDir print "Chosen source-directory: " , sourceDir # Create list of containers for which files shall be pre-processed. containers = [ ] if args . want_vector : containers . append ( 'vector' ) if args . want_list : containers . append ( 'list' ) if args . want_set : containers . append ( 'set' ) if args . want_map : containers . append ( 'map' ) if containers == [ ] : 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 # Create (additional) input files for generating pre-processed headers of numbered sequence MPL containers. if args . seqType == "both" or args . seqType == "numbered" : create_input_for_numbered_sequences ( headerDir , sourceDir , containers , args . numElements ) # Modify settings for generating pre-processed headers of variadic sequence MPL containers. if args . seqType == "both" or args . seqType == "variadic" : adjust_container_limits_for_variadic_sequences ( headerDir , containers , args . numElements ) # Generate MPL-preprocessed files. os . chdir ( sourceDir ) if args . seqType == "both" or args . seqType == "numbered" : if args . want_vector : if args . verbose : print "Pre-process headers for Boost.MPL numbered vectors." os . system ( "python " + os . path . join ( sourceDir , "preprocess_vector.py" ) + " all " + args . sourceDir ) if args . want_list : if args . verbose : print "Pre-process headers for Boost.MPL numbered lists." os . system ( "python " + os . path . join ( sourceDir , "preprocess_list.py" ) + " all " + args . sourceDir ) if args . want_set : if args . verbose : print "Pre-process headers for Boost.MPL numbered sets." os . system ( "python " + os . path . join ( sourceDir , "preprocess_set.py" ) + " all " + args . sourceDir ) if args . want_map : if args . verbose : print "Pre-process headers for Boost.MPL numbered maps." os . system ( "python " + os . path . join ( sourceDir , "preprocess_map.py" ) + " all " + args . sourceDir ) if args . seqType == "both" or args . seqType == "variadic" : if args . verbose : print "Pre-process headers for Boost.MPL variadic containers." os . system ( "python " + os . path . join ( sourceDir , "preprocess.py" ) + " all " + args . sourceDir )