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::Copy;
|
| 39 | use File::Path;
|
| 40 | use File::Basename;
|
| 41 | # show usage
|
| 42 | sub usage
|
| 43 | {
|
| 44 | print "USAGE: perl copySrcComp.pl <filename of .lis> <path of .dep> <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 | #
|
| 58 | # open .lis & .dep
|
| 59 | #
|
| 60 |
|
| 61 | $LIS_FILE = $ARGV[0];
|
| 62 | open LIS_FILE,"$LIS_FILE" or die "cannot open $LIS_FILE\n";
|
| 63 | @reading = <LIS_FILE>;
|
| 64 | $obj_count = 0;
|
| 65 | $obj_list = '';
|
| 66 | foreach (@reading)
|
| 67 | {
|
| 68 | if ((s/([0-9a-zA-Z_.\-]+)\.cp?p?\s*$/$1.obj/i) || (s/([0-9a-zA-Z_.\-]+)\.s\s*$/$1.obj/i)) # extract '*.c/cpp/s'
|
| 69 | {
|
| 70 | $obj_list .= " $_";
|
| 71 | # print "$_\n";
|
| 72 | $obj_count++;
|
| 73 | }
|
| 74 | }
|
| 75 | close LIS_FILE;
|
| 76 |
|
| 77 |
|
| 78 | $DEP_FILE = $ARGV[1];
|
| 79 | open DEP_FILE,"$DEP_FILE" or die "cannot open $DEP_FILE\n";
|
| 80 | @reading = <DEP_FILE>;
|
| 81 | $dep_count = 0;
|
| 82 | $hdr_count = 0;
|
| 83 | $needed_obj = 0;
|
| 84 | foreach (@reading)
|
| 85 | {
|
| 86 | $reading = $_;
|
| 87 | if ($reading =~ /([0-9a-zA-Z_.\-]+\.obj)/)
|
| 88 | {
|
| 89 | my $objName = $1;
|
| 90 | if (index($obj_list, $objName) > -1){ # if the '.obj' is needed in .lis
|
| 91 | $needed_obj = 1;
|
| 92 | }
|
| 93 | else{
|
| 94 | $needed_obj = 0;
|
| 95 | }
|
| 96 | }
|
| 97 | if($needed_obj){
|
| 98 | my @files = split /\s+/,$reading;
|
| 99 | for my $file(@files){
|
| 100 | if($file =~ /\b\S+\.(hpp|hs|hex|dat|cpp|c|h|incl|inc|tbl|def|msg)\s*$/i) # find out next .(hpp|h|dat|c|hex) in this line
|
| 101 | {
|
| 102 | if ( !($file =~ /c:/i) ) # exclude the c:\progra~1\...\xxx.(hpp|h|dat|c|hex)
|
| 103 | {
|
| 104 | if ( !($req_hdr{$hdr_name}) ) # find out non-duplicated .(hpp|h|dat|c|hex)
|
| 105 | {
|
| 106 | $req_hdr{$file} = 1;
|
| 107 | $hdr_count ++;
|
| 108 | }
|
| 109 | else
|
| 110 | {
|
| 111 | $req_hdr{$file} ++; # count duplication times of .(hpp|h|dat|c|hex), just for our info.
|
| 112 | }
|
| 113 | }
|
| 114 | }
|
| 115 | $dep_count++;
|
| 116 | }
|
| 117 | }
|
| 118 | }
|
| 119 | close DEP_FILE;
|
| 120 |
|
| 121 | #print "\n\n$hdr_count .(hpp|hex|dat|cpp|c|h|incl|inc|tbl|def|msg) will be copied: \n";
|
| 122 | #$output = "~"."$module"."rh.tmp";
|
| 123 | #print "out = $output\n";
|
| 124 |
|
| 125 | #open(W,">$ARGV[2]\\$output");
|
| 126 | while ( ($key, $value) = each %req_hdr)
|
| 127 | {
|
| 128 | # Copy header files at the same time.
|
| 129 | $targetfile = "$ARGV[2]"."\\$key";
|
| 130 | my $path = dirname($targetfile);
|
| 131 | if (!-e $targetfile) {
|
| 132 | print $targetfile."\n";
|
| 133 | CopyFile("$key","$targetfile");
|
| 134 | }
|
| 135 | }
|
| 136 | #close(W);
|
| 137 |
|
| 138 | # dump header file list to make\~srccomprh.tmp
|
| 139 | #system("type make\\$output >> make\\~srccomprh.tmp");
|
| 140 |
|
| 141 | #system("echo $DEP_FILE $module >> make\\module.tmp");
|
| 142 |
|
| 143 | sub CopyFile
|
| 144 | {
|
| 145 | my $src = shift;
|
| 146 | my $target = shift;
|
| 147 | my $dest = dirname($target);
|
| 148 | mkpath($dest) if (! -e $dest);
|
| 149 | copy($src, $target);# or die "Fail to copy $src";
|
| 150 | }
|