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