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 | #!/usr/bin/perl
|
| 37 | # find out required .(hpp|h|dat|c|hex|incl|inc|msg) for the header sources listed in .lis and in .dep
|
| 38 |
|
| 39 | # show usage
|
| 40 | sub usage
|
| 41 | {
|
| 42 | print "USAGE: perl req_hdr.pl <filename of .lis> <filename of .dep>\n";
|
| 43 | exit(0);
|
| 44 | }
|
| 45 |
|
| 46 | #
|
| 47 | # parsing command arguments
|
| 48 | #
|
| 49 |
|
| 50 | my $arg_idx=0;
|
| 51 | my $LIS_FILE;
|
| 52 | my $DEP_FILE;
|
| 53 | my $reading;
|
| 54 |
|
| 55 | if (!($ARGV[0] =~ /\.lis$/) || !($ARGV[1] =~ /\.dep$/))
|
| 56 | {
|
| 57 | usage();
|
| 58 | }
|
| 59 |
|
| 60 | #
|
| 61 | # open .lis & .dep
|
| 62 | #
|
| 63 |
|
| 64 | $LIS_FILE = $ARGV[0];
|
| 65 | open LIS_FILE,"$LIS_FILE" or die "cannot open $LIS_FILE\n";
|
| 66 | $DEP_FILE = $ARGV[1];
|
| 67 | open DEP_FILE,"$DEP_FILE" or die "cannot open $DEP_FILE\n";
|
| 68 |
|
| 69 | #print "$LIS_FILE and $DEP_FILE are OPENED\n";
|
| 70 |
|
| 71 | #
|
| 72 | #
|
| 73 | #
|
| 74 |
|
| 75 | @reading = <LIS_FILE>;
|
| 76 | $obj_count = 0;
|
| 77 | $obj_list = '';
|
| 78 | foreach (@reading)
|
| 79 | {
|
| 80 | if ((s/\S+\\(\w+)\.cp?p?\s*$/\L$1.obj/i) || (s/\S+\\(\w+)\.s\s*$/\L$1.obj/i))# extract '*.c/cpp/s'
|
| 81 | {
|
| 82 | $obj_list .= " $_";
|
| 83 | # print "$_\n";
|
| 84 | $obj_count++;
|
| 85 | }
|
| 86 | }
|
| 87 | close LIS_FILE;
|
| 88 | #print "$obj_count .obj will be checked for the dependency\n";
|
| 89 | #print $obj_list;
|
| 90 |
|
| 91 | @reading = <DEP_FILE>;
|
| 92 | $dep_count = 0;
|
| 93 | $hdr_count = 0;
|
| 94 | $needed_obj = 0;
|
| 95 | foreach (@reading)
|
| 96 | {
|
| 97 | if (/\.obj/)
|
| 98 | {
|
| 99 | $reading = lc($_);
|
| 100 |
|
| 101 | s/(\w+\.obj).+\n/\L$1/; # extract '*.obj' from .dep
|
| 102 | if (index($obj_list, $_) > -1) # if the '.obj' is needed in .lis
|
| 103 | {
|
| 104 | $needed_obj = 1;
|
| 105 |
|
| 106 | # print "\n\n$dep_count\t";
|
| 107 | while ($reading =~ /\b\S+\.(hpp|hex|dat|c|h|incl|inc|msg)/) # find out next .(hpp|h|dat|c|hex) in this line
|
| 108 | {
|
| 109 | $hdr_name = "\L$&";
|
| 110 | $reading = ($`).($');
|
| 111 | if ( !($hdr_name =~ /c:/) ) # exclude the c:\progra~1\...\xxx.(hpp|h|dat|c|hex)
|
| 112 | {
|
| 113 | if ( !($req_hdr{$hdr_name}) ) # find out non-duplicated .(hpp|h|dat|c|hex)
|
| 114 | {
|
| 115 | $req_hdr{$hdr_name} = 1;
|
| 116 | $hdr_count ++;
|
| 117 | # print "[$hdr_name]\t";
|
| 118 | }
|
| 119 | else
|
| 120 | {
|
| 121 | $req_hdr{$hdr_name} ++; # count duplication times of .(hpp|h|dat|c|hex), just for our info.
|
| 122 | }
|
| 123 | }
|
| 124 | }
|
| 125 | $dep_count++;
|
| 126 | }
|
| 127 | else
|
| 128 | {
|
| 129 | $needed_obj = 0;
|
| 130 | }
|
| 131 | }
|
| 132 | elsif (/\.(hpp|hex|dat|c|h|incl|inc|msg)/ && $needed_obj == 1)
|
| 133 | {
|
| 134 | $reading = lc($_);
|
| 135 |
|
| 136 | while ($reading =~ /\b\S+\.(hpp|hex|dat|c|h|incl|inc|msg)/) # find out next .(hpp|h|dat|c|hex) in this line
|
| 137 | {
|
| 138 | $hdr_name = "\L$&";
|
| 139 | $reading = ($`).($');
|
| 140 | if ( !($hdr_name =~ /c:/) ) # exclude the c:\progra~1\...\xxx.(hpp|h|dat|c|hex)
|
| 141 | {
|
| 142 | if ( !($req_hdr{$hdr_name}) ) # find out non-duplicated .(hpp|h|dat|c|hex)
|
| 143 | {
|
| 144 | $req_hdr{$hdr_name} = 1;
|
| 145 | $hdr_count ++;
|
| 146 | # print "[$hdr_name]\t";
|
| 147 | }
|
| 148 | else
|
| 149 | {
|
| 150 | $req_hdr{$hdr_name} ++; # count duplication times of .(hpp|h|dat|c|hex), just for our info.
|
| 151 | }
|
| 152 | }
|
| 153 | }
|
| 154 | }
|
| 155 | }
|
| 156 | close DEP_FILE;
|
| 157 |
|
| 158 | print "\n\n$hdr_count .(hpp|hex|dat|c|h|incl|inc|msg) will be copied: \n";
|
| 159 | while ( ($key, $value) = each %req_hdr)
|
| 160 | {
|
| 161 | print "$key\n";
|
| 162 | }
|