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 copyDepFile.pl <filename 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 $DEP_FILE;
|
| 54 | my $reading;
|
| 55 |
|
| 56 | if (!($ARGV[0] =~ /\.dep$/))
|
| 57 | {
|
| 58 | usage();
|
| 59 | }
|
| 60 |
|
| 61 |
|
| 62 | if ($ARGV[0] =~ /.+\\(.+)\.dep/) {
|
| 63 | $module = $1;
|
| 64 | } else {
|
| 65 | die "Cannot get module name.";
|
| 66 | }
|
| 67 | print "$module\n";
|
| 68 | $DEP_FILE = $ARGV[0];
|
| 69 | open DEP_FILE,"$DEP_FILE" or die "cannot open $DEP_FILE\n";
|
| 70 |
|
| 71 | @reading = <DEP_FILE>;
|
| 72 | $dep_count = 0;
|
| 73 | $hdr_count = 0;
|
| 74 | $needed_obj = 0;
|
| 75 | foreach (@reading)
|
| 76 | {
|
| 77 | $reading = $_;
|
| 78 | while ($reading =~ /\b\S+\.(hpp|hs|hex|dat|cpp|c|h|incl|inc|tbl|def|msg)/) # find out next .(hpp|h|dat|c|hex) in this line
|
| 79 | {
|
| 80 | $hdr_name = "$&";
|
| 81 | $reading = ($`).($');#'
|
| 82 | if ( !($hdr_name =~ /c:/) ) # exclude the c:\progra~1\...\xxx.(hpp|h|dat|c|hex)
|
| 83 | {
|
| 84 | if ( !($req_hdr{$hdr_name}) ) # find out non-duplicated .(hpp|h|dat|c|hex)
|
| 85 | {
|
| 86 | $req_hdr{$hdr_name} = 1;
|
| 87 | $hdr_count ++;
|
| 88 | }
|
| 89 | else
|
| 90 | {
|
| 91 | $req_hdr{$hdr_name} ++; # count duplication times of .(hpp|h|dat|c|hex), just for our info.
|
| 92 | }
|
| 93 | }
|
| 94 | }
|
| 95 | }
|
| 96 | close DEP_FILE;
|
| 97 |
|
| 98 | #print "\n$hdr_count .(hpp|hex|dat|cpp|c|h|incl|inc|tbl|def|msg) will be copied: \n";
|
| 99 |
|
| 100 | while ( ($key, $value) = each %req_hdr)
|
| 101 | {
|
| 102 | $targetfile = "$ARGV[2]"."\\$key";
|
| 103 | my $path = dirname($targetfile);
|
| 104 | if (!-e $targetfile) {
|
| 105 | print "Copying file $key\n";
|
| 106 | CopyFile("$key","$targetfile");
|
| 107 | }
|
| 108 | }
|
| 109 |
|
| 110 | sub CopyFile
|
| 111 | {
|
| 112 | my $src = shift;
|
| 113 | my $target = shift;
|
| 114 | my $dest = dirname($target);
|
| 115 | mkpath($dest) if (! -e $dest);
|
| 116 | copy($src, $target);# or die "Fail to copy $src";
|
| 117 | }
|