File: gcc2tasks.pl

package info (click to toggle)
qtcreator 18.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 261,164 kB
  • sloc: cpp: 1,581,559; ansic: 528,781; python: 48,245; xml: 34,678; javascript: 15,495; sh: 2,670; asm: 2,049; perl: 1,039; lex: 737; java: 695; objc: 409; makefile: 111; yacc: 86; cs: 41; ruby: 33; sed: 22
file content (34 lines) | stat: -rwxr-xr-x 916 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w

# Copyright (C) 2016 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

=head1 NAME

msvc2tasks.pl - Convert GCC warnings into Qt Creator task files.

=head1 SYNOPSIS

    gcc2tasks.pl < logfile > taskfile

=cut

use strict;

my $count = 0;
while (my $line = <STDIN> ) {
    chomp($line);
    # --- extract file name based matching:
    # file.cpp:214:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    if ($line =~ /^([^:]+):(\d+):\d*:? (warning|error|fatal error): (.*)$/) {
        my $fileName = $1;
        my $lineNumber = $2;
        my $type = $3 eq 'warning' ? 'warn' : 'err';
        my $text = $4;
        $fileName =~ s|\\|/|g;
        print $fileName, "\t", $lineNumber, "\t", $type, "\t", $text,"\n";
        $count++;
    }
}

print STDERR $count, " issue(s) found.\n" if $count;