mte_parse_img_usage.pl
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#
# MTE image resource header file generator
#
open(INFILE, "<.\\debug\\image_resource_usage.txt") or die "Cannot open image_resource_usage.txt!";
open(OUTFILE, ">..\\CustResource\\mte_img_resource.h") or die "Cannot open mte_img_resource.h!";
%image_resource_hash = ();
$backslash_warn = 0;
$warning_msg = "Please make sure the number of consecutive backslashes is EVEN.\n[ID] [PATH]\n";
$count = 0;
$total_size = 0;
$content = "
typedef struct
{
S32 id;
S32 size;
S8* path;
} mmi_mte_img_resource_struct;
static const mmi_mte_img_resource_struct g_mmi_mte_img_resource[] =
{
";
$l = <INFILE>; # skip the first line cotaning only column names
while ($l = <INFILE>)
{
chomp($l);
@v = split(/\t/, $l);
($id, $name, $size, $file_path) = @v[2..5];
$file_path =~ /^\.\.\\\\\.\.\\\\Customer\\\\Images\\\\(.*)/i;
$file_path = $1;
# warnings on even backslashes
while ($file_path =~ /(\\+)/g)
{
if (length($1) & 1)
{
$backslash_warn++;
$warning_msg .="$backslash_warn: $name $file_path\n";
last;
}
}
if ($file_path eq "")
{
$file_path = "NULL";
}
else
{
$file_path = '"'.$file_path.'"';
}
if ($image_resource_hash{$file_path})
{ # only count 1 duped image
$size = -$size;
$image_resource_hash{$file_path}++;
}
else
{
$image_resource_hash{$file_path} = 1;
$total_size += $size;
}
$content .= "{$id, $size, $file_path}, // $name\n";
$count++;
}
# output mte resource header file
print OUTFILE "//\n// DO NOT MODIFY THIS FILE!!!\n//\n\n";
print OUTFILE "#define MMI_MTE_SYSTEM_IMAGE_RESOURCE_SIZE $total_size\n";
print OUTFILE "#define MMI_MTE_SYSTEM_IMAGE_RESOURCE_NUM $count\n";
print OUTFILE $content;
print OUTFILE "};\n\n";
close(OUTFILE);
close(INFILE);
print $warning_msg."\n" if $backslash_warn;
# copy convert.exe to modis directory for MTE usage
`copy convert.exe ..\\..\\..\\modis\\modis\\debug`;
`copy convert.exe ..\\..\\..\\modis\\modis\\release`;