|
1 #!perl |
|
2 |
|
3 # AllKitsRebaseline.pm |
|
4 |
|
5 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
6 # All rights reserved. |
|
7 # This component and the accompanying materials are made available |
|
8 # under the terms of "Eclipse Public License v1.0" |
|
9 # which accompanies this distribution, and is available |
|
10 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 # |
|
12 # Initial Contributors: |
|
13 # Nokia Corporation - initial contribution. |
|
14 # |
|
15 # Contributors: |
|
16 # |
|
17 # Description: |
|
18 # Version Info: |
|
19 # Run with the substed build drive as the current directory. |
|
20 # e.g. subst m: <mapped drive to build machine>/04640/output> |
|
21 # m: |
|
22 # <location of tool>\AllKitsRebaseline.pl <absolute target directory of new packages> <codeline-tree> |
|
23 # |
|
24 # |
|
25 |
|
26 |
|
27 use Win32::Registry; |
|
28 |
|
29 |
|
30 package AllKitsRebaseline; |
|
31 |
|
32 use Win32::Process; |
|
33 use Win32::Registry; |
|
34 use File::Path; |
|
35 use File::Copy; |
|
36 |
|
37 use KitStandardLocations; |
|
38 use ZipLog2Pkg; |
|
39 |
|
40 |
|
41 |
|
42 # ------------------------------------- Global variables ----------------------------------- |
|
43 |
|
44 # Drive/directory for new packages |
|
45 my $SaveToDir = ""; |
|
46 my $iprTool = "$SourceDir\\os\\buildtools\\bldsystemtools\\commonbldutils\\iprtool.pl"; |
|
47 my $commonToolsDirectory = ""; |
|
48 |
|
49 |
|
50 # --------------------------------- Start of CreatePackages() ---------------------------------- |
|
51 # |
|
52 # |
|
53 sub CreateFileLists() |
|
54 { |
|
55 |
|
56 # main array: within each entry is: |
|
57 # file name |
|
58 # IPR category to filter on |
|
59 # directory to filter on |
|
60 # a flag to indicate if warnings should be ignored if the directory does not exist |
|
61 # additional flags for CreateProcess call |
|
62 my @RequiredLists = |
|
63 ( |
|
64 # common generic |
|
65 ["GT-common-A", "A", "$SourceDir\\common\\generic"], |
|
66 ["GT-common-B", "B", "$SourceDir\\common\\generic"], |
|
67 ["GT-common-I", "I", "$SourceDir\\common\\generic"], |
|
68 ["GT-common-O", "O", "$SourceDir\\common\\generic"], |
|
69 ["GT-common-C", "C", "$SourceDir\\common\\generic"], |
|
70 ["GT-common-DET", "DET", "$SourceDir\\common\\generic", "", "-e"], |
|
71 ["GT-common-FG", "FG", "$SourceDir\\common\\generic"], |
|
72 |
|
73 # tree generic |
|
74 ["GT-$Platform-A", "A", "$SourceDir\\$Platform\\generic"], |
|
75 ["GT-$Platform-B", "B", "$SourceDir\\$Platform\\generic"], |
|
76 ["GT-$Platform-I", "I", "$SourceDir\\$Platform\\generic"], |
|
77 ["GT-$Platform-O", "O", "$SourceDir\\$Platform\\generic"], |
|
78 ["GT-$Platform-C", "C", "$SourceDir\\$Platform\\generic"], |
|
79 ["GT-$Platform-DET", "DET", "$SourceDir\\$Platform\\generic", "", "-e"], |
|
80 ["GT-$Platform-FG", "FG", "$SourceDir\\$Platform\\generic"], |
|
81 |
|
82 # common UI |
|
83 ["UI-common-A", "A", "$SourceDir\\common\\techview"], |
|
84 ["UI-common-B", "B", "$SourceDir\\common\\techview"], |
|
85 ["UI-common-I", "I", "$SourceDir\\common\\techview"], |
|
86 ["UI-common-O", "O", "$SourceDir\\common\\techview"], |
|
87 ["UI-common-C", "C", "$SourceDir\\common\\techview"], |
|
88 ["UI-common-DET", "DET", "$SourceDir\\common\\techview"], |
|
89 ["UI-common-FG", "FG", "$SourceDir\\common\\techview"], |
|
90 |
|
91 # tree UI |
|
92 ["UI-$Platform-A", "A", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
93 ["UI-$Platform-B", "B", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
94 ["UI-$Platform-I", "I", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
95 ["UI-$Platform-O", "O", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
96 ["UI-$Platform-C", "C", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
97 ["UI-$Platform-DET", "DET", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
98 ["UI-$Platform-FG", "FG", "$SourceDir\\$Platform\\techview", "nowarn"], |
|
99 |
|
100 # testtools |
|
101 ["TestTools", "DEFGT", "$SourceDir\\os\\unref\\orphan\\comtt"], |
|
102 |
|
103 # docs |
|
104 ["Doc-DET", "DET", "$OutputDir\\documentation"], |
|
105 ["Doc-FGX", "FGX", "$OutputDir\\documentation"], |
|
106 ["Doc-common-DET", "DET", "$SourceDir\\common\\developerlibrary"], |
|
107 ["Doc-common-FGX", "FGX", "$SourceDir\\common\\developerlibrary"], |
|
108 ["Doc-common-system-FGX", "FGX", "$SourceDir\\common\\system"], |
|
109 |
|
110 ["Conn-common-Src", "DEFGT", "$SourceDir\\common\\epocconnect", "nowarn"], |
|
111 ["Conn-$Platform-Src", "DEFGT", "$SourceDir\\$Platform\\epocconnect", "nowarn"], |
|
112 ["Conn-Bin", "DEFGXT", "$OutputDir\\symbianconnect", "nowarn"], |
|
113 |
|
114 ["TechViewExampleSDK", "DEFGXT","$SourceDir\\$Platform\\product\\TechViewExampleSDK"] |
|
115 ) ; |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 sub ErrorReport |
|
121 { |
|
122 print "Error: ".Win32::FormatMessage( Win32::GetLastError() ); |
|
123 } |
|
124 |
|
125 |
|
126 # get Perl bin directory |
|
127 if ( ( $main::HKEY_LOCAL_MACHINE->Open("SOFTWARE\\Perl", $RegObj) ) && ( $RegObj->QueryValueEx("bindir", my $Type, $Value) ) ) |
|
128 { |
|
129 # fix problem where Perl 5.6's bindir registry variable contains the exe, but 5.005's doesn't; remove exe name |
|
130 $Value =~ s|\\perl\.exe$||i; |
|
131 } |
|
132 else |
|
133 { |
|
134 print "Unable to find Perl key\n"; |
|
135 exit; |
|
136 } |
|
137 $RegObj->Close(); |
|
138 |
|
139 |
|
140 # preserve STDOUT, STDERR |
|
141 open(OLDOUT, ">&STDOUT") or die $!; # backup filehandles |
|
142 open(OLDERR, ">&STDERR") or die $!; |
|
143 open(STDERR, ">NUL") or die $!; |
|
144 |
|
145 |
|
146 # start the processes |
|
147 my @Processes ; |
|
148 my $ProcessObj; |
|
149 foreach $entry (@RequiredLists) |
|
150 { |
|
151 my $FileName = $entry->[0]; |
|
152 my $Category = $entry->[1]; |
|
153 my $Directory = $entry->[2]; |
|
154 my $noWarn = $entry->[3]; |
|
155 my $ExtraFlag = $entry->[4]; |
|
156 |
|
157 if (-d "$Directory") |
|
158 { |
|
159 # direct STDOUT to output file |
|
160 open(STDOUT,">$SaveToDir\\$FileName"); |
|
161 select(STDOUT); # force a flush on stdout so that any output will be in sync. |
|
162 |
|
163 # create process and inherit STDOUT |
|
164 Win32::Process::Create($ProcessObj, "$Value\\perl.exe", "perl.exe ".$iprTool." -c $Category -f -1 -s $ExtraFlag", 1, NORMAL_PRIORITY_CLASS, "$Directory") || die ErrorReport(); |
|
165 push @Processes, $ProcessObj; |
|
166 } |
|
167 else |
|
168 { |
|
169 print OLDOUT "INFO: Directory not found: $Directory\n" if ($noWarn !~ /nowarn/i); |
|
170 open(FILE,">$SaveToDir\\$FileName"); |
|
171 print FILE "\n"; # force all output files to exist, even if no content found by iprtool |
|
172 close FILE; |
|
173 } |
|
174 }; |
|
175 |
|
176 |
|
177 |
|
178 # wait for them to complete |
|
179 while (scalar(@Processes) > 0) |
|
180 { |
|
181 $ProcessObj = pop @Processes; |
|
182 $ProcessObj->Wait(INFINITE); |
|
183 print "."; |
|
184 } print "\n"; |
|
185 |
|
186 |
|
187 open(STDOUT, ">&OLDOUT") or die $!; # restore filehandle |
|
188 open(STDERR, ">&OLDERR") or die $!; |
|
189 |
|
190 my $SourceDirWithoutDrive = $SourceDir; |
|
191 $SourceDirWithoutDrive =~ s/^\w://; # remove initial drive letter |
|
192 $SourceDirWithoutDrive =~ s#\\#\\\\#g; # ensure slash is escaped |
|
193 |
|
194 my $OutputDirWithoutDrive = $OutputDir; |
|
195 $OutputDirWithoutDrive =~ s/^\w://; # remove initial drive letter |
|
196 $OutputDirWithoutDrive =~ s#\\#\\\\#g; # ensure slash is escaped |
|
197 |
|
198 # remove IPR status info and the initial directory (\src, \bin etc.) |
|
199 |
|
200 foreach $entry (@RequiredLists) |
|
201 { |
|
202 my $FileName = $entry->[0]; |
|
203 |
|
204 # read in file |
|
205 if (open (FILE, "<$SaveToDir\\$FileName")) |
|
206 { |
|
207 my @file = <FILE>; |
|
208 close(FILE); |
|
209 |
|
210 unlink("$SaveToDir\\$FileName"); |
|
211 |
|
212 if (open (FILE, ">$SaveToDir\\$FileName")) |
|
213 { |
|
214 |
|
215 foreach $line (@file) |
|
216 { |
|
217 chomp($line); |
|
218 if ($line =~ m/^\s*([\\\/].+[^\/\\]$)/) |
|
219 { |
|
220 # remove whitespace at start of line |
|
221 $line =~ s/^\s*//i; |
|
222 |
|
223 # if file name includes "common", replace preceeding part with '' |
|
224 $line =~ s/^$SourceDirWithoutDrive([\\\/]common[\\\/].*$)/$1/i; |
|
225 |
|
226 # if file name includes $Platform, replace preceeding part with '' |
|
227 $line =~ s/^$SourceDirWithoutDrive([\\\/]$Platform[\\\/].*$)/$1/i; |
|
228 |
|
229 # if file name includes bin\$Platform\<build_type>\epoc32, replace with 'epoc32' |
|
230 $line =~ s/^$OutputDirWithoutDrive[\\\/][^\\\/]*([\\\/]epoc32[\\\/].*$)/$1/i; |
|
231 |
|
232 # if file name includes bin\$Platform\, delete (for bin.connect, docs) |
|
233 $line =~ s/^$OutputDirWithoutDrive//i; |
|
234 |
|
235 # replace & with & |
|
236 $line =~ s/&/&/i; |
|
237 |
|
238 print FILE "$line\n" ; |
|
239 } |
|
240 } |
|
241 close(FILE); |
|
242 } |
|
243 else |
|
244 { |
|
245 print "ERROR: Couldn't create file $SaveToDir\\$FileName\n"; |
|
246 } |
|
247 } |
|
248 else |
|
249 { |
|
250 print "ERROR: Couldn't open file $SaveToDir\\$FileName\n"; |
|
251 } |
|
252 } |
|
253 return 0; |
|
254 |
|
255 } |
|
256 |
|
257 |
|
258 |
|
259 # --------------------------------- Start of ProcessPackageDefinitions() ---------------------------------------- |
|
260 |
|
261 sub ProcessPackageDefinitions() |
|
262 { |
|
263 |
|
264 my $PackageName = "com.symbian.src.package-definitions" ; |
|
265 |
|
266 my $header1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<packagedef version=\"1.0\">\n <package name=\""; |
|
267 my $header2 = "\" major-version=\"0\" minor-version=\"0\">\n <supplier>Symbian Ltd<\/supplier>\n <sdk-version>7.0s<\/sdk-version>\n"; |
|
268 my $depends = " <dependencies>\n <dependency name=\"$dependency\" major-version=\"0\" minor-version=\"0\" build-number=\"0\"\/>\n <\/dependencies>\n"; |
|
269 my $header3 = " <\/package>\n\n <manifest>\n"; |
|
270 my $footer = " <\/manifest>\n<\/packagedef>"; |
|
271 |
|
272 chdir ($commonToolsDirectory); # ensure correct drive |
|
273 chdir $CustKitPath."\\".$PkgDefDir or die "Failed to change directory to ".$CustKitPath."\\".$PkgDefDir; |
|
274 |
|
275 # open pkgdef file here so it's included in it's own list! |
|
276 open (FILE, ">$PackageName.pkgdef") or die "Couldn't open file $PackageName.pkgdef"; |
|
277 print FILE $header1.$PackageName.$header2.$header3; |
|
278 |
|
279 # CustKit packages first |
|
280 my @Packages = <com.symbian.*.pkgdef>; |
|
281 foreach $package (@Packages) |
|
282 { |
|
283 print FILE " <item src=\"\\$CustKitDir\\$PkgDefDir\\$package\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$CustKitDir\\$PkgDefDir\\$package\"/>\n"; |
|
284 } |
|
285 print FILE " <item src=\"\\$CustKitDir\\$PkgDefDir\\distribution.policy\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$CustKitDir\\$PkgDefDir\\distribution.policy\"/>\n" if (-e "$CustKitPath\\$PkgDefDir\\distribution.policy"); |
|
286 # single srcdef file & IPR |
|
287 print FILE " <item src=\"\\$CustKitDir\\$SrcDefDir\\CustKit.srcdef\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$CustKitDir\\$SrcDefDir\\CustKit.srcdef\"/>\n"; |
|
288 print FILE " <item src=\"\\$CustKitDir\\$SrcDefDir\\distribution.policy\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$CustKitDir\\$SrcDefDir\\distribution.policy\"/>\n" if (-e "$CustKitPath\\$SrcDefDir\\distribution.policy"); |
|
289 |
|
290 |
|
291 # DevKit packages |
|
292 chdir $DevKitPath."\\".$PkgDefDir or die "Failed to change directory to $DevKitPath\\$PkgDefDir" ; |
|
293 @Packages = <com.symbian.*pkgdef>; |
|
294 foreach $package (@Packages) |
|
295 { |
|
296 print FILE " <item src=\"\\$DevKitDir\\$PkgDefDir\\$package\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$DevKitDir\\$PkgDefDir\\$package\"/>\n"; |
|
297 } |
|
298 print FILE " <item src=\"\\$DevKitDir\\$PkgDefDir\\distribution.policy\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$DevKitDir\\$PkgDefDir\\distribution.policy\"/>\n" if (-e "$DevKitPath\\$PkgDefDir\\distribution.policy"); |
|
299 # single srcdef file & IPR |
|
300 print FILE " <item src=\"\\$DevKitDir\\$SrcDefDir\\DevKit.srcdef\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$DevKitDir\\$SrcDefDir\\DevKit.srcdef\"/>\n"; |
|
301 print FILE " <item src=\"\\$DevKitDir\\$SrcDefDir\\distribution.policy\" dest=\"[sdkroot]\\src\\$Platform\\$ProductDir\\$DevKitDir\\$SrcDefDir\\distribution.policy\"/>\n" if (-e "$DevKitPath\\$SrcDefDir\\distribution.policy"); |
|
302 |
|
303 print FILE $footer; |
|
304 close(FILE); |
|
305 } |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 # --------------------------------- Start of AllKitsRebaseline() ---------------------------------------- |
|
311 |
|
312 sub AllKitsRebaseline($) |
|
313 { |
|
314 $SaveToDir = shift; |
|
315 |
|
316 # get initial directory so other tools/scripts in this directory can be found |
|
317 $commonToolsDirectory = $FindBin::Bin; |
|
318 my $platformToolsDirectory = $commonToolsDirectory; |
|
319 $platformToolsDirectory =~ s/common/$Platform/i; |
|
320 |
|
321 |
|
322 if ($SaveToDir eq "") |
|
323 { |
|
324 die "Parameter (SaveToDir) is required - please run with parameter\n"; |
|
325 } |
|
326 |
|
327 # Create directory for saving temporary packages |
|
328 if (! -e $SaveToDir) |
|
329 { |
|
330 mkpath $SaveToDir or die "Unable to create directory $SaveToDir - $!"; |
|
331 } |
|
332 |
|
333 |
|
334 # Create the categorised lists of files |
|
335 print "** CreateFileLists()\n"; |
|
336 CreateFileLists(); |
|
337 |
|
338 |
|
339 # prepare special file lists for static packages - assumes supplementary packages will build correctly |
|
340 open (FILE,">$SaveToDir\\static"); |
|
341 my $OutputDirWithoutDrive = $OutputDir; |
|
342 $OutputDirWithoutDrive =~ s/^\w:[\/\\]//; # remove initial drive letter and slash |
|
343 print FILE "$OutputDirWithoutDrive\\techview\\epoc32\\tools\\productinstaller\\License.txt\n" if (-e "$SourceDir\\common\\generic\\tools\\custkits\\ProductInstaller\\pkgdef\\License.txt"); |
|
344 print FILE "lockit.zip\n" if (-e "$ZipDir\\lockit.zip"); |
|
345 close(FILE); |
|
346 |
|
347 |
|
348 # copy package definition files from source code control system to build directories |
|
349 (mkpath $DevKitPath or print "WARNING: Unable to create directory $DevKitPath - $!\n") if (! -d $DevKitPath); |
|
350 (mkpath $SuppKitPath or print "WARNING: Unable to create directory $SuppKitPath - $!\n") if (! -d $SuppKitPath); |
|
351 |
|
352 |
|
353 system ("xcopy $SourceDir\\$Platform\\$ProductDir\\$DevKitDir $DevKitPath /E /Z /I /Q"); |
|
354 system ("xcopy $SourceDir\\$Platform\\$ProductDir\\$SuppKitDir $SuppKitPath /E /Z /I /Q"); |
|
355 |
|
356 |
|
357 # generate the package definition files |
|
358 chdir ("$SaveToDir") or print "Unable to change to directory $SaveToDir\n"; |
|
359 print "** Source packages\n"; |
|
360 ZipLog2Pkg::ZipLog2Pkg ("$platformToolsDirectory\\".$BuildBaseName."_src", "-batch"); |
|
361 |
|
362 print "** Static packages\n"; |
|
363 ZipLog2Pkg::ZipLog2Pkg ("$platformToolsDirectory\\".$BuildBaseName."_static", "-batch"); |
|
364 |
|
365 # change to directory of new files and generate the non-source files |
|
366 chdir($FindBin::Bin) or print "Unable to change to directory $FindBin::Bin\n"; |
|
367 |
|
368 print "** NonSourceRebaseline - generating logs\n"; |
|
369 $ENV{"ProductDir"}=$ProductDir; # required by exports.bat |
|
370 system ("call $commonToolsDirectory\\exports.bat"); |
|
371 |
|
372 print "** NonSourceRebaseline - generating non source packages\n"; |
|
373 ZipLog2Pkg::ZipLog2Pkg ("$platformToolsDirectory\\".$BuildBaseName."_bin", "-batch"); |
|
374 |
|
375 |
|
376 } |
|
377 |
|
378 |
|
379 return 1; |