make_filter 2.36 KB
Newer Older
1
#! /usr/bin/perl -w
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#
# Copyright 1999, 2000, 2001 Patrik Stridvall
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18
#
19 20 21 22 23 24 25 26

use strict;

BEGIN {
    $0 =~ m%^(.*?/?tools)/winapi/make_filter$%;
    require "$1/winapi/setup.pm";
}

Patrik Stridvall's avatar
Patrik Stridvall committed
27
use config qw(
28
    file_absolutize file_normalize
Patrik Stridvall's avatar
Patrik Stridvall committed
29 30
    $current_dir $wine_dir
);
31 32 33
use output qw($output);
use make_filter_options qw($options);

Patrik Stridvall's avatar
Patrik Stridvall committed
34
use make_parser qw($directory $tool $file $line $message);
35 36 37 38 39 40 41 42 43 44 45

if($options->progress) {
    $output->enable_progress;
} else {
    $output->disable_progress;
}

########################################################################
# main
########################################################################

Patrik Stridvall's avatar
Patrik Stridvall committed
46
my $command = $options->make . " " . join(" ", $options->arguments);
47
open(IN, "($command) 2>&1 |") || die "Cannot execute command $command: $!";
48

49
while(<IN>) {
50 51
    chomp;

52
    if(!make_parser::line($_)) {
53 54 55
	next;
    }

Patrik Stridvall's avatar
Patrik Stridvall committed
56
    if($message) {
57
	if($file && $line) {
58
	    if($directory && $directory ne "." && $file !~ m%^/%) {
59
		$output->write(file_normalize("$directory/$file") . ":$line: $message\n");
60 61 62 63
	    } else {
		$output->write("$file:$line: $message\n");
	    }
	} elsif($file) {
64
	    if($directory && $directory ne "." && $file !~ m%^/%) {
65
		$output->write(file_normalize("$directory/$file") . ": $message\n");
66 67 68 69
	    } else {
		$output->write("$file: $message\n");
	    }
	} else {
Patrik Stridvall's avatar
Patrik Stridvall committed
70 71 72 73
	    if($directory && $directory ne ".") {
		$output->write("$directory: $tool: $message\n");
	    } elsif($tool) {
		$output->write("$tool: $message\n");
74
	    } else {
Patrik Stridvall's avatar
Patrik Stridvall committed
75
		$output->write("$message\n");
76 77
	    }
	}
Patrik Stridvall's avatar
Patrik Stridvall committed
78 79 80 81
    } elsif($tool eq "make") {
	if($directory && $directory ne ".") {
	    $output->progress("$directory: make");
	}
82 83 84 85 86 87
    }
}

close(IN);

$output->hide_progress();