author | William Roberts <williamr@symbian.org> |
Sun, 10 Oct 2010 17:40:25 +0100 | |
changeset 14 | 4331846fc8cb |
child 15 | 330c2ceccdc6 |
permissions | -rw-r--r-- |
14
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
1 |
# Copyright (c) 2010 Symbian Foundation Ltd. |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
2 |
# All rights reserved. |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
3 |
# This component and the accompanying materials are made available |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
4 |
# under the terms of the License "Eclipse Public License v1.0" |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
5 |
# which accompanies this distribution, and is available |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
7 |
# |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
8 |
# Initial Contributors: |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
9 |
# Symbian Foundation - initial contribution. |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
10 |
# |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
11 |
# Contributors: |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
12 |
# |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
13 |
# Description: |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
14 |
# This script filters an OBY file given a rom_content.csv and a static_dependencies.txt |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
15 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
16 |
use strict; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
17 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
18 |
if (scalar @ARGV < 2) |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
19 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
20 |
die ("Must specify at least two arguments: rom_content.csv and static_dependencies.txt"); |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
21 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
22 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
23 |
my $rom_content_csv = shift @ARGV; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
24 |
my $static_dependencies_txt = shift @ARGV; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
25 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
26 |
open ROM_CONTENT, "<$rom_content_csv" or die("Cannot read $rom_content_csv: $!\n"); |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
27 |
my @rom_content = <ROM_CONTENT>; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
28 |
close ROM_CONTENT; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
29 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
30 |
my $rom_content_header = shift @rom_content; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
31 |
die("Not a valid rom_content.csv file") if ($rom_content_header !~ /^ROM file,/); |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
32 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
33 |
# read through the rom_content_csv looking for direct instructions |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
34 |
my %stem_substitutions; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
35 |
my %deletions; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
36 |
my %must_have; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
37 |
foreach my $line (@rom_content) |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
38 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
39 |
my ($romfile,$hostfile,$ibyfile,$package,$cmd,@rest) = split /,/, $line; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
40 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
41 |
next if ($cmd eq ""); |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
42 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
43 |
$cmd = lc $cmd; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
44 |
if ($cmd eq "stem") |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
45 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
46 |
$stem_substitutions{$romfile} = $hostfile; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
47 |
next; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
48 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
49 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
50 |
if ($cmd eq "out") |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
51 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
52 |
$deletions{$romfile} = ""; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
53 |
next; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
54 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
55 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
56 |
if ($cmd eq "in") |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
57 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
58 |
$must_have{$romfile} = 1; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
59 |
next; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
60 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
61 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
62 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
63 |
printf STDERR "%d stem, %d out, %d in\n", |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
64 |
scalar keys %stem_substitutions, |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
65 |
scalar keys %deletions, |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
66 |
scalar keys %must_have; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
67 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
68 |
# read static dependencies file |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
69 |
# process the "out" commands to recursively expand the deletions |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
70 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
71 |
# read the oby file and apply the commands |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
72 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
73 |
my $line; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
74 |
while ($line = <>) |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
75 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
76 |
chomp $line; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
77 |
if ($line =~ /^(.*=)(\S+\s+)(\S+)(\s.*)?$/) |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
78 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
79 |
my $romcmd = $1; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
80 |
my $hostfile = $2; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
81 |
my $romfile = $3; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
82 |
my $rest = $4; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
83 |
$rest = "" if (!defined $rest); |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
84 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
85 |
if ($romfile =~ /^"(.*)"$/) |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
86 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
87 |
$romfile = $1; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
88 |
$hostfile .= '"'; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
89 |
$rest = '"'. $rest; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
90 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
91 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
92 |
next if ($deletions{$romfile}); |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
93 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
94 |
if (defined $stem_substitutions{$romfile}) |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
95 |
{ |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
96 |
# print STDERR "Applying stem_ prefix to $hostfile in $line\n"; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
97 |
$hostfile =~ s/(\/|\\)([^\\\/]+)$/$1stem_$2/; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
98 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
99 |
print $romcmd, $hostfile, $romfile, $rest, "\n"; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
100 |
next; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
101 |
} |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
102 |
|
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
103 |
print $line,"\n"; |
4331846fc8cb
Add first version of tools\filter_obyfile.pl, which uses rom_content.csv to select "stem_" versions of files.
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
104 |
} |