|
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 # e32toolp/e32util/prepdef.pl |
|
15 # |
|
16 # |
|
17 |
|
18 use strict; |
|
19 |
|
20 use FindBin; # for FindBin::Bin |
|
21 use Getopt::Long; |
|
22 |
|
23 my $PerlLibPath; # fully qualified pathname of the directory containing our Perl modules |
|
24 |
|
25 BEGIN { |
|
26 # check user has a version of perl that will cope |
|
27 require 5.005_03; |
|
28 # establish the path to the Perl libraries: currently the same directory as this script |
|
29 $PerlLibPath = $FindBin::Bin; # X:/epoc32/tools |
|
30 if ($^O eq "MSWin32") |
|
31 { |
|
32 $PerlLibPath =~ s/\//\\/g; # X:\epoc32\tools |
|
33 $PerlLibPath .= "\\"; |
|
34 } |
|
35 } |
|
36 |
|
37 use lib $PerlLibPath; |
|
38 use Defutl; |
|
39 use E32tpver; |
|
40 use Pathutl; |
|
41 |
|
42 |
|
43 |
|
44 # THE MAIN PROGRAM SECTION |
|
45 ########################## |
|
46 |
|
47 { |
|
48 |
|
49 |
|
50 # process the command-line |
|
51 unless (@ARGV==2 || @ARGV==3 || @ARGV==4) { |
|
52 &Usage; |
|
53 } |
|
54 my ($FRZFILE,$GENFILE,$DATASWITCH,$ABSENTSYM)=@ARGV; |
|
55 |
|
56 |
|
57 |
|
58 # Read the Frozen .DEF file |
|
59 my @FrzDataStruct; |
|
60 my $FrzExportsOn=0; |
|
61 eval { &Def_ReadFileL(\@FrzDataStruct, $FRZFILE, $FrzExportsOn); }; |
|
62 die $@ if $@; |
|
63 |
|
64 eval { &WriteOutputFileL(\@FrzDataStruct, $GENFILE, $DATASWITCH, $ABSENTSYM); }; |
|
65 die $@ if $@; |
|
66 |
|
67 exit; |
|
68 } |
|
69 |
|
70 ####################################################################### |
|
71 # SUBROUTINES |
|
72 ####################################################################### |
|
73 |
|
74 sub Usage () { |
|
75 |
|
76 print( |
|
77 "\n", |
|
78 "PREPDEF - Prepare frozen DEF file for library generation (Build ",&E32tpver,")\n", |
|
79 "\n", |
|
80 "PREPDEF [frozen .DEF file] [processed .DEF file] [nodatasizes] [entrypoint_name]\n", |
|
81 "\n", |
|
82 "\n", |
|
83 "\n" |
|
84 ); |
|
85 exit 1; |
|
86 } |
|
87 |
|
88 |
|
89 |
|
90 sub WriteOutputFileL ($$$$) { |
|
91 my ($FrzStructRef, $FILE, $DATASWITCH, $ABSENTSYM)=@_; |
|
92 |
|
93 my @Text; |
|
94 |
|
95 if ($ABSENTSYM) { |
|
96 $ABSENTSYM = '='.$ABSENTSYM; |
|
97 } |
|
98 |
|
99 # Process the frozen .DEF file |
|
100 my $FrzRef; |
|
101 my $ExportsDeclared; |
|
102 |
|
103 # get the lines of text from the frozen .DEF file |
|
104 foreach $FrzRef (@$FrzStructRef) { |
|
105 next if (!$FrzRef); |
|
106 if (!defined($$FrzRef{Ordinal})) { |
|
107 push @Text, $$FrzRef{Line}; |
|
108 $ExportsDeclared = 1 if ($$FrzRef{Line} =~ /^\s*EXPORTS\s*(\s+\S+.*)?$/io); |
|
109 next; |
|
110 } |
|
111 my $Comment=''; |
|
112 if ($$FrzRef{Comment}) { |
|
113 $Comment=" ; $$FrzRef{Comment}"; |
|
114 } |
|
115 # Mention if it is a Data symbol along with its size. |
|
116 my $data = ""; |
|
117 if(defined $$FrzRef{Data}) |
|
118 { |
|
119 if ($DATASWITCH eq "nodatasizes") |
|
120 { |
|
121 $data = " DATA"; |
|
122 } |
|
123 else |
|
124 { |
|
125 $data = " DATA $$FrzRef{Size}"; |
|
126 } |
|
127 } |
|
128 my $r3unused = $$FrzRef{R3Unused} ? " R3UNUSED" : ""; |
|
129 my $ord = $$FrzRef{Ordinal}; |
|
130 if ($$FrzRef{Absent}) { |
|
131 push @Text, "\t\"_._.absent_export_$ord\"$ABSENTSYM \@ $ord NONAME$data$r3unused$Comment\n"; |
|
132 } else { |
|
133 my $export = $$FrzRef{ExportName}; |
|
134 if ($export ne $$FrzRef{Name}) |
|
135 { |
|
136 $export .= "=$$FrzRef{Name}"; |
|
137 } |
|
138 push @Text, "\t$export \@ $ord NONAME$data$r3unused$Comment\n"; |
|
139 } |
|
140 } |
|
141 unshift @Text, "EXPORTS\n" unless ($ExportsDeclared); |
|
142 |
|
143 # add a terminating newline |
|
144 push @Text, "\n"; |
|
145 |
|
146 # write the new frozen .DEF file |
|
147 eval { &Def_WriteFileL(\@Text, $FILE); }; |
|
148 die $@ if $@; |
|
149 } |
|
150 |