yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [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) for the header sources listed in .lis and in .dep
|
| 38 | use File::Basename;
|
| 39 | use File::Copy;
|
| 40 | use File::Path;
|
| 41 | # show usage
|
| 42 | sub usage
|
| 43 | {
|
| 44 | print "USAGE: perl copySrcComp.pl <filename of .lis> <path of .dep> <tmp file path> <release dir>\n";
|
| 45 | exit(0);
|
| 46 | }
|
| 47 |
|
| 48 | #
|
| 49 | # parsing command arguments
|
| 50 | #
|
| 51 |
|
| 52 | my $arg_idx=0;
|
| 53 | my $LIS_FILE;
|
| 54 | my $DEP_FILE;
|
| 55 | my $reading;
|
| 56 |
|
| 57 | if (!($ARGV[0] =~ /\.lis$/))
|
| 58 | {
|
| 59 | usage();
|
| 60 | }
|
| 61 |
|
| 62 | #
|
| 63 | # open .lis & .dep
|
| 64 | #
|
| 65 |
|
| 66 | $LIS_FILE = $ARGV[0];
|
| 67 | open LIS_FILE,"$LIS_FILE" or die "cannot open $LIS_FILE\n";
|
| 68 |
|
| 69 | if ($ARGV[0] =~ /.+[\\\/](.+).lis/) {
|
| 70 | $DEP_FILE = "$ARGV[1]/".$1.".dep";
|
| 71 | $module = $1;
|
| 72 | } else {
|
| 73 | die "Cannot get module name.";
|
| 74 | }
|
| 75 | print "$DEP_FILE\n";
|
| 76 | print "$module\n";
|
| 77 |
|
| 78 | open DEP_FILE,"$DEP_FILE" or die "cannot open $DEP_FILE\n";
|
| 79 |
|
| 80 | #print "$LIS_FILE and $DEP_FILE are OPENED\n";
|
| 81 |
|
| 82 | #
|
| 83 | #
|
| 84 | #
|
| 85 |
|
| 86 | @reading = <LIS_FILE>;
|
| 87 | $obj_count = 0;
|
| 88 | $obj_list = '';
|
| 89 | foreach (@reading)
|
| 90 | {
|
| 91 | if ((s/\S+[\\\/]([0-9a-zA-Z_.\-]+)\.cp?p?\s*$/\L$1.obj/i) || (s/\S+[\\\/]([0-9a-zA-Z_.\-]+)\.s\s*$/\L$1.obj/i)) # extract '*.c/cpp/s'
|
| 92 | {
|
| 93 | $obj_list .= " $_";
|
| 94 | # print "$_\n";
|
| 95 | $obj_count++;
|
| 96 | }
|
| 97 | }
|
| 98 | close LIS_FILE;
|
| 99 | #print "$obj_count .obj will be checked for the dependency\n";
|
| 100 | #print $obj_list;
|
| 101 |
|
| 102 | @reading = <DEP_FILE>;
|
| 103 | $dep_count = 0;
|
| 104 | $hdr_count = 0;
|
| 105 | $needed_obj = 0;
|
| 106 | foreach (@reading)
|
| 107 | {
|
| 108 | if (/\.obj/)
|
| 109 | {
|
| 110 | $reading = lc($_);
|
| 111 |
|
| 112 | s/([0-9a-zA-Z_.\-]+\.obj).+\n/\L$1/; # extract '*.obj' from .dep
|
| 113 | if (index($obj_list, $_) > -1) # if the '.obj' is needed in .lis
|
| 114 | {
|
| 115 | $needed_obj = 1;
|
| 116 |
|
| 117 | # print "\n\n$dep_count\t";
|
| 118 | while ($reading =~ /\b\S+\.(hpp|hex|dat|cpp|c|h|incl|inc|tbl|def|msg)/) # find out next .(hpp|h|dat|c|hex) in this line
|
| 119 | {
|
| 120 | $hdr_name = "\L$&";
|
| 121 | $reading = ($`).($');
|
| 122 | if ( !($hdr_name =~ /c:/) ) # exclude the c:\progra~1\...\xxx.(hpp|h|dat|c|hex)
|
| 123 | {
|
| 124 | if ( !($req_hdr{$hdr_name}) ) # find out non-duplicated .(hpp|h|dat|c|hex)
|
| 125 | {
|
| 126 | $req_hdr{$hdr_name} = 1;
|
| 127 | $hdr_count ++;
|
| 128 | # print "[$hdr_name]\t";
|
| 129 | }
|
| 130 | else
|
| 131 | {
|
| 132 | $req_hdr{$hdr_name} ++; # count duplication times of .(hpp|h|dat|c|hex), just for our info.
|
| 133 | }
|
| 134 | }
|
| 135 | }
|
| 136 | $dep_count++;
|
| 137 | }
|
| 138 | else
|
| 139 | {
|
| 140 | $needed_obj = 0;
|
| 141 | }
|
| 142 | }
|
| 143 | elsif (/\.(hpp|hex|dat|cpp|c|h|incl|inc|tbl|def|msg)/ && $needed_obj == 1)
|
| 144 | {
|
| 145 | $reading = lc($_);
|
| 146 |
|
| 147 | while ($reading =~ /\b\S+\.(hpp|hex|dat|c|h|incl|inc|tbl|def|msg)/) # find out next .(hpp|h|dat|c|hex) in this line
|
| 148 | {
|
| 149 | $hdr_name = "\L$&";
|
| 150 | $reading = ($`).($');
|
| 151 | if ( !($hdr_name =~ /c:/) ) # exclude the c:\progra~1\...\xxx.(hpp|h|dat|c|hex)
|
| 152 | {
|
| 153 | if ( !($req_hdr{$hdr_name}) ) # find out non-duplicated .(hpp|h|dat|c|hex)
|
| 154 | {
|
| 155 | $req_hdr{$hdr_name} = 1;
|
| 156 | $hdr_count ++;
|
| 157 | # print "[$hdr_name]\t";
|
| 158 | }
|
| 159 | else
|
| 160 | {
|
| 161 | $req_hdr{$hdr_name} ++; # count duplication times of .(hpp|h|dat|c|hex), just for our info.
|
| 162 | }
|
| 163 | }
|
| 164 | }
|
| 165 | }
|
| 166 | }
|
| 167 | close DEP_FILE;
|
| 168 |
|
| 169 | print "\n\n$hdr_count .(hpp|hex|dat|cpp|c|h|incl|inc|tbl|def|msg) will be copied: \n";
|
| 170 | $output = "~"."$module"."rh.tmp";
|
| 171 | print "out = $output\n";
|
| 172 |
|
| 173 | open(W,">$ARGV[2]/$output");
|
| 174 | while (($key, $value) = each %req_hdr)
|
| 175 | {
|
| 176 | print W "$key\n";
|
| 177 | # Copy header files at the same time.
|
| 178 | my $targetfile = "$ARGV[3]"."\\$key";
|
| 179 | if (!-e $targetfile) {
|
| 180 | print "Copying file $key\n";
|
| 181 | my $path = dirname($targetfile);
|
| 182 | mkpath($path) if(! -d $path);
|
| 183 | copy($key, $targetfile) or warn "Fail to copy $src";
|
| 184 | }
|
| 185 | }
|
| 186 | close(W);
|
| 187 |
|
| 188 | # dump header file list to make\~srccomprh.tmp
|
| 189 | if (open(W, ">>make/~srccomprh.tmp"))
|
| 190 | {
|
| 191 | while (($key, $value) = each %req_hdr)
|
| 192 | {
|
| 193 | print W "$key\n";
|
| 194 | }
|
| 195 | close W;
|
| 196 | }
|
| 197 | if (open(W, ">>make/module.tmp"))
|
| 198 | {
|
| 199 | print W "$DEP_FILE $module\n";
|
| 200 | close W;
|
| 201 | }
|