1 # Copyright (c) 2003-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 # Script to Generate the XML file that is suitable for Diamonds |
|
15 # |
|
16 # |
|
17 package GenDiamondsXml; |
|
18 use FindBin; |
|
19 use lib "$FindBin::Bin/lib"; |
|
20 use strict; |
|
21 use Text::Template; |
|
22 use Text::Template 'fill_in_file'; |
|
23 use publishDiamonds; |
|
24 use ZipDiamondsXml; |
|
25 |
|
26 my $Debug = 0; |
|
27 my $MainXML = "Main.xml"; |
|
28 my @start; |
|
29 if($ENV{BuildSubType} eq "Daily") |
|
30 { |
|
31 @start = ('build.tmpl','schema.tmpl','locations.tmpl','tools.tmpl','content.tmpl','files.tmpl'); |
|
32 } |
|
33 elsif($ENV{BuildSubType} eq "Test") |
|
34 { |
|
35 @start = ('build.tmpl','schema.tmpl','locations.tmpl','tools.tmpl','files.tmpl'); |
|
36 } |
|
37 |
|
38 my %states = ( |
|
39 'STARTBUILD' => { |
|
40 'START' => \@start |
|
41 #~ 'START' => ['files.tmpl'] |
|
42 }, |
|
43 'GT' => { |
|
44 'START' => ['stage.tmpl'], |
|
45 'STOP' => ['stage.tmpl', 'faults.tmpl'] |
|
46 }, |
|
47 'TV' => { |
|
48 'START' => ['stage.tmpl'], |
|
49 'STOP' => ['stage.tmpl','faults.tmpl'] |
|
50 }, |
|
51 'ROM' => { |
|
52 'START' => ['stage.tmpl'], |
|
53 'STOP' => ['stage.tmpl','faults.tmpl'] |
|
54 }, |
|
55 'CBR' => { |
|
56 'START' => ['stage.tmpl'], |
|
57 'STOP' => ['stage.tmpl','faults.tmpl'] |
|
58 }, |
|
59 'CDB' => { |
|
60 'START' => ['stage.tmpl'], |
|
61 'STOP' => ['stage.tmpl','faults.tmpl'] |
|
62 }, |
|
63 'BUILD' => { |
|
64 'START' => ['stage.tmpl'], |
|
65 'STOP' => ['stage.tmpl','faults.tmpl'] |
|
66 }, |
|
67 'SMOKETEST' => { |
|
68 'STOP' => ['smoketest.tmpl'] |
|
69 }, |
|
70 'ENDBUILD' => { |
|
71 'START' => ['diamonds_finish.tmpl', 'status.tmpl'] |
|
72 } |
|
73 ); |
|
74 |
|
75 sub main |
|
76 { |
|
77 my ($iStage, $iState, $iServer) = @_; |
|
78 print "STAGE: $iStage\t STATE: $iState\n"; |
|
79 my %vars = (); |
|
80 $vars{'iStage'} = $iStage; |
|
81 $vars{$iState} = 1; |
|
82 my $LogsLocation = $ENV{LogsDir}."\\"; |
|
83 my @toMerge = (); |
|
84 my $BatFile = "SendXmls.bat"; |
|
85 open (BAT,">>$BatFile") or warn "$BatFile: $!\n"; |
|
86 |
|
87 foreach my $tmpl (@{$states{$iStage}{$iState}}) |
|
88 { |
|
89 my $suffix = "_".$iStage."_".$iState; |
|
90 my $XmlName = $tmpl; |
|
91 $XmlName =~ s/\.tmpl/$suffix\.xml/; |
|
92 my $outfile = $LogsLocation.$XmlName; |
|
93 $tmpl = "$FindBin::Bin/".$tmpl; |
|
94 open(OUT,">$outfile"); |
|
95 print "Processing $tmpl...\n" if $Debug; |
|
96 my $template = Text::Template->new(TYPE => 'FILE', SOURCE => $tmpl)or die "Couldn't construct template: $Text::Template::ERROR"; |
|
97 my $success = $template->fill_in(OUTPUT => \*OUT, DELIMITERS => [ '[@--', '--@]' ], HASH => \%vars) or warn "$Text::Template::ERROR\n"; |
|
98 close(OUT); |
|
99 if ($success) |
|
100 { |
|
101 print "Successfully processed $tmpl\n" if $Debug; |
|
102 &publishDiamonds::publishToDiamonds($outfile,$iServer) if($ENV{BuildSubType} eq "Daily"); |
|
103 &ZipDiamondsXml::main($outfile); |
|
104 print BAT "perl -e \"use publishDiamonds; &publishDiamonds::publishToDiamonds(\'$XmlName\',\'$iServer\');\"\n"; |
|
105 unlink ($outfile) or warn "Error in deleting: $!\n"; |
|
106 } |
|
107 } |
|
108 close(BAT); |
|
109 if ($iStage eq "ENDBUILD") |
|
110 { |
|
111 &ZipDiamondsXml::main($BatFile); |
|
112 unlink ($BatFile) or warn "Error in deleting: $!\n"; |
|
113 &ZipDiamondsXml::main($FindBin::Bin."/"."publishDiamonds.pm"); |
|
114 &ZipDiamondsXml::main($FindBin::Bin."/"."send_xml_to_diamonds.pl"); |
|
115 } |
|
116 } |
|
117 1; |
|