[pygccxml-commit] SF.net SVN: pygccxml:[1585]
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-01-18 06:14:06
|
Revision: 1585 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1585&view=rev Author: roman_yakovenko Date: 2009-01-18 06:14:01 +0000 (Sun, 18 Jan 2009) Log Message: ----------- adding ability to configure compiler settings from the web UI Modified Paths: -------------- pygccxml_dev/pygccxml/parser/config.py ui/web/code_generator.py ui/web/config.py ui/web/form_processor.py Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2009-01-17 20:37:23 UTC (rev 1584) +++ pygccxml_dev/pygccxml/parser/config.py 2009-01-18 06:14:01 UTC (rev 1585) @@ -92,6 +92,9 @@ cflags = property( __get_cflags, __set_cflags , doc="additional flags to pass to compiler" ) + def append_cflags( self, val ): + self.__cflags = self.__cflags + ' ' + val + def __ensure_dir_exists( self, dir_path, meaning ): if os.path.isdir( dir_path ): return @@ -232,7 +235,7 @@ values = defaults if not values: values = {} - + if parser.has_section( 'gccxml' ): for name, value in parser.items( 'gccxml' ): if value.strip(): Modified: ui/web/code_generator.py =================================================================== --- ui/web/code_generator.py 2009-01-17 20:37:23 UTC (rev 1584) +++ ui/web/code_generator.py 2009-01-18 06:14:01 UTC (rev 1585) @@ -11,9 +11,9 @@ def __init__( self ): pass - def show_xml( self, file_configuration ): + def show_xml( self, file_configuration, compiler_config ): try: - reader = parser.project_reader_t( config=config.gccxml ) + reader = parser.project_reader_t( config=compiler_config ) content = reader.read_xml( file_configuration ) return content, '' #return xml.sax.saxutils.escape( content ), '' @@ -23,9 +23,9 @@ user_msg.append( str( error ) ) return '', '\n'.join( user_msg ) - def show_declarations( self, file_configuration ): + def show_declarations( self, file_configuration, compiler_config ): try: - reader = parser.project_reader_t( config=config.gccxml ) + reader = parser.project_reader_t( config=compiler_config ) decls = reader.read_files( [file_configuration] ) global_ns = declarations.get_global_namespace( decls ) tmp = [] @@ -37,13 +37,13 @@ user_msg.append( str( error ) ) return '', '\n'.join( user_msg ) - def generate_bpl_code( self, file_configuration ): + def generate_bpl_code( self, file_configuration, compiler_config ): try: _logging_.loggers.make_inmemory() mb = module_builder.module_builder_t( [ file_configuration ] - , gccxml_path=config.gccxml.gccxml_path - , compiler=config.gccxml.compiler) + , gccxml_path=compiler_config.gccxml_path + , compiler=compiler_config.compiler) mb.decls( header_dir=config.temp_dir ).include() mb.build_code_creator( "pyplusplus" ) code = mb.code_creator.create() @@ -58,10 +58,10 @@ user_msg.append( str( error ) ) return '', '\n'.join( user_msg ) - def generate_ctypes_code( self, file_configuration, symbols_file ): + def generate_ctypes_code( self, file_configuration, symbols_file, compiler_config ): try: _logging_.loggers.make_inmemory() - mb = ctypes_module_builder_t( [ file_configuration ], symbols_file, config.gccxml ) + mb = ctypes_module_builder_t( [ file_configuration ], symbols_file, compiler_config ) mb.build_code_creator( symbols_file ) code = mb.code_creator.create() code = code.replace( '\n\r', '\n' ) @@ -74,11 +74,3 @@ user_msg.append( 'Error:' ) user_msg.append( str( error ) ) return '', '\n'.join( user_msg ) - - - - -if __name__ == '__main__': - m = manager_t() - m.generate_bpl_code( 'int do_smth( int &);int do_smth( int, int);' ) - Modified: ui/web/config.py =================================================================== --- ui/web/config.py 2009-01-17 20:37:23 UTC (rev 1584) +++ ui/web/config.py 2009-01-18 06:14:01 UTC (rev 1585) @@ -6,7 +6,7 @@ this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) ) projects_root_dir = os.path.dirname( os.path.dirname( this_module_dir_path ) ) -sys.path.insert( 0, os.path.join( this_module_dir_path, 'web.zip' ) ) +#~ sys.path.insert( 0, os.path.join( this_module_dir_path, 'web.zip' ) ) if os.path.exists( os.path.join( projects_root_dir, 'pygccxml_dev' ) ): sys.path.append( os.path.join( projects_root_dir, 'pygccxml_dev' ) ) @@ -14,13 +14,10 @@ sys.path.append( os.path.join( projects_root_dir, 'pyplusplus_dev' ) ) #else use installed modules -from pygccxml import parser -from pyplusplus import module_builder +import pygccxml -gccxml_path = os.path.join( projects_root_dir, 'gccxml_bin', 'v09', sys.platform, 'bin' ) -if os.path.exists( gccxml_path ): - gccxml = parser.config_t( gccxml_path=gccxml_path ) -else: #use gccxml from PATH - gccxml = parser.config_t() +gccxml = pygccxml.parser.load_gccxml_configuration( os.path.join( this_module_dir_path, 'gccxml.cfg' ) + , gccxml_path=os.path.join( projects_root_dir, 'gccxml_bin', 'v09', sys.platform, 'bin' ) + , compiler=pygccxml.utils.native_compiler.get_gccxml_compiler() ) temp_dir = tempfile.gettempdir() Modified: ui/web/form_processor.py =================================================================== --- ui/web/form_processor.py 2009-01-17 20:37:23 UTC (rev 1584) +++ ui/web/form_processor.py 2009-01-18 06:14:01 UTC (rev 1585) @@ -25,30 +25,45 @@ else: return parser.create_source_fc( self.__input[ file_key ] ) + def __create_gccxml_cfg( self ): + #in real web mode this functionality should be disabled + cfg = config.gccxml.clone() + + include_dirs = self.__input['COMPILER_INCLUDE_DIRECTORIES'] + include_dirs = include_dirs.split('\n') + cfg.include_paths.extend([ idir.strip() for idir in include_dirs ]) + + preprocessor_defs = self.__input['COMPILER_PREPROCESSOR_DEFINITIONS'] + cfg.append_cflags( preprocessor_defs.replace( '\n', ' ' ) ) + + additional_args = self.__input['COMPILER_CMD_ARGS'] + cfg.append_cflags( additional_args.replace( '\n', ' ' ) ) + return cfg + def on_view_xml( self ): fc = self.__create_fc( 'GCCXML' ) - decls_tree, warnings = self.__code_generator.show_xml( fc ) + decls_tree, warnings = self.__code_generator.show_xml( fc, compiler_config=self.__create_gccxml_cfg() ) return decls_tree, warnings def on_view_decls( self ): fc = self.__create_fc( 'GCCXML' ) - decls_tree, warnings = self.__code_generator.show_declarations( fc ) + decls_tree, warnings = self.__code_generator.show_declarations( fc, compiler_config=self.__create_gccxml_cfg() ) return decls_tree, warnings def on_generate_bpl_code( self ): fc = self.__create_fc( 'BPL' ) - code, warnings = self.__code_generator.generate_bpl_code( fc ) + code, warnings = self.__code_generator.generate_bpl_code( fc, compiler_config=self.__create_gccxml_cfg() ) return code, warnings def on_generate_bpl_pypp_code( self ): w = wizard.wizard_t() - code = w.create_bpl_code( config.gccxml, self.__create_fc( 'BPL' ) ) + code = w.create_bpl_code( self.__create_gccxml_cfg(), self.__create_fc( 'BPL' ) ) return code, '' def on_generate_ctypes_code( self ): fc = parser.create_source_fc( self.__input[ "CTYPES_FILE_NAME" ] ) symbols_file = self.__input[ "CTYPES_SHLIB_FILE_NAME" ] - code, warnings = self.__code_generator.generate_ctypes_code( fc, symbols_file ) + code, warnings = self.__code_generator.generate_ctypes_code( fc, symbols_file, compiler_config=self.__create_gccxml_cfg() ) return code, warnings def on_generate_ctypes_pypp_code( self ): @@ -67,16 +82,3 @@ def process( self ): handler = self.__select_handler() return handler() - - - #~ source_code = request_data[ self.__source_code.name] - #~ if self.__show_decls.name in request_data: - #~ generated = self.__code_generator.show_declarations( source_code ) - #~ elif self.__generate_pypp_code.name in request_data: - #~ generated = self.__code_generator.generate_pypp_code( source_code ) - #~ elif self.__generate_bpl_code.name in request_data: - #~ generated, warnings = self.__code_generator.generate_bpl_code( source_code ) - #~ else: - #~ generated = 'error - unknown submit action' - #~ return generated, warnings - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |