[pygccxml-commit] SF.net SVN: pygccxml: [835] installers/install_gccxml.1.py
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-01-02 21:32:53
|
Revision: 835 http://svn.sourceforge.net/pygccxml/?rev=835&view=rev Author: roman_yakovenko Date: 2007-01-02 13:32:53 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Added Paths: ----------- installers/install_gccxml.1.py Added: installers/install_gccxml.1.py =================================================================== --- installers/install_gccxml.1.py (rev 0) +++ installers/install_gccxml.1.py 2007-01-02 21:32:53 UTC (rev 835) @@ -0,0 +1,99 @@ +#step 1 - extract cmake +import os +import re +import sys +import utils +import config +import shutil +import tempfile + +def build_gccxml(working_dir): + utils.logger.info( 'create environment for building GCC_XML' ) + gccxml_src_dir = os.path.join( working_dir, os.path.splitext( config.archives.gccxml )[0] ) + build_dir = gccxml_src_dir + '-build' + + if not os.path.exists( build_dir ): + utils.logger.info( 'creating GCC_XML build directory "%s"' % build_dir ) + os.makedirs( build_dir ) + utils.logger.info( 'creating GCC_XML build directory "%s" - done' % build_dir ) + else: + utils.logger.info( 'GCC_XML build directory "%s" already exists' % build_dir ) + + if os.path.exists( config.gccxml_install_dir ): + utils.logger.info( 'creating GCC_XML install directory "%s"' % config.gccxml_install_dir) + shutil.rmtree( config.gccxml_install_dir ) + utils.logger.info( 'creating GCC_XML install directory "%s"- done' % config.gccxml_install_dir ) + else: + utils.logger.info( 'GCC_XML install directory "%s" already exists' % config.gccxml_install_dir) + + os.chdir( build_dir ) + + cmake = os.path.join( working_dir + , os.path.splitext( config.archives.cmake )[0] + , 'bin' + , 'cmake' ) + + utils.execute( cmake + , '-DCMAKE_INSTALL_PREFIX:PATH=' + config.gccxml_install_dir + , '-DCMAKE_BUILD_TYPE=release' + , '-G "%s"' % config.cmake.generator + , gccxml_src_dir ) + + utils.execute( config.cmake.native_build ) + if 'win32' == sys.platform: + #On windows GCC_XML does not support installation, so this setup will + #do it. + gccxml_config_file = os.path.join( build_dir, 'bin', 'gccxml_config' ) + gccxml_config = file( gccxml_config_file ).read() + gccxml_config = gccxml_config.replace( 'GCCXML_COMPILER="cl"' + , 'GCCXML_COMPILER="%s"' % config.cmake.compiler ) + + gccxml_root_re = re.compile( r'GCCXML_ROOT=\".*?\"' ) + found = gccxml_root_re.search( gccxml_config ) + gccxml_new_root = 'GCCXML_ROOT="%s"' % config.gccxml_install_dir + gccxml_new_root = gccxml_new_root.replace( '\\', '/' ) + gccxml_config = gccxml_config[:found.start()] + gccxml_new_root + gccxml_config[found.end():] + tmp = file( gccxml_config_file, 'w+' ) + tmp.write( gccxml_config ) + tmp.close() + utils.logger.info( 'copying GCC_XML files to the install directory' ) + shutil.copytree( os.path.join( build_dir, 'bin' ), config.gccxml_install_dir ) + utils.logger.info( 'copying GCC_XML files to the install directory - done' ) + else: + utils.execute( config.cmake.native_build, 'install' ) + utils.logger.info( 'removing GCC_XML build directory' ) + shutil.rmtree( build_dir, True ) + utils.logger.info( 'removing GCC_XML build directory - done' ) + +if __name__ == "__main__": + if 2 == len(sys.argv): + config.gccxml_install_dir = sys.argv[1] + else: + config.gccxml_install_dir = utils.ask_directory( "Select directory GCC_XML will be installed in" ) + if not config.gccxml_install_dir: + utils.logger.info( 'If you want to install GCC_XML you have to provide a directory it will be installed in.' ) + sys.exit(1) + else: + utils.logger.info( 'GCC_XML will be installed in "%s" directory.' % config.gccxml_install_dir) + + utils.logger.info( 'creating temporal directory ...') + working_dir = tempfile.mkdtemp( dir=tempfile.gettempdir() ) + utils.logger.info( 'creating temporal directory - done( "%s" )' % working_dir) + + try: + #decompressing all archives + for arch in config.archives.all: + utils.logger.info( 'extracting "%s"' % arch ) + utils.tar_extract_all( arch, working_dir ) + utils.logger.info( 'extracting "%s" - done' % arch ) + + build_gccxml(working_dir) + + finally: + utils.logger.info( 'removing temporal directory "%s"' % working_dir ) + shutil.rmtree( working_dir ) + utils.logger.info( 'removing temporal directory "%s" - done' % working_dir ) + + utils.logger.info( 'GCC_XML was successfully installed in "%s" directory' % config.gccxml_install_dir ) + utils.logger.info( 'Uninstall instruction - delete GCC_XML install directory.' ) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |