<table><tr><td style="">akellermann added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D7040" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>Hi Morten,</p>

<p>I don't have a second patch and I left the lines pushing <tt style="background: #ebebeb; font-size: 13px;">m_buildDir.parent()</tt> to <tt style="background: #ebebeb; font-size: 13px;">m_currentDirs</tt> untouched, as this could act as a sensible fallback in case filtering of the absolute project path fails for some reason.<br />
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:</p>

<p>The first line of cmake output always contains the call to cmake in the form: <tt style="background: #ebebeb; font-size: 13px;">/path/to/cmake [OPTIONS] absPathToProjDir</tt><br />
The patch adds a regex to filter <tt style="background: #ebebeb; font-size: 13px;">absPathToProjDir</tt> out of the output to <tt style="background: #ebebeb; font-size: 13px;">actionInLine(const QString& line)</tt> using the application tag <tt style="background: #ebebeb; font-size: 13px;">cd</tt>.</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">ActionFormat( QStringLiteral("cd"),
    QStringLiteral("(?:/|\\\\)cmake (?:.*?)( (?:(?:[A-Za-z]:)+\\\\|/).*$)"), 1),</pre></div>

<p>As the application tag <tt style="background: #ebebeb; font-size: 13px;">cd</tt> is used, <tt style="background: #ebebeb; font-size: 13px;">absPathToProjDir</tt> is added to <tt style="background: #ebebeb; font-size: 13px;">m_currentDirs</tt> after the first line is processed.</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">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 );
}</pre></div>

<p>That in turn means, that <tt style="background: #ebebeb; font-size: 13px;">m_currentDirs</tt> isn't empty anymore, and pushing <tt style="background: #ebebeb; font-size: 13px;">m_buildDir.parent()</tt> is skipped and only acts as a fallback if something went wrong previously.</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">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() );
    }
}</pre></div>

<p>If all the above is correct, I think the following code could just be removed.</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">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();
}</pre></div>

<p>Thoughts?</p>

<p>Thanks,<br />
Axel</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R33 KDevPlatform</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D7040" rel="noreferrer">https://phabricator.kde.org/D7040</a></div></div><br /><div><strong>To: </strong>akellermann, kfunk<br /><strong>Cc: </strong>volden, kdevelop-devel, geetamc, Pilzschaf, akshaydeo, surgenight, arrowdodger<br /></div>