gccparser.cpp 4.32 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
#include "gccparser.h"
31
#include "projectexplorerconstants.h"
32
#include "taskwindow.h"
con's avatar
con committed
33

34
using namespace ProjectExplorer;
con's avatar
con committed
35
36
37

GccParser::GccParser()
{
38
    m_regExp.setPattern("^([^\\(\\)]+[^\\d]):(\\d+):(\\d+:)*(\\s(warning|error):)?\\s(.+)$");
con's avatar
con committed
39
40
41
42
43
    m_regExp.setMinimal(true);

    m_regExpIncluded.setPattern("^.*from\\s([^:]+):(\\d+)(,|:)$");
    m_regExpIncluded.setMinimal(true);

44
    m_regExpLinker.setPattern("^(\\S*)\\(\\S+\\):\\s(.+)$");
con's avatar
con committed
45
46
47
    m_regExpLinker.setMinimal(true);

    //make[4]: Entering directory `/home/kkoehne/dev/ide-explorer/src/plugins/qtscripteditor'
48
    m_makeDir.setPattern("^(?:mingw32-)?make.*: (\\w+) directory .(.+).$");
con's avatar
con committed
49
50
51
52
53
    m_makeDir.setMinimal(true);
}

QString GccParser::name() const
{
54
    return QLatin1String(ProjectExplorer::Constants::BUILD_PARSER_GCC);
con's avatar
con committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
}

void GccParser::stdOutput(const QString & line)
{
    QString lne = line.trimmed();

    if (m_makeDir.indexIn(lne) > -1) {
        if (m_makeDir.cap(1) == "Leaving")
                emit leaveDirectory(m_makeDir.cap(2));
            else
                emit enterDirectory(m_makeDir.cap(2));
    }
}

void GccParser::stdError(const QString & line)
{
    QString lne = line.trimmed();
72
    if (m_regExpLinker.indexIn(lne) > -1) {
73
        QString description = m_regExpLinker.cap(2);
74
75
76
77
78
        emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
                                              description,
                                              m_regExpLinker.cap(1) /* filename */,
                                              -1 /* linenumber */,
                                              Constants::TASK_CATEGORY_COMPILE));
79
    } else if (m_regExp.indexIn(lne) > -1) {
80
81
82
83
84
        TaskWindow::Task task(TaskWindow::Unknown,
                              m_regExp.cap(6) /* description */,
                              m_regExp.cap(1) /* filename */,
                              m_regExp.cap(2).toInt() /* line number */,
                              Constants::TASK_CATEGORY_COMPILE);
con's avatar
con committed
85
        if (m_regExp.cap(5) == "warning")
86
            task.type = TaskWindow::Warning;
con's avatar
con committed
87
        else if (m_regExp.cap(5) == "error")
88
            task.type = TaskWindow::Error;
con's avatar
con committed
89

90
        emit addToTaskWindow(task);
con's avatar
con committed
91
    } else if (m_regExpIncluded.indexIn(lne) > -1) {
92
93
94
95
96
97
98
99
100
101
102
103
104
        emit addToTaskWindow(TaskWindow::Task(TaskWindow::Unknown,
                                              lne /* description */,
                                              m_regExpIncluded.cap(1) /* filename */,
                                              m_regExpIncluded.cap(2).toInt() /* linenumber */,
                                              Constants::TASK_CATEGORY_COMPILE));
    } else if (lne.startsWith(QLatin1String("collect2:")) ||
               lne.startsWith(QLatin1String("ERROR:")) ||
               lne == QLatin1String("* cpp failed")) {
        emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
                                              lne /* description */,
                                              QString() /* filename */,
                                              -1 /* linenumber */,
                                              Constants::TASK_CATEGORY_COMPILE));
Tobias Hunger's avatar
Tobias Hunger committed
105
106
    }
}