123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824 |
- #
- # 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
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- #
- package make_parser;
- use strict;
- use warnings 'all';
- use setup qw($current_dir $wine_dir $winapi_dir);
- use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT = qw();
- @EXPORT_OK = qw($directory $tool $file $line $message);
- use vars qw($directory $tool $file $line $message);
- use output qw($output);
- use options qw($options);
- #sub command($);
- #sub gcc_output($$);
- #sub ld_output($$);
- #sub make_output($$);
- #sub winebuild_output($$);
- #sub wmc_output($$);
- #sub wrc_output($$);
- ########################################################################
- # global
- ########################################################################
- my $current;
- my $function;
- ########################################################################
- # error
- ########################################################################
- sub error($) {
- my $where = shift;
- if(!defined($where)) {
- $where = "";
- }
- my $context;
- if($tool) {
- $context = "$tool";
- if($where) {
- $context .= "<$where>";
- }
- } else {
- if($where) {
- $context = "<$where>";
- } else {
- $context = "<>";
- }
- }
- if(defined($tool)) {
- $output->write("$directory: $context: can't parse output: '$current'\n");
- } else {
- $output->write("$directory: $context: can't parse output: '$current'\n");
- }
- exit 1;
- }
- ########################################################################
- # make_output
- ########################################################################
- sub make_output($$) {
- my $level = shift;
- local $_ = shift;
- $file = "";
- $message = "";
- if(/^\*\*\* \[(.*?)\] Error (\d+)$/) {
- # Nothing
- } elsif(/^\*\*\* Error code (\d+)$/) {
- # Nothing
- } elsif(/^\*\*\* Warning:\s+/) { #
- if(/^File \`(.+?)\' has modification time in the future \((.+?) > \(.+?\)\)$/) {
- # Nothing
- } else {
- error("make_output");
- }
- } elsif(/^\`(.*?)\' is up to date.$/) {
- # Nothing
- } elsif(/^\[(.*?)\] Error (\d+) \(ignored\)$/) {
- # Nothing
- } elsif(/^don\'t know how to make (.*?)\. Stop$/) {
- $message = "$_";
- } elsif(/^(Entering|Leaving) directory \`(.*?)\'$/) {
- if($1 eq "Entering") {
- $directory = $2;
- } else {
- $directory = "";
- }
- my @components;
- foreach my $component (split(/\//, $directory)) {
- if($component eq "wine") {
- @components = ();
- } else {
- push @components, $component;
- }
- }
- $directory = join("/", @components);
- } elsif(/^(.*?) is older than (.*?), please rerun (.*?)\$/) {
- # Nothing
- } elsif(/^Nothing to be done for \`(.*?)\'\.$/) {
- # Nothing
- } elsif(s/^warning:\s+//) {
- if(/^Clock skew detected. Your build may be incomplete.$/) {
- # Nothing
- } else {
- error("make_output");
- }
- } elsif(/^Stop in (.*?)\.$/) {
- # Nothing
- } elsif(/^\s*$/) {
- # Nothing
- } else {
- error("make_output");
- }
- }
- ########################################################################
- # ar_command
- ########################################################################
- sub ar_command($) {
- local $_ = shift;
- my $read_files;
- my $write_files;
- if(/rc\s+(\S+)(\s+\S+)+$/) {
- $write_files = [$1];
- $read_files = $2;
- $read_files =~ s/^\s*//;
- $read_files = [split(/\s+/, $read_files)];
- } else {
- error("ar_command");
- }
- return ($read_files, $write_files);
- }
- ########################################################################
- # as_command
- ########################################################################
- sub as_command($) {
- local $_ = shift;
- my $read_files;
- my $write_files;
- if(/-o\s+(\S+)\s+(\S+)$/) {
- $write_files = [$1];
- $read_files = [$2];
- } else {
- error("as_command");
- }
- return ($read_files, $write_files);
- }
- ########################################################################
- # bision_command
- ########################################################################
- sub bison_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # cd_command
- ########################################################################
- sub cd_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # cd_output
- ########################################################################
- sub cd_output($) {
- local $_ = shift;
- if(/^(.*?): No such file or directory/) {
- $message = "directory '$1' doesn't exist";
- }
- }
- ########################################################################
- # flex_command
- ########################################################################
- sub flex_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # for_command
- ########################################################################
- sub for_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # gcc_command
- ########################################################################
- sub gcc_command($) {
- my $read_files;
- my $write_files;
- if(/-o\s+(\S+)\s+(\S+)$/) {
- my $write_file = $1;
- my $read_file = $2;
- $write_file =~ s%^\./%%;
- $read_file =~ s%^\./%%;
- $write_files = [$write_file];
- $read_files = [$read_file];
- } elsif(/-o\s+(\S+)/) {
- my $write_file = $1;
- $write_file =~ s%^\./%%;
- $write_files = [$write_file];
- $read_files = ["<???>"];
- } elsif(/^-shared.*?-o\s+(\S+)/) {
- my $write_file = $1;
- $write_file =~ s%^\./%%;
- $write_files = [$write_file];
- $read_files = ["<???>"];
- } else {
- error("gcc_command");
- }
- return ($read_files, $write_files);
- }
- ########################################################################
- # gcc_output
- ########################################################################
- sub gcc_output($$) {
- $file = shift;
- local $_ = shift;
- if(s/^(\d+):\s+//) {
- $line = $1;
- if(s/^warning:\s+//) {
- my $suppress = 0;
- if(/^((?:signed |unsigned )?(?:int|long)) format, (different type|\S+) arg \(arg (\d+)\)$/) {
- my $type = $2;
- if($type =~ /^(?:
- HACCEL|HACMDRIVER|HANDLE|HBITMAP|HBRUSH|HCALL|HCURSOR|HDC|HDRVR|HDESK|HDRAWDIB
- HGDIOBJ|HKL|HGLOBAL|HIMC|HINSTANCE|HKEY|HLOCAL|
- HMENU|HMIDISTRM|HMIDIIN|HMIDIOUT|HMIXER|HMIXEROBJ|HMMIO|HMODULE|
- HLINE|HPEN|HPHONE|HPHONEAPP|
- HRASCONN|HRGN|HRSRC|HWAVEIN|HWAVEOUT|HWINSTA|HWND|
- SC_HANDLE|WSAEVENT|handle_t|pointer)$/x)
- {
- $suppress = 1;
- } else {
- $suppress = 0;
- }
- } elsif(/^\(near initialization for \`(.*?)\'\)$/) {
- $suppress = 0;
- } elsif(/^\`(.*?)\' defined but not used$/) {
- $suppress = 0;
- } elsif(/^\`(.*?)\' is not at beginning of declaration$/) {
- $suppress = 0;
- } elsif(/^\`%x\' yields only last 2 digits of year in some locales$/) {
- $suppress = 1;
- } elsif(/^assignment makes integer from pointer without a cast$/) {
- $suppress = 0;
- } elsif(/^assignment makes pointer from integer without a cast$/) {
- $suppress = 0;
- } elsif(/^assignment from incompatible pointer type$/) {
- $suppress = 0;
- } elsif(/^cast from pointer to integer of different size$/) {
- $suppress = 0;
- } elsif(/^comparison between pointer and integer$/) {
- $suppress = 0;
- } elsif(/^comparison between signed and unsigned$/) {
- $suppress = 0;
- } elsif(/^comparison of unsigned expression < 0 is always false$/) {
- $suppress = 0;
- } elsif(/^comparison of unsigned expression >= 0 is always true$/) {
- $suppress = 0;
- } elsif(/^conflicting types for built-in function \`(.*?)\'$/) {
- $suppress = 0;
- } elsif(/^empty body in an if-statement$/) {
- $suppress = 0;
- } elsif(/^empty body in an else-statement$/) {
- $suppress = 0;
- } elsif(/^implicit declaration of function \`(.*?)\'$/) {
- $suppress = 0;
- } elsif(/^initialization from incompatible pointer type$/) {
- $suppress = 0;
- } elsif(/^initialization makes pointer from integer without a cast$/) {
- $suppress = 0;
- } elsif(/^missing initializer$/) {
- $suppress = 0;
- } elsif(/^ordered comparison of pointer with integer zero$/) {
- $suppress = 0;
- } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') from incompatible pointer type$/) {
- $suppress = 0;
- } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes integer from pointer without a cast$/) {
- $suppress = 0;
- } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes pointer from integer without a cast$/) {
- $suppress = 0;
- } elsif(/^return makes integer from pointer without a cast$/) {
- $suppress = 0;
- } elsif(/^return makes pointer from integer without a cast$/) {
- $suppress = 0;
- } elsif(/^type of \`(.*?)\' defaults to \`(.*?)\'$/) {
- $suppress = 0;
- } elsif(/^unused variable \`(.*?)\'$/) {
- $suppress = 0;
- } elsif(!$options->pedantic) {
- $suppress = 0;
- } else {
- error("gcc_output");
- }
- if(!$suppress) {
- if($function) {
- $message = "function $function: warning: $_";
- } else {
- $message = "warning: $_";
- }
- } else {
- $message = "";
- }
- } elsif(/^\`(.*?)\' undeclared \(first use in this function\)$/) {
- $message = "$_";
- } elsif(/^\(Each undeclared identifier is reported only once$/) {
- $message = "$_";
- } elsif(/^conflicting types for \`(.*?)\'$/) {
- $message = "$_";
- } elsif(/^for each function it appears in.\)$/) {
- $message = "$_";
- } elsif(/^too many arguments to function$/) {
- $message = "$_";
- } elsif(/^previous declaration of \`(.*?)\'$/) {
- $message = "$_";
- } elsif(/^parse error before `(.*?)'$/) {
- $message = "$_";
- } elsif(!$options->pedantic) {
- $message = "$_";
- } else {
- error("gcc_output");
- }
- } elsif(/^In function \`(.*?)\':$/) {
- $function = $1;
- } elsif(/^At top level:$/) {
- $function = "";
- } else {
- error("gcc_output");
- }
- }
- ########################################################################
- # install_command
- ########################################################################
- sub install_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # ld_command
- ########################################################################
- sub ld_command($) {
- local $_ = shift;
- my $read_files;
- my $write_files;
- if(/-r\s+(.*?)\s+-o\s+(\S+)$/) {
- $write_files = [$2];
- $read_files = [split(/\s+/, $1)];
- } else {
- error("ld_command");
- }
- return ($read_files, $write_files);
- }
- ########################################################################
- # ld_output
- ########################################################################
- sub ld_output($$) {
- $file = shift;
- local $_ = shift;
- if(/^In function \`(.*?)\':$/) {
- $function = $1;
- } elsif(/^more undefined references to \`(.*?)\' follow$/) {
- # Nothing
- } elsif(/^the use of \`(.+?)\' is dangerous, better use \`(.+?)\'$/) {
- # Nothing
- } elsif(/^undefined reference to \`(.*?)\'$/) {
- # Nothing
- } elsif(/^warning: (.*?)\(\) possibly used unsafely; consider using (.*?)\(\)$/) {
- # Nothing
- } elsif(/^warning: type and size of dynamic symbol \`(.*?)\' are not defined$/) {
- $message = "$_";
- } else {
- $message = "$_";
- }
- }
- ########################################################################
- # ldconfig_command
- ########################################################################
- sub ldconfig_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # makedep_command
- ########################################################################
- sub makedep_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # mkdir_command
- ########################################################################
- sub mkdir_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # ranlib_command
- ########################################################################
- sub ranlib_command($) {
- local $_ = shift;
- my $read_files;
- my $write_files;
- $read_files = [split(/\s+/)];
- $write_files = [];
- return ($read_files, $write_files);
- }
- ########################################################################
- # rm_command
- ########################################################################
- sub rm_command($) {
- local $_ = shift;
- s/^-f\s*//;
- return ([], [], [split(/\s+/, $_)]);
- }
- ########################################################################
- # sed_command
- ########################################################################
- sub sed_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # strip_command
- ########################################################################
- sub strip_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # winebuild_command
- ########################################################################
- sub winebuild_command($) {
- local $_ = shift;
- return ([], []);
- }
- ########################################################################
- # winebuild_output
- ########################################################################
- sub winebuild_output($$) {
- $file = shift;
- local $_ = shift;
- $message = $_;
- }
- ########################################################################
- # wmc_command
- ########################################################################
- sub wmc_command($) {
- local $_ = shift;
- my $read_files;
- my $write_files;
- if(/\s+(\S+)$/) {
- my $mc_file = $1;
- my $rc_file = $mc_file;
- $rc_file =~ s/\.mc$/.rc/;
- $write_files = [$rc_file];
- $read_files = [$mc_file];
- } else {
- error("wmc_command");
- }
- return ($read_files, $write_files);
- }
- ########################################################################
- # wmc_output
- ########################################################################
- sub wmc_output($$) {
- $file = shift;
- local $_ = shift;
- }
- ########################################################################
- # wrc_command
- ########################################################################
- sub wrc_command($) {
- local $_ = shift;
- my $read_files;
- my $write_files;
- if(/\s+(\S+)$/) {
- my $rc_file = $1;
- my $o_file = $rc_file;
- $o_file =~ s/\.rc$/.o/;
- $write_files = [$o_file];
- $read_files = [$rc_file];
- } else {
- error("wrc_command");
- }
- return ($read_files, $write_files);
- }
- ########################################################################
- # wrc_output
- ########################################################################
- sub wrc_output($$) {
- $file = shift;
- local $_ = shift;
- }
- ########################################################################
- # command
- ########################################################################
- sub command($) {
- local $_ = shift;
- my $tool;
- my $file;
- my $read_files = ["<???>"];
- my $write_files = ["<???>"];
- my $remove_files = [];
- s/^\s*(.*?)\s*$/$1/;
- if(s/^\[\s+-d\s+(.*?)\s+\]\s+\|\|\s+//) {
- # Nothing
- }
- if(s/^ar\s+//) {
- $tool = "ar";
- ($read_files, $write_files) = ar_command($_);
- } elsif(s/^as\s+//) {
- $tool = "as";
- ($read_files, $write_files) = as_command($_);
- } elsif(s/^bison\s+//) {
- $tool = "bison";
- ($read_files, $write_files) = bison_command($_);
- } elsif(s/^cd\s+//) {
- $tool = "cd";
- ($read_files, $write_files) = cd_command($_);
- } elsif(s/^flex\s+//) {
- $tool = "flex";
- ($read_files, $write_files) = flex_command($_);
- } elsif(s/^for\s+//) {
- $tool = "for";
- ($read_files, $write_files) = for_command($_);
- } elsif(s/^\/usr\/bin\/install\s+//) {
- $tool = "install";
- ($read_files, $write_files) = install_command($_);
- } elsif(s/^ld\s+//) {
- $tool = "ld";
- ($read_files, $write_files) = ld_command($_);
- } elsif(s/^\/sbin\/ldconfig\s+//) {
- $tool = "ldconfig";
- ($read_files, $write_files) = ldconfig_command();
- } elsif(s/^gcc\s+//) {
- $tool = "gcc";
- ($read_files, $write_files) = gcc_command($_);
- } elsif(s/^(?:(?:\.\.\/)+|\.\/)tools\/makedep\s+//) {
- $tool = "makedep";
- ($read_files, $write_files) = makedep_command($_);
- } elsif(s/^mkdir\s+//) {
- $tool = "mkdir";
- ($read_files, $write_files) = mkdir_command($_);
- } elsif(s/^ranlib\s+//) {
- $tool = "ranlib";
- ($read_files, $write_files) = ranlib_command($_);
- } elsif(s/^rm\s+//) {
- $tool = "rm";
- ($read_files, $write_files, $remove_files) = rm_command($_);
- } elsif(s/^sed\s+//) {
- $tool = "sed";
- ($read_files, $write_files) = sed_command($_);
- } elsif(s/^strip\s+//) {
- $tool = "sed";
- ($read_files, $write_files) = strip_command($_);
- } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/winebuild\/winebuild\s+//) {
- $tool = "winebuild";
- ($read_files, $write_files) = winebuild_command($_);
- } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wmc\/wmc\s+//) {
- $tool = "wmc";
- ($read_files, $write_files) = wmc_command($_);
- } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wrc\/wrc\s+//) {
- $tool = "wrc";
- ($read_files, $write_files) = wrc_command($_);
- }
- return ($tool, $read_files, $write_files, $remove_files);
- }
- ########################################################################
- # line
- ########################################################################
- sub line($) {
- local $_ = shift;
- $file = "";
- $line = "";
- $message = "";
- $current = $_;
- my ($new_tool, $read_files, $write_files, $remove_files) = command($_);
- if(defined($new_tool)) {
- $tool = $new_tool;
- $function = "";
- my $progress = "";
- if($directory && $directory ne ".") {
- $progress .= "$directory: ";
- }
- if($tool) {
- $progress .= "$tool: ";
- }
- if($tool =~ /^(?:cd|make)$/) {
- # Nothing
- } elsif($tool eq "ld"/) {
- foreach my $file (@{$read_files}) {
- $output->lazy_progress("${progress}reading '$file'");
- }
- my $file = $$write_files[0];
- $output->progress("$progress: writing '$file'");
- } elsif($tool eq "rm") {
- foreach my $file (@{$remove_files}) {
- $output->lazy_progress("${progress}removing '$file'");
- }
- } else {
- if($#$read_files >= 0) {
- $progress .= "read[" . join(" ", @{$read_files}) . "]";
- }
- if($#$write_files >= 0) {
- if($#$read_files >= 0) {
- $progress .= ", ";
- }
- $progress .= "write[" . join(" ", @{$write_files}) . "]";
- }
- if($#$remove_files >= 0) {
- if($#$read_files >= 0 || $#$write_files >= 0) {
- $progress .= ", ";
- }
- $progress .= "remove[" . join(" ", @{$remove_files}) . "]";
- }
- $output->progress($progress);
- }
- return 0;
- }
- my $make = $options->make;
- if(/^Wine build complete\.$/) {
- # Nothing
- } elsif(/^(.*?) is newer than (.*?), please rerun (.*?)\!$/) {
- $message = "$_";
- } elsif(/^(.*?) is older than (.*?), please rerun (.*?)$/) {
- $message = "$_";
- } elsif(/^\`(.*?)\' is up to date.$/) {
- $tool = "make";
- make_output($1, $_);
- } elsif(s/^$make(?:\[(\d+)\])?:\s*//) {
- $tool = "make";
- make_output($1, $_);
- } elsif(!defined($tool)) {
- error("line");
- } elsif($tool eq "make") {
- make_output($1, $_);
- } elsif($tool eq "bison" && /^conflicts:\s+\d+\s+shift\/reduce$/) {
- # Nothing
- } elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) {
- # Nothing
- } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
- $tool = "ld";
- ld_output($1, $_)
- } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.*?)ld:\s*//) {
- $tool = "ld";
- ld_output("", $_)
- } elsif($tool =~ /^(?:gcc|ld)$/ && s/^collect2:\s*//) {
- $tool = "ld";
- ld_output("collect2", $_);
- } elsif($tool eq "gcc" && s/^(.+?\.[chly]):\s*//) {
- gcc_output($1, $_);
- } elsif($tool eq "ld" && s/^(.+?\.c):(?:\d+:)?\s*//) {
- ld_output($1, $_);
- } elsif($tool eq "winebuild" && s/^(.+?\.spec):\s*//) {
- winebuild_output($1, $_);
- } elsif($tool eq "wmc" && s/^(.+?\.mc):\s*//) {
- wmc_output($1, $_);
- } elsif($tool eq "wrc" && s/^(.+?\.rc):\s*//) {
- wrc_output($1, $_);
- } elsif($tool eq "cd" && s/^\/bin\/sh:\s*cd:\s*//) {
- parse_cd_output($_);
- } elsif(/^\s*$/) {
- # Nothing
- } else {
- error("line");
- }
- $file =~ s/^\.\///;
- return 1;
- }
- 1;
|