|
1 # Copyright (c) 2009 Symbian Foundation Ltd |
|
2 # This component and the accompanying materials are made available |
|
3 # under the terms of the License "Eclipse Public License v1.0" |
|
4 # which accompanies this distribution, and is available |
|
5 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
6 # |
|
7 # Initial Contributors: |
|
8 # Symbian Foundation Ltd - initial contribution. |
|
9 # |
|
10 # Contributors: |
|
11 # |
|
12 # Description: |
|
13 # Raptor parser module. |
|
14 # Extract, analyzes and dumps raptor recipes i.e. content of <recipe> tags from a raptor log file |
|
15 |
|
16 package RaptorRecipe; |
|
17 |
|
18 use strict; |
|
19 use RaptorCommon; |
|
20 |
|
21 our $reset_status = {}; |
|
22 my $buildlog_status = {}; |
|
23 my $buildlog_recipe_status = {}; |
|
24 |
|
25 $reset_status->{name} = 'reset_status'; |
|
26 $reset_status->{next_status} = {buildlog=>$buildlog_status}; |
|
27 |
|
28 $buildlog_status->{name} = 'buildlog_status'; |
|
29 $buildlog_status->{next_status} = {recipe=>$buildlog_recipe_status}; |
|
30 |
|
31 $buildlog_recipe_status->{name} = 'buildlog_recipe_status'; |
|
32 $buildlog_recipe_status->{next_status} = {}; |
|
33 $buildlog_recipe_status->{on_start} = 'RaptorRecipe::on_start_buildlog_recipe'; |
|
34 $buildlog_recipe_status->{on_end} = 'RaptorRecipe::on_end_buildlog_recipe'; |
|
35 $buildlog_recipe_status->{on_chars} = 'RaptorRecipe::on_chars_buildlog_recipe'; |
|
36 |
|
37 my $characters = ''; |
|
38 my $recipe_info = {}; |
|
39 |
|
40 my $category = $RaptorCommon::CATEGORY_RAPTORRECIPE; |
|
41 |
|
42 sub process |
|
43 { |
|
44 my ($text) = @_; |
|
45 |
|
46 my $severity = $RaptorCommon::SEVERITY_UNKNOWN; |
|
47 |
|
48 if ($text =~ m,Cannot process schema version .* of file,) |
|
49 { |
|
50 $severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
51 |
|
52 #dump_recipe($category, $severity, $text); |
|
53 print "$category, $severity, $text\n"; |
|
54 } |
|
55 } |
|
56 |
|
57 sub on_start_buildlog_recipe |
|
58 { |
|
59 my ($el) = @_; |
|
60 |
|
61 $recipe_info = {}; |
|
62 $characters = ''; |
|
63 |
|
64 my $attrstring = ''; |
|
65 my $bldinf = ''; |
|
66 |
|
67 my $attributes = $el->{Attributes}; |
|
68 for (keys %{$attributes}) |
|
69 { |
|
70 if ($attributes->{$_}->{'LocalName'} eq 'bldinf') |
|
71 { |
|
72 $bldinf = $attributes->{$_}->{'Value'}; |
|
73 } |
|
74 |
|
75 $attrstring .= "$attributes->{$_}->{'LocalName'}}='$attributes->{$_}->{'Value'}' "; |
|
76 |
|
77 } |
|
78 |
|
79 if ($bldinf eq '') |
|
80 { |
|
81 print "WARNING: recipe tag with no bldinf attribute. Associating to package unknown/unknown\n"; |
|
82 $bldinf = "/sf/unknown/unknown/group/bld.inf"; |
|
83 } |
|
84 |
|
85 $recipe_info->{bldinf} = $bldinf; |
|
86 |
|
87 $characters = "<recipe $attrstring>\n"; |
|
88 } |
|
89 |
|
90 sub on_chars_buildlog_recipe |
|
91 { |
|
92 my ($ch) = @_; |
|
93 |
|
94 #print "on_chars_buildlog_recipe\n"; |
|
95 |
|
96 $characters .= $ch->{Data}; |
|
97 |
|
98 #print "characters is now -->$characters<--\n"; |
|
99 } |
|
100 |
|
101 sub on_end_buildlog_recipe |
|
102 { |
|
103 #print "on_end_buildlog_recipe\n"; |
|
104 |
|
105 $characters .= "\n</recipe>\n"; |
|
106 |
|
107 my $normalized = lc($recipe_info->{bldinf}); |
|
108 $normalized =~ s,^[A-Za-z]:,,; |
|
109 $normalized =~ s,[\\],/,g; |
|
110 |
|
111 $normalized =~ m,^/sf/([^/]+)/([^/]+)/,; |
|
112 my $layer = $1; |
|
113 my $package = $2; |
|
114 |
|
115 mkdir("$::basedir/recipes"); |
|
116 mkdir("$::basedir/recipes/$layer"); |
|
117 mkdir("$::basedir/recipes/$layer/$package"); |
|
118 |
|
119 my $filename = "$::basedir/recipes/$layer/$package/recipes.txt"; |
|
120 |
|
121 print "Writing recipes file $filename\n" if (!-f$filename); |
|
122 open(FILE, ">>$filename"); |
|
123 print FILE $characters; |
|
124 close(FILE); |
|
125 } |
|
126 |
|
127 |
|
128 1; |