KDevelop API Documentation

kdevdriver.cpp

Go to the documentation of this file.
00001 #include <lexer.h>
00002 
00003 #include <kdevdriver.h>
00004 #include <unistd.h>
00005 
00006 KDevDriver::KDevDriver( CppSupportPart* cppSupport )
00007     : m_cppSupport( cppSupport )
00008 {
00009     //setupProject();
00010     //setup();
00011 
00012     addMacro( Macro( "__cplusplus", "1" ) );
00013 }
00014 
00015 CppSupportPart* KDevDriver::cppSupport() { return m_cppSupport; }
00016 
00017 void KDevDriver::setupProject()
00018 {
00019     QMap<QString, bool> map;
00020 
00021     {
00022     QStringList fileList = m_cppSupport->project()->allFiles();
00023     QStringList::ConstIterator it = fileList.begin();
00024     while( it != fileList.end() ){
00025         QFileInfo info( *it );
00026         ++it;
00027 
00028         map.insert( info.dirPath(true), true );
00029     }
00030     }
00031 
00032     {
00033     QMap<QString, bool>::Iterator it = map.begin();
00034     while( it != map.end() ){
00035         addIncludePath( it.key() );
00036         ++it;
00037     }
00038     }
00039 }
00040 
00041 void KDevDriver::setupLexer( Lexer* lexer )
00042 {
00043     Driver::setupLexer( lexer );
00044     lexer->setReportMessages( true );
00045     lexer->setReportWarnings( true );
00046 }
00047 
00050 void KDevDriver::setup()
00051 {
00052     QString kdedir = getenv( "KDEDIR" );
00053     if( !kdedir.isNull() )
00054     addIncludePath( kdedir + "/include" );
00055 
00056     QString qtdir = getenv( "QTDIR" );
00057     if( !qtdir.isNull() )
00058     addIncludePath( qtdir + "/include" );
00059 
00060     QString qmakespec = getenv( "QMAKESPEC" );
00061     if ( qmakespec.isNull() )
00062     qmakespec = "linux-g++";
00063     // #### implement other mkspecs and find a better way to find the
00064     // #### proper mkspec (althoigh this will be no fun :-)
00065 
00066     addIncludePath( qtdir + "/mkspecs/" + qmakespec );
00067     if ( qmakespec == "linux-g++" ) {
00068     addIncludePath( "/include" );
00069     addIncludePath( "/usr/include" );
00070     addIncludePath( "/usr/local/include" );
00071 #if KDE_VERSION <= 305
00072     return; 
00073     // If the QProcess from below is executed,
00074     // it somehow breaks the gcc call in parts/outputviews/makewidget.cpp. :-(
00075     // It then has the effect that KProcess will never exit, at least on KDE-3.0
00076 #endif // KDE_VERSION
00077     QProcess proc;
00078     proc.addArgument( "gcc" );
00079     proc.addArgument( "-print-file-name=include" );
00080     if ( !proc.start() ) {
00081         qWarning( "Couldn't start gcc" );
00082         return;
00083     }
00084     while ( proc.isRunning() )
00085         usleep( 1 );
00086 
00087     addIncludePath( proc.readStdout() );
00088     addIncludePath( "/usr/include/g++-3" );
00089     addIncludePath( "/usr/include/g++" );
00090     proc.clearArguments();
00091     proc.addArgument( "gcc" );
00092     proc.addArgument( "-E" );
00093     proc.addArgument( "-dM" );
00094     proc.addArgument( "-ansi" );
00095     proc.addArgument( "-" );
00096     if ( !proc.start() ) {
00097         qWarning( "Couldn't start gcc" );
00098         return;
00099     }
00100     while ( !proc.isRunning() )
00101         usleep( 1 );
00102     proc.closeStdin();
00103     while ( proc.isRunning() )
00104         usleep( 1 );
00105     while ( proc.canReadLineStdout() ) {
00106         QString l = proc.readLineStdout();
00107         QStringList lst = QStringList::split( ' ', l );
00108         if ( lst.count() != 3 )
00109         continue;
00110         addMacro( Macro( lst[1], lst[2] ) );
00111     }
00112     addMacro( Macro( "__cplusplus", "1" ) );
00113     } else if ( qmakespec == "win32-borland" ) {
00114     QString incl = getenv( "INCLUDE" );
00115     QStringList includePaths = QStringList::split( ';', incl );
00116     QStringList::Iterator it = includePaths.begin();
00117     while( it != includePaths.end() ){
00118         addIncludePath( *it );
00119         ++it;
00120     }
00121     // ### I am sure there are more standard include paths on
00122     // ### windows. I will fix that soon
00123     // ### Also do the compiler specific defines on windows
00124     }
00125 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:47 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003