Package pygccxml :: Package parser :: Module config

Source Code for Module pygccxml.parser.config

  1  # Copyright 2004-2008 Roman Yakovenko.
 
  2  # Distributed under the Boost Software License, Version 1.0. (See
 
  3  # accompanying file LICENSE_1_0.txt or copy at
 
  4  # http://www.boost.org/LICENSE_1_0.txt)
 
  5  
 
  6  """This module contains the implementation of the L{config_t} class.
 
  7  """ 
  8  
 
  9  import os 
 10  import sys 
 11  import copy 
12 13 -class parser_configuration_t(object):
14 """Configuration object to collect parameters for invoking C++ parser 15 16 This class serves as a base class for the parameters that can be used 17 to customize the call to C++ parser. This class also allows users to work with 18 relative files paths. In this case files are searched in the following order: 19 20 1. current directory 21 22 2. working directory 23 24 3. additional include paths specified by the user 25 26 """
27 - def __init__( self 28 , working_directory='.' 29 , include_paths=None 30 , define_symbols=None 31 , undefine_symbols=None 32 , cflags="" 33 , compiler=None):
34 """Constructor. 35 """ 36 object.__init__( self ) 37 self.__working_directory = working_directory 38 39 if not include_paths: 40 include_paths = [] 41 self.__include_paths = include_paths 42 43 if not define_symbols: 44 define_symbols = [] 45 self.__define_symbols = define_symbols 46 47 if not undefine_symbols: 48 undefine_symbols = [] 49 self.__undefine_symbols = undefine_symbols 50 51 self.__cflags = cflags 52 53 self.__compiler = compiler
54
55 - def clone(self):
56 raise NotImplementedError( self.__class__.__name__ )
57
58 - def __get_working_directory(self):
59 return self.__working_directory
60 - def __set_working_directory(self, working_dir):
61 self.__working_directory=working_dir
62 working_directory = property( __get_working_directory, __set_working_directory ) 63 64 @property
65 - def include_paths(self):
66 """list of include paths to look for header files""" 67 return self.__include_paths
68 69 @property
70 - def define_symbols(self):
71 """list of "define" directives """ 72 return self.__define_symbols
73 74 @property
75 - def undefine_symbols(self):
76 """list of "undefine" directives """ 77 return self.__undefine_symbols
78 79 @property
80 - def compiler(self):
81 """compiler name to simulate""" 82 return self.__compiler
83
84 - def __get_cflags(self):
85 return self.__cflags
86 - def __set_cflags(self, val):
87 self.__cflags = val
88 cflags = property( __get_cflags, __set_cflags 89 , doc="additional flags to pass to compiler" ) 90
91 - def __ensure_dir_exists( self, dir_path, meaning ):
92 if os.path.isdir( dir_path ): 93 return 94 msg = None 95 if os.path.exists( self.working_directory ): 96 raise RuntimeError( '%s("%s") does not exist!' % ( meaning, dir_path ) ) 97 else: 98 raise RuntimeError( '%s("%s") should be "directory", not a file.' % ( meaning, dir_path ) )
99 100
101 - def raise_on_wrong_settings( self ):
102 """validates the configuration settings and raises RuntimeError on error""" 103 self.__ensure_dir_exists( self.working_directory, 'working directory' ) 104 map( lambda idir: self.__ensure_dir_exists( idir, 'include directory' ) 105 , self.include_paths )
106
107 108 -class gccxml_configuration_t(parser_configuration_t):
109 """Configuration object to collect parameters for invoking gccxml. 110 111 This class serves as a container for the parameters that can be used 112 to customize the call to gccxml. 113 """
114 - def __init__( self 115 , gccxml_path='' 116 , working_directory='.' 117 , include_paths=None 118 , define_symbols=None 119 , undefine_symbols=None 120 , start_with_declarations=None 121 , ignore_gccxml_output=False 122 , cflags="" 123 , compiler=None):