rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #!/usr/bin/perl
|
| 2 | #
|
| 3 | # Copyright Statement:
|
| 4 | # --------------------
|
| 5 | # This software is protected by Copyright and the information contained
|
| 6 | # herein is confidential. The software may not be copied and the information
|
| 7 | # contained herein may not be used or disclosed except with the written
|
| 8 | # permission of MediaTek Inc. (C) 2008
|
| 9 | #
|
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
|
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
|
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
|
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
|
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
|
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
|
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
|
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
|
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
|
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
|
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
|
| 22 | #
|
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
|
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
|
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
|
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
|
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
|
| 28 | #
|
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
|
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
|
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
|
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
|
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
|
| 34 | #
|
| 35 | #
|
| 36 | #*****************************************************************************
|
| 37 | #*
|
| 38 | #* Filename:
|
| 39 | #* ---------
|
| 40 | #* get_log.pl
|
| 41 | #*
|
| 42 | #* Project:
|
| 43 | #* --------
|
| 44 | #* Maui_Software
|
| 45 | #*
|
| 46 | #* Description:
|
| 47 | #* ------------
|
| 48 | #* This script will parse compile logs and dump them to a single log file.
|
| 49 | #*
|
| 50 | #* Author:
|
| 51 | #* -------
|
| 52 | #* Frank Wu (mtk01760)
|
| 53 | #*
|
| 54 | #*============================================================================
|
| 55 | #* HISTORY
|
| 56 | #* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 57 | #*------------------------------------------------------------------------------
|
| 58 | #*
|
| 59 | #*------------------------------------------------------------------------------
|
| 60 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 61 | #*============================================================================
|
| 62 | #****************************************************************************/
|
| 63 | use File::Basename;
|
| 64 | my $LOG_FILE = $ARGV[0];
|
| 65 | my $LOG_PATH = $ARGV[1];
|
| 66 | if (defined $ARGV[2]) {
|
| 67 | $HEADER_REF = $ARGV[2];
|
| 68 | $HEADER_FLD = $ARGV[3];
|
| 69 | $HEADER_FLD =~ s/\\/\//g;
|
| 70 | }
|
| 71 |
|
| 72 | my $line = 0;
|
| 73 | my %errFile;
|
| 74 | open LOG_FILE,"<$LOG_FILE" or die "cannot open $LOG_FILE:$!\n";
|
| 75 | while(<LOG_FILE>) {
|
| 76 | $line++;
|
| 77 | next if($line == 1);
|
| 78 | if ($_ =~ /.+\*\*\*.+\[(.+)\.obj\].+/ig) {
|
| 79 | $errFile{uc($1)}=1;
|
| 80 | }
|
| 81 | }
|
| 82 | close LOG_FILE;
|
| 83 |
|
| 84 | # Get original header file paths from tools\copy_mmi_inlude_h.bat
|
| 85 | if (defined $ARGV[2]) {
|
| 86 | open HEADER_REF,"<$HEADER_REF" or die "Cannot open $HEADER_REF";
|
| 87 | while(<HEADER_REF>) {
|
| 88 | $_ =~ s/\\/\//g;
|
| 89 | if ($_ =~ /(\S+\.h)/) {
|
| 90 | $file = $1;
|
| 91 | $fdir=dirname($file);
|
| 92 | $fname=basename($file);
|
| 93 | $path{lc("$HEADER_FLD/$fname")} = "$fdir/$fname";
|
| 94 | push @header, $fname;
|
| 95 | }
|
| 96 | }
|
| 97 | close HEADER_REF;
|
| 98 | }
|
| 99 |
|
| 100 | our @LOGFILES;
|
| 101 |
|
| 102 | if (opendir(LOGDIR, $LOG_PATH)) {
|
| 103 | @LOGFILES = sort readdir(LOGDIR);
|
| 104 | closedir(LOGDIR);
|
| 105 | }
|
| 106 |
|
| 107 | open LOG_FILE,"<$LOG_FILE" or die "cannot open $LOG_FILE:$!\n";
|
| 108 | my $newlog;
|
| 109 | my $printlog;
|
| 110 | my $file;
|
| 111 | my $log;
|
| 112 | my $filename;
|
| 113 | $line = 0;
|
| 114 | while(<LOG_FILE>) {
|
| 115 | $line++;
|
| 116 | if ($line == 1) {
|
| 117 | $newlog.=$_;
|
| 118 | $printlog = 1;
|
| 119 | } else {
|
| 120 | if ($printlog == 1) {
|
| 121 | foreach $file (@LOGFILES) {
|
| 122 | next if ($file eq ".");
|
| 123 | next if ($file eq "..");
|
| 124 | $file =~ /(.+)\.log/;
|
| 125 | $filename = $1;
|
| 126 | next if ($errFile{uc($filename)} == 1);
|
| 127 |
|
| 128 | open f,"<$LOG_PATH/$file" or die "cannot open $LOG_PATH/$file:$!\n";
|
| 129 | my $backup= $/;
|
| 130 | undef $/;
|
| 131 | $log .= <f>;
|
| 132 | $/ = $backup;
|
| 133 | close f;
|
| 134 | }
|
| 135 | $log =~ s/\\/\//g;
|
| 136 | if (defined $ARGV[2]) {
|
| 137 | foreach $h(@header){
|
| 138 | $ori_h_file = $path{lc("$HEADER_FLD/$h")};
|
| 139 | $log =~ s/$HEADER_FLD\/$h/$ori_h_file/ig;
|
| 140 | }
|
| 141 | }
|
| 142 | $printlog = 0;
|
| 143 |
|
| 144 | $newlog.=$log;
|
| 145 |
|
| 146 | $log = "";
|
| 147 | }
|
| 148 | if ($_ =~ /.+\*\*\*.+\[(.+)\.obj\].+/ig) {
|
| 149 | if (-e "$LOG_PATH/$1.log") {
|
| 150 | open f,"<$LOG_PATH/$1.log" or die "cannot open $LOG_PATH/$1.log:$!\n";
|
| 151 | my $backup= $/;
|
| 152 | undef $/;
|
| 153 | $log = <f>;
|
| 154 | $/ = $backup;
|
| 155 | close f;
|
| 156 | $log =~ s/\\/\//g;
|
| 157 | if (defined $ARGV[2]) {
|
| 158 | foreach $h(@header){
|
| 159 | $ori_h_file = $path{lc("$HEADER_FLD/$h")};
|
| 160 | $log =~ s/$HEADER_FLD\/$h/$ori_h_file/ig;
|
| 161 | }
|
| 162 | }
|
| 163 | $newlog.=$log;
|
| 164 | }
|
| 165 | }
|
| 166 | $newlog.=$_;
|
| 167 | }
|
| 168 | }
|
| 169 |
|
| 170 | open LOG_FILE,"+<$LOG_FILE" or die "cannot open $LOG_FILE:$!\n";
|
| 171 | # clear all file content
|
| 172 | truncate(LOG_FILE,0);
|
| 173 | # then insert the content of $LOG_FILE
|
| 174 | seek(LOG_FILE,0,0);
|
| 175 | print LOG_FILE $newlog;
|
| 176 | close LOG_FILE;
|
| 177 |
|