D7040: OutputFilteringStrategies: Parse cmake output for project directory and use it in OutputView

Axel Kellermann noreply at phabricator.kde.org
Fri Aug 4 11:55:16 UTC 2017


akellermann added a comment.


  Hi Morten,
  
  I don't have a second patch and I left the lines pushing `m_buildDir.parent()` to `m_currentDirs` untouched, as this could act as a sensible fallback in case filtering of the absolute project path fails for some reason.
  But maybe I just give you some more context by explaining what I think the patch is doing, and you can then intervene if any of my assumptions aren't correct. So here we go:
  
  The first line of cmake output always contains the call to cmake in the form: `/path/to/cmake [OPTIONS] absPathToProjDir`
  The patch adds a regex to filter `absPathToProjDir` out of the output to `actionInLine(const QString& line)` using the application tag `cd`.
  
    ActionFormat( QStringLiteral("cd"),
        QStringLiteral("(?:/|\\\\)cmake (?:.*?)( (?:(?:[A-Za-z]:)+\\\\|/).*$)"), 1),
  
  As the application tag `cd` is used, `absPathToProjDir` is added to `m_currentDirs` after the first line is processed.
  
    if( curActFilter.tool == QLatin1String("cd") ) {
        const Path path(match.captured(curActFilter.fileGroup));
        printf("actionInLine: put path into currentDirs\n");
        d->m_currentDirs.push_back( path );
        d->m_positionInCurrentDirs.insert( path , d->m_currentDirs.size() - 1 );
    }
  
  That in turn means, that `m_currentDirs` isn't empty anymore, and pushing `m_buildDir.parent()` is skipped and only acts as a fallback if something went wrong previously.
  
    if( curErrFilter.compiler == QLatin1String("cmake") ) { // Unfortunately we cannot know if an error or an action comes first in cmake, and therefore we need to do this
        if( d->m_currentDirs.empty() ) {
            d->putDirAtEnd( d->m_buildDir.parent() );
        }
    }
  
  If all the above is correct, I think the following code could just be removed.
  
    if(curErrFilter.fileGroup > 0) {
        if( curErrFilter.compiler == QLatin1String("cmake") ) { // Unfortunately we cannot know if an error or an action comes first in cmake, and therefore we need to do this
            if( d->m_currentDirs.empty() ) {
                printf("errorInLine1: put parent into m_currentDirs\n");
                d->putDirAtEnd( d->m_buildDir.parent() );
            }
        }
        item.url = d->pathForFile( match.captured( curErrFilter.fileGroup ) ).toUrl();
    }
  
  Thoughts?
  
  Thanks,
  Axel

REPOSITORY
  R33 KDevPlatform

REVISION DETAIL
  https://phabricator.kde.org/D7040

To: akellermann, kfunk
Cc: volden, kdevelop-devel, geetamc, Pilzschaf, akshaydeo, surgenight, arrowdodger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170804/486bf46b/attachment-0001.html>


More information about the KDevelop-devel mailing list