|
1 # Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 # Full build equiv that builds WINSCW targets only |
|
17 |
|
18 use strict; |
|
19 |
|
20 my $ARGC = @ARGV; |
|
21 if (($ARGV[0] eq "-h") || |
|
22 ($ARGV[0] eq "--h") || |
|
23 ($ARGV[0] eq "-help") || |
|
24 ($ARGV[0] eq "--help") || |
|
25 ($ARGV[0] eq "help") |
|
26 ) |
|
27 { |
|
28 print "\n"; |
|
29 print "winsMmBuild - Builds for WINSCW only\n\n"; |
|
30 print "Syntax : winsMmBuild [-x] [-k] [-c] [-dir=directory] [-a3flog]\n"; |
|
31 print "-cw WINSCW build - NOTE: does nothing as this is default\n"; |
|
32 print "-x include optional elements\n"; |
|
33 print "-f build A3F DevSound instead of DevSound\n"; |
|
34 print "-l build Legacy DevSound instead of A3F (ignored if -f given)\n"; |
|
35 print "-k keep going\n"; |
|
36 print "-c clean build\n"; |
|
37 print "-dir location of TestTools\\Build directory\n"; |
|
38 print "-a3flog enables A3F logging\n"; |
|
39 print "-iclTestdata builds ICL test data\n"; |
|
40 exit 0; |
|
41 } |
|
42 |
|
43 |
|
44 use Getopt::Long; |
|
45 my %optctl = (); |
|
46 keys(%optctl)=5; |
|
47 unless (GetOptions (\%optctl, "x", "f", "l", "c", "cw" , "k", "dir=s", "a3flog","iclTestdata")) |
|
48 {exit 1;} |
|
49 |
|
50 my $ccover_target = "winscw"; |
|
51 |
|
52 my $targetToolsDir = "..\\..\\..\\..\\..\\TargetTools\\Build"; |
|
53 my $testToolsDir = "..\\..\\mmtesttools\\Build"; |
|
54 my $targetToolsExists = 0; |
|
55 if (-d $targetToolsDir) |
|
56 { |
|
57 $targetToolsExists = 1; |
|
58 print "TargetTools directory exists: $targetToolsDir\n" |
|
59 } |
|
60 |
|
61 # main |
|
62 { |
|
63 |
|
64 ################## A3F Section ####################################### |
|
65 my $a3f_define = 'SYMBIAN_MULTIMEDIA_A3FDEVSOUND'; |
|
66 my $search_item = '#define\s+'.$a3f_define; # looking for this |
|
67 my $hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\Symbian_OS.hrh"; # assign hrh file and location |
|
68 my $found_search_item = 0; #false |
|
69 my $iclTest = " --iclTestdata " if ($optctl{"iclTestdata"}); |
|
70 # print "HRH filename is : $hrh_filename\n"; |
|
71 |
|
72 if ($optctl{"f"}) |
|
73 { |
|
74 # This displays the content of the hash table |
|
75 # use it to confirm the "f" entry has been added. |
|
76 # |
|
77 # my $key; # holds the command line options |
|
78 # my $value; # redundant for hash entry as only a key is used. |
|
79 # while (($key, $value) = each(%optctl)) |
|
80 # { |
|
81 # print $key.", ".$value."\n"; |
|
82 # } |
|
83 |
|
84 # opens up the hrh file for reading |
|
85 open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n"; |
|
86 |
|
87 my @file_data=<FILEHANDLE>; # read all file data into array |
|
88 |
|
89 #check the contents of the array (i.e. the contents of the file) |
|
90 for(@file_data) |
|
91 { |
|
92 # print "$_\n"; #display the line in the file |
|
93 |
|
94 # search line for string of interest: =~ is equals, !~ is not equal |
|
95 if(($_ =~ m/$search_item/i)) |
|
96 { |
|
97 $found_search_item = 1; #found the macro |
|
98 # print "Search item found: $_\n"; #display the line containing the search item |
|
99 } |
|
100 else |
|
101 { |
|
102 # Search item not found, do nothing |
|
103 } |
|
104 } #for loop |
|
105 |
|
106 close(FILEHANDLE) or die "Can't close file $hrh_filename.\n"; # readonly file |
|
107 |
|
108 if(!$found_search_item) #search item has not been found |
|
109 { |
|
110 # print warning |
|
111 print "Modifying file $hrh_filename to enable A3F as -f flag has been used.\n"; |
|
112 |
|
113 # open file for append |
|
114 open(FILEHANDLE, ">>", $hrh_filename) or die "Unable to open $hrh_filename for appending. $!\n"; |
|
115 print FILEHANDLE "\n#define $a3f_define\n"; # append macro to the file |
|
116 |
|
117 close(FILEHANDLE) or die "Can't close appended file $hrh_filename.\n"; # readonly file |
|
118 } |
|
119 |
|
120 # Now remove the "f" from the hash table so there is no chance of it being passed |
|
121 # to anything called in this file. |
|
122 ######## NOTE removal of flag from Hash table ############ |
|
123 delete($optctl{f}); |
|
124 |
|
125 # This displays the content of the hash table |
|
126 # use it to confirm the "f" entry has been removed. |
|
127 # |
|
128 # while (($key, $value) = each(%optctl)) |
|
129 # { |
|
130 # print $key.", ".$value."\n"; |
|
131 # } |
|
132 |
|
133 } # if $optctl{"f"} |
|
134 elsif ($optctl{"l"}) |
|
135 { |
|
136 ########### Remove the macro from the hrh as "-f" is not specified ############### |
|
137 |
|
138 $found_search_item = 0 ; # false |
|
139 # opens up the original hrh file for reading |
|
140 open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n"; |
|
141 |
|
142 # temporary file |
|
143 my $temp_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\temp_Symbian_OS.hrh"; |
|
144 # open temporary file for writing |
|
145 open(TEMPFILEHANDLE, ">", $temp_hrh_filename) or die "can't open tempory file $temp_hrh_filename. $!\n"; |
|
146 |
|
147 my @file_data=<FILEHANDLE>; # read all original hrh file data into array |
|
148 |
|
149 #check the contents of the array (i.e. the contents of the file) |
|
150 for(@file_data) |
|
151 { |
|
152 # print "$_\n"; #display the line in the file |
|
153 |
|
154 # search line for string of interest: =~ is equals, !~ is not equal |
|
155 if(($_ =~ m/(.*)$search_item(.*)/i)) |
|
156 { |
|
157 #display a warning message (only do so once) |
|
158 if( !$found_search_item ) |
|
159 { |
|
160 print "Modifying file $hrh_filename to disable A3F as -l flag has been used.\n"; |
|
161 } |
|
162 |
|
163 # write line excluding the #define bit to temp file. (to preserve any other bits in this line. e.g.: comment delimiters) |
|
164 print TEMPFILEHANDLE $1." ".$2."\n"; |
|
165 $found_search_item = 1 ; # true |
|
166 # Do not write line to the file as we want to remove it. |
|
167 } |
|
168 else |
|
169 { |
|
170 print TEMPFILEHANDLE $_; # copy unchanged line to temporary file |
|
171 } |
|
172 } #for loop |
|
173 |
|
174 close(FILEHANDLE) or die "Can't close file $hrh_filename.$!\n"; # readonly file |
|
175 close(TEMPFILEHANDLE) or die "Can't close file $temp_hrh_filename. $!\n"; # temp file |
|
176 if($found_search_item) |
|
177 { |
|
178 my $orig_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\orig.hrh"; |
|
179 rename($hrh_filename, $orig_hrh_filename) or die "can't rename $hrh_filename to $orig_hrh_filename: $!\n"; |
|
180 rename($temp_hrh_filename, $hrh_filename) or die "can't rename $temp_hrh_filename to $hrh_filename: $!\n"; |
|
181 unlink $orig_hrh_filename; # delete the original as it is no longer needed |
|
182 } |
|
183 else |
|
184 { |
|
185 unlink $temp_hrh_filename; # no changes to be made so delete the temporary file |
|
186 } |
|
187 |
|
188 } # main else for A3F |
|
189 |
|
190 ################## End A3F Section #################################### |
|
191 |
|
192 ################## A3F Logging Section #################################### |
|
193 |
|
194 my $search_item = "SYMBIAN_MULTIMEDIA_A3F_ENABLE_LOGGING"; # looking for this |
|
195 my $hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\Symbian_OS.hrh"; # assign hrh file and location |
|
196 my $found_search_item = 0; #false |
|
197 |
|
198 if ($optctl{"a3flog"}) |
|
199 { |
|
200 # opens up the hrh file for reading |
|
201 open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n"; |
|
202 |
|
203 my @file_data=<FILEHANDLE>; # read all file data into array |
|
204 |
|
205 #check the contents of the array (i.e. the contents of the file) |
|
206 for(@file_data) |
|
207 { |
|
208 # search line for string of interest: =~ is equals, !~ is not equal |
|
209 if(($_ =~ m/$search_item/i)) |
|
210 { |
|
211 $found_search_item = 1; #found the macro |
|
212 } |
|
213 else |
|
214 { |
|
215 # Search item not found, do nothing |
|
216 } |
|
217 } #for loop |
|
218 |
|
219 close(FILEHANDLE) or die "Can't close file $hrh_filename.\n"; # readonly file |
|
220 |
|
221 if(!$found_search_item) #search item has not been found |
|
222 { |
|
223 # open file for append |
|
224 open(FILEHANDLE, ">>", $hrh_filename) or die "Unable to open $hrh_filename for appending. $!\n"; |
|
225 print FILEHANDLE "\n#define $search_item\n"; # append macro to the file |
|
226 close(FILEHANDLE) or die "Can't close appended file $hrh_filename.\n"; # readonly file |
|
227 } |
|
228 |
|
229 # Now remove the "log" from the hash table so there is no chance of it being passed |
|
230 # to anything called in this file. |
|
231 ######## NOTE removal of flag from Hash table ############ |
|
232 delete($optctl{log}); |
|
233 } # if $optctl{"log"} |
|
234 else |
|
235 { |
|
236 ########### Remove the macro from the hrh as "-a3flog" is not specified ############### |
|
237 |
|
238 $found_search_item = 0 ; # false |
|
239 # opens up the original hrh file for reading |
|
240 open(FILEHANDLE, "<", $hrh_filename) or die "Unable to open $hrh_filename for reading. $!\n"; |
|
241 |
|
242 # temporary file |
|
243 my $temp_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\temp_Symbian_OS.hrh"; |
|
244 # open temporary file for writing |
|
245 open(TEMPFILEHANDLE, ">", $temp_hrh_filename) or die "can't open tempory file $temp_hrh_filename. $!\n"; |
|
246 |
|
247 my @file_data=<FILEHANDLE>; # read all original hrh file data into array |
|
248 |
|
249 #check the contents of the array (i.e. the contents of the file) |
|
250 for(@file_data) |
|
251 { |
|
252 # search line for string of interest: =~ is equals, !~ is not equal |
|
253 if(($_ =~ m/$search_item/i)) |
|
254 { |
|
255 #display a warning message |
|
256 print "Removing $_ from file $hrh_filename as -a3flog flag has not been used to indicate an A3F logging build is required.\n"; |
|
257 $found_search_item = 1 ; # true |
|
258 # Do not write line to the file as we want to remove it. |
|
259 } |
|
260 else |
|
261 { |
|
262 # Ensure the last newline after the macro is not written to the file. |
|
263 # the last new line was added by the macro append in the previous section. |
|
264 # The asssumes the macro is the last entry in the file. If it is not then |
|
265 # the if statement should be removed and the print statement left on its own |
|
266 # to copy the last line to file. |
|
267 if(!$found_search_item) |
|
268 { |
|
269 print TEMPFILEHANDLE $_; # copy unchanged line to temporary file |
|
270 } |
|
271 } |
|
272 } #for loop |
|
273 |
|
274 close(FILEHANDLE) or die "Can't close file $hrh_filename.$!\n"; # readonly file |
|
275 close(TEMPFILEHANDLE) or die "Can't close file $temp_hrh_filename. $!\n"; # temp file |
|
276 if($found_search_item) |
|
277 { |
|
278 my $orig_hrh_filename = "$ENV{EPOCROOT}epoc32\\include\\variant\\orig.hrh"; |
|
279 rename($hrh_filename, $orig_hrh_filename) or die "can't rename $hrh_filename to $orig_hrh_filename: $!\n"; |
|
280 rename($temp_hrh_filename, $hrh_filename) or die "can't rename $temp_hrh_filename to $hrh_filename: $!\n"; |
|
281 unlink $orig_hrh_filename; # delete the original as it is no longer needed |
|
282 } |
|
283 else |
|
284 { |
|
285 unlink $temp_hrh_filename; # no changes to be made so delete the temporary file |
|
286 } |
|
287 |
|
288 } # main else for A3F |
|
289 |
|
290 ################## End A3F Logging Section #################################### |
|
291 |
|
292 |
|
293 my $optional = "-x " if ($optctl{"x"}); |
|
294 my $keep = "-k " if ($optctl{"k"}); |
|
295 my $target = ""; # default to all |
|
296 my $build = "winscw"; |
|
297 |
|
298 if($optctl{"dir"}) |
|
299 { |
|
300 my $dir = $optctl{"dir"}; |
|
301 chdir $dir or die "Can't cd $dir - $!"; |
|
302 } |
|
303 |
|
304 |
|
305 if($optctl{"cw"}) |
|
306 { |
|
307 $build = "winscw"; |
|
308 } |
|
309 |
|
310 my $command; |
|
311 |
|
312 # mmbuild [-x] [-k] setup |
|
313 $command = "mmbuild " . $optional . $keep . "setup". $iclTest; |
|
314 (system ($command)==0 )or die "Couldn't execute $command"; |
|
315 |
|
316 if ($optctl{"c"}) |
|
317 { |
|
318 # mmbuild -t clean (throw away result - so we ignore any no-export errors) |
|
319 $command = "mmbuild -t clean >\$NULL 2>&1"; |
|
320 print $command, "\n"; |
|
321 (system ($command)==0 )or die "Couldn't execute $command"; |
|
322 } |
|
323 |
|
324 |
|
325 |
|
326 # mmbuild [-k] build |
|
327 $command = "mmbuild ". $keep. "build " . $build. $iclTest; |
|
328 (system ($command)==0 )or die "Couldn't execute $command"; |
|
329 |
|
330 # mmbuild -t [-k] build |
|
331 $command = "mmbuild -t ". $keep. "build ". $build. $iclTest; |
|
332 (system ($command)==0 )or die "Couldn't execute $command"; |
|
333 |
|
334 # mmbuild -t -b[-k] build |
|
335 $command = "mmbuild -t -b ". $keep. "build ". $build. $iclTest; |
|
336 (system ($command)==0 )or die "Couldn't execute $command"; |
|
337 |
|
338 } |