blob: 1a0e7fc0ee77a854dca1d0ebbb39d39c98eaea0a [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#!/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
38use File::stat;
39use Cwd;
40
41my $lib_file = "init.lib";
42my $short_lib_file = "init.lib";
43my $obj_path = "init";
44my $ar_file = "c:\progra~1\arm\adsv1_2\bin\armar.exe";
45my $lis_file = ".\make\init\init.lis";
46my $current_lib = "";
47my $lis_path = "";
48my $flag_modis = "";
49my $flag_print = 1;
50
51
52while ($#ARGV != -1) {
53 if ($ARGV[0] =~ /-h/) {
54 Usage();
55 } elsif ($#ARGV > 2) {
56 $lib_file = shift(@ARGV);
57 $obj_path = shift(@ARGV);
58 $ar_file = shift(@ARGV);
59 $lis_file = shift(@ARGV);
60 last;
61
62 } else {
63 Usage();
64 }
65 #shift(@ARGV);
66}
67
68
69$short_lib_file = $lib_file . "_bak";
70if ($lib_file =~ /[\\\/](MoDIS|UESim)[\\\/](\w+)[\\\/](Debug|Release)[\\\/](\w+\.lib)\s*$/i)
71{
72 $current_lib = lc($2);
73 $flag_modis = $3;
74 $short_lib_file = $4;
75}
76elsif ($lib_file =~ /\w+[\\|\/]{1}(\w+)(\.lib)\s*/)
77{
78 $short_lib_file = "$1$2"."_bak";
79 $current_lib = lc($1);
80}
81
82 if ( ! -e $lib_file )
83 {
84 print " no $lib_file file \n";
85 exit 0;
86 }
87
88 if ( ! ( -e $lis_file))
89 {
90 if($lis_file =~ /(.+module)/i)
91 {
92 $lis_path = $1;
93 }
94 if(defined $current_lib)
95 {
96 if($$current_lib =~ /PLUTOMMI/i )
97 {
98 $lis_file = $lis_path."/PLUTOMMI/$current_lib/$current_lib.lis";
99 }
100 elsif($$current_lib =~ /VENUS/i )
101 {
102 $lis_file = $lis_path."/VENUS/$current_lib/$current_lib.lis";
103 }
104 }
105 }
106
107 if ( ! ( -e $lis_file))
108 {
109 print " $lis_file not exist ! \n";
110 exit 0;
111 } else
112 {
113 print " lis_file = $lis_file \n";
114 }
115
116
117my $inode = stat($lib_file);
118my $mtime = $inode->mtime;
119my $ctime = $inode->ctime;
120my $atime = $inode->atime;
121
122if ($flag_print)
123{
124print " mtime = $mtime \n";
125print " ctime = $ctime \n";
126print " atime = $atime \n";
127
128#system "pause";
129
130
131print "====================================\n";
132print " lib_file = $lib_file \n";
133print " obj_path = $obj_path \n";
134print " ar_file = $ar_file \n";
135print " lis_file = $lis_file \n";
136print " short_lib_file = $short_lib_file \n";
137print "====================================\n";
138}
139
140#system "pause";
141
142#@a=<$obj_path\\*.obj>;
143# foreach $xx (@a)
144#{
145# print " find obj, exit 0 \n";
146# exit 0;
147#}
148
149
150
151 open(F, "<$lis_file");
152 my @objs=();
153
154 while (<F>)
155 {
156 if (/\w+[\\|\/]{1}(\w+\.)(c|cpp|s|arm)\s*$/)
157 {
158 chomp;
159 next if (($flag_modis ne "") && (! -e $_));
160 my $obj = $1 . "obj";
161 push(@objs, $obj);
162 }
163 }
164 close F;
165
166 print " ====================== \n";
167
168 print " objs = @objs \n";
169
170 my @real_objs = ();
171
172 foreach my $obj (@objs) {
173 if (! (-e "$obj_path/$obj" ))
174 {
175 print " not exist $obj_path\\$obj \n";
176 push(@real_objs, $obj);
177 }
178 else
179 {
180 print " exist $obj_path\\$obj \n";
181 }
182 } # foreach
183
184
185 my $cwd = getcwd();
186 chdir($obj_path);
187
188
189 if ( ! @real_objs == ())
190 {
191 if ($flag_modis eq "")
192 {
193 print " $ar_file -x $short_lib_file @real_objs \n";
194 system " $ar_file -x $short_lib_file @real_objs ";
195 }
196 else
197 {
198 foreach my $obj (@real_objs)
199 {
200 #lib /nologo /extract:.\debug\verno.obj verno.lib
201 system "$ar_file /nologo /extract:.\\$flag_modis\\$obj $short_lib_file";
202 }
203 }
204 }
205
206
207 foreach my $obj (@real_objs)
208 {
209 if ( -e $obj )
210 {
211 utime( $atime, $mtime, $obj);
212 }
213 else
214 {
215 print " no file $obj error ! \n";
216 exit 1;
217 }
218 }
219
220 chdir($cwd);
221
222
223exit 0;
224
225sub Usage {
226 print <<"__EOFUSAGE";
227Usage: $0 [-h | lib_file obj_path obj_name ]
228 -h Help.
229__EOFUSAGE
230 exit 0;
231}