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) 2005
|
| 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 | #* pack_dep.pl
|
| 41 | #*
|
| 42 | #* Project:
|
| 43 | #* --------
|
| 44 | #* Maui_Software
|
| 45 | #*
|
| 46 | #* Description:
|
| 47 | #* ------------
|
| 48 | #* This script will pack the dependency file generated by compiler/assembler
|
| 49 | #*
|
| 50 | #* Author:
|
| 51 | #* -------
|
| 52 | #* Sherman Wang (mtk00590)
|
| 53 | #*
|
| 54 | #*============================================================================
|
| 55 | #* HISTORY
|
| 56 | #* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 57 | #*------------------------------------------------------------------------------
|
| 58 | #* $Revision: 1.7 $
|
| 59 | #* $Modtime: Aug 12 2005 13:37:30 $
|
| 60 | #* $Log: //mtkvs01/vmdata/Maui_sw/archives/mcu/pcore/tools/pack_dep.pl-arc $
|
| 61 | #*
|
| 62 | #* 08 21 2012 amber.su
|
| 63 | #* [MOLY00002246] [Target Build][hTogether] check in htogether mechasiam
|
| 64 | #* .
|
| 65 | #
|
| 66 | # Rev 1.7 Aug 12 2005 13:39:02 BM
|
| 67 | #update for No extension file name
|
| 68 | #I.E.
|
| 69 | #c:\progra~1\arm\adsv1_2\include\exception
|
| 70 | #
|
| 71 | # Rev 1.6 Jun 20 2005 18:39:24 BM
|
| 72 | #Karlos:
|
| 73 | #add copyright and disclaimer
|
| 74 | #
|
| 75 | # Rev 1.5 Apr 15 2005 18:41:46 mtk00990
|
| 76 | #Patch for mcurom.
|
| 77 | #
|
| 78 | # Rev 1.4 Mar 23 2005 21:38:18 mtk00990
|
| 79 | #For SCR10362.
|
| 80 | #
|
| 81 | # Rev 1.3 Dec 24 2004 18:40:10 BM
|
| 82 | #update for RVCT
|
| 83 | #
|
| 84 | # Rev 1.2 Aug 31 2004 18:20:06 mtk00590
|
| 85 | #fix a bug because some tailing spaces may be occured in some generated .d
|
| 86 | #
|
| 87 | # Rev 1.1 Jul 05 2004 19:11:34 BM
|
| 88 | #update to scandep when compile source code
|
| 89 | #
|
| 90 | # Rev 1.0 Apr 05 2004 14:00:28 BM
|
| 91 | #Initial revision.
|
| 92 | #*------------------------------------------------------------------------------
|
| 93 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 94 | #*============================================================================
|
| 95 | #****************************************************************************/
|
| 96 |
|
| 97 | #****************************************************************************
|
| 98 | # Included Modules
|
| 99 | #****************************************************************************
|
| 100 |
|
| 101 | #****************************************************************************
|
| 102 | # Constants
|
| 103 | #****************************************************************************
|
| 104 | my $DebugPrint = 0; # 1 for debug; 0 for non-debug
|
| 105 |
|
| 106 | #****************************************************************************
|
| 107 | # Read dependency file generatedd by compiler/assembler
|
| 108 | #****************************************************************************
|
| 109 | my $start_time = `time\/t` if ($DebugPrint == 1);
|
| 110 |
|
| 111 | my $DEP_FILE = $ARGV[0];
|
| 112 | if (defined $ARGV[1]){
|
| 113 | $HEADER_LIST = $ARGV[1];
|
| 114 | $HEADER_FLD = $ARGV[2];
|
| 115 | }
|
| 116 |
|
| 117 | # Get original header file paths from tools\copy_mmi_inlude_h.bat
|
| 118 | if (defined $ARGV[1]) {
|
| 119 | open HEADER_LIST,"<$HEADER_LIST" or die "Error: $HEADER_LIST";
|
| 120 | while(<HEADER_LIST>) {
|
| 121 | if ($_ =~ /\.\\(.+)\\(.+\.h)/) {
|
| 122 | $headerF = lc($2);
|
| 123 | $path{lc("$HEADER_FLD\\$headerF")} = "$1\\$2";
|
| 124 | }
|
| 125 | }
|
| 126 | close HEADER_LIST;
|
| 127 | }
|
| 128 |
|
| 129 | # replace '/' with '\'
|
| 130 | open DEP_FILE,"+<$DEP_FILE" or die "cannot open $DEP_FILE for replacing \'\/\' with \'\\\'\n";
|
| 131 | my $backup= $/;
|
| 132 | undef $/;
|
| 133 |
|
| 134 | my $reading = <DEP_FILE>;
|
| 135 | $/ = $backup;
|
| 136 |
|
| 137 | $reading =~ s/\//\\/g;
|
| 138 |
|
| 139 | seek(DEP_FILE,0,0);
|
| 140 | print DEP_FILE $reading;
|
| 141 | close DEP_FILE;
|
| 142 |
|
| 143 |
|
| 144 | open DEP_FILE,"<$DEP_FILE" or die "cannot open $DEP_FILE for reading\n";
|
| 145 | #print "$DEP_FILE are OPENED\n";
|
| 146 |
|
| 147 | my %dependency = ();
|
| 148 | my $src = '';
|
| 149 | my $obj = '';
|
| 150 | my $line_no = 0;
|
| 151 | my $file = '';
|
| 152 | my $find_obj = 0;
|
| 153 |
|
| 154 | while (<DEP_FILE>)
|
| 155 | {
|
| 156 | $line_no ++;
|
| 157 | if (/(\S+\\)*(\S*)\.(?:obj|o|db)\s*:\s*(\S*)/)
|
| 158 | {
|
| 159 | if ($src ne $2)
|
| 160 | {
|
| 161 | $src = $2;
|
| 162 | $obj = $src . ".obj";
|
| 163 | }
|
| 164 | $file = $3;
|
| 165 | }
|
| 166 | # for parsing the file by -M precompilation
|
| 167 | elsif(/__image\.axf:/)
|
| 168 | {
|
| 169 | if ($find_obj == 0 && /.*:\s*(\S+\\)*(\S*)(\.c)$/i || /.*:\s*(\S+\\)*(\S*)(\.cpp)$/i || /.*:\s*(\S+\\)*(\S*)(\.s)$/i || /.*:\s*(\S+\\)*(\S*)(\.arm)$/i){
|
| 170 | if ($src ne $2){
|
| 171 | $src = $2;
|
| 172 | $obj = $src . ".obj";
|
| 173 | $file = $1.$2.$3;
|
| 174 | $find_obj = 1;
|
| 175 | }
|
| 176 | }
|
| 177 | elsif ($find_obj == 1 && /.*?:\s*(.+)$/)
|
| 178 | {
|
| 179 | $file = $1;
|
| 180 | }
|
| 181 | else
|
| 182 | {
|
| 183 | die "cannot find source file: $_ ";
|
| 184 | }
|
| 185 | }
|
| 186 | #end for parsing the file by -M precompilation
|
| 187 | else{
|
| 188 | die "cannot parse $_ ";
|
| 189 | }
|
| 190 |
|
| 191 | if (defined $ARGV[1])
|
| 192 | {
|
| 193 | if (defined $path{lc($file)}){
|
| 194 | $reading = $path{lc($file)};
|
| 195 | } else {
|
| 196 | $reading = $file;
|
| 197 | }
|
| 198 | }
|
| 199 | else
|
| 200 | {
|
| 201 | $reading = $file;
|
| 202 | }
|
| 203 | if ($reading =~ /([\w|\.][^\/\*\?\"<>|]*\\[^\\\/\*\?\":<>|]+)\s*$/)
|
| 204 | {
|
| 205 | my $req_hdr = $1;
|
| 206 |
|
| 207 | if ($req_hdr =~ /:\\\w+/ )
|
| 208 | {
|
| 209 | next;
|
| 210 | }
|
| 211 |
|
| 212 | while ($req_hdr =~ /\\\.\\/)
|
| 213 | {
|
| 214 | $req_hdr =~ s/\\\.\\/\\/; # remove "\.\"
|
| 215 | }
|
| 216 | while ($req_hdr =~ /\w[\w~:]*\\\.\.\\/) #( index ($req_hdr, "\\.") > -1)
|
| 217 | {
|
| 218 | $req_hdr =~ s/\w[\w~:]*\\\.\.\\//; # remove "xxx\..\"
|
| 219 | }
|
| 220 | while ($req_hdr =~ /^\.\.\\/)
|
| 221 | {
|
| 222 | $req_hdr =~ s/\.\.\\//; # remove "..\..\"
|
| 223 | }
|
| 224 |
|
| 225 | if (exists $dependency{$obj})
|
| 226 | {
|
| 227 | if (index(lc($dependency{$obj}), lc($req_hdr)) == -1)
|
| 228 | {
|
| 229 | $dependency{$obj} .= " \\\n\t\t$req_hdr";
|
| 230 | }
|
| 231 | }
|
| 232 | else
|
| 233 | {
|
| 234 | $dependency{$obj} = "\t$req_hdr";
|
| 235 | }
|
| 236 | }
|
| 237 | else
|
| 238 | {
|
| 239 | die "$reading dependency errors in line $line_no!!!";
|
| 240 | }
|
| 241 | }
|
| 242 | close DEP_FILE;
|
| 243 |
|
| 244 | #****************************************************************************
|
| 245 | # Output the packed dependency file
|
| 246 | #****************************************************************************
|
| 247 | print "#UPDATE#\n";
|
| 248 | while ( my ($key, $value) = each %dependency)
|
| 249 | {
|
| 250 | print "$key:$value\n";
|
| 251 | }
|
| 252 | print "#ENDUPDATE#\n";
|
| 253 |
|
| 254 | my $end_time = `time\/t` if ($DebugPrint == 1);
|
| 255 | print "$start_time ~ $end_time" if ($DebugPrint == 1);
|