1 | #! /usr/bin/perl
|
---|
2 | #
|
---|
3 | # TOPPERS Software
|
---|
4 | # Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
5 | #
|
---|
6 | # Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | # Toyohashi Univ. of Technology, JAPAN
|
---|
8 | # Copyright (C) 2005-2011 by Embedded and Real-Time Systems Laboratory
|
---|
9 | # Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
10 | #
|
---|
11 | # ãLì ÒÍCȺÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
|
---|
12 | # Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
13 | # ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
14 | # (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
15 | # \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
16 | # XR[hÉÜÜêĢ鱯D
|
---|
17 | # (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
18 | # pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
19 | gip
|
---|
20 | # Ò}j
|
---|
21 | AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
|
---|
22 | # Ì³ÛØKèðfÚ·é±ÆD
|
---|
23 | # (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
24 | # pūȢ`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
25 | # ÆD
|
---|
26 | # (a) Äzzɺ¤hL
|
---|
27 | gipÒ}j
|
---|
28 | AÈÇjÉCãLÌ
|
---|
29 | # ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
|
---|
30 | # (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
31 | # ñ·é±ÆD
|
---|
32 | # (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
33 | # Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
34 | # ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
35 | # RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
36 | # ÆÓ·é±ÆD
|
---|
37 | #
|
---|
38 | # {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
39 | # æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
40 | # ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
41 | # AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
42 | # ÌÓCðíÈ¢D
|
---|
43 | #
|
---|
44 | # @(#) $Id: genrename 509 2007-08-22 23:09:56Z hiro $
|
---|
45 | #
|
---|
46 |
|
---|
47 | #
|
---|
48 | # æªÉ¯é¶ñ
|
---|
49 | #
|
---|
50 | sub prefix_string {
|
---|
51 | local($sym) = @_;
|
---|
52 |
|
---|
53 | if ($sym =~ /[a-z]/) {
|
---|
54 | return("_kernel_");
|
---|
55 | }
|
---|
56 | else {
|
---|
57 | return("_KERNEL_");
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | #
|
---|
62 | # l[è`𶬷é
|
---|
63 | #
|
---|
64 | sub generate_define
|
---|
65 | {
|
---|
66 | local($sym, $prefix) = @_;
|
---|
67 |
|
---|
68 | print FILE "#define ",$prefix,$sym;
|
---|
69 | print FILE "\t" if (length($prefix.$sym) < 4);
|
---|
70 | print FILE "\t" if (length($prefix.$sym) < 8);
|
---|
71 | print FILE "\t" if (length($prefix.$sym) < 12);
|
---|
72 | print FILE "\t" if (length($prefix.$sym) < 16);
|
---|
73 | print FILE "\t" if (length($prefix.$sym) < 20);
|
---|
74 | print FILE "\t" if (length($prefix.$sym) < 24);
|
---|
75 | print FILE "\t",$prefix,prefix_string($sym),$sym,"\n";
|
---|
76 | }
|
---|
77 |
|
---|
78 | #
|
---|
79 | # l[ð𶬷é
|
---|
80 | #
|
---|
81 | sub generate_undef
|
---|
82 | {
|
---|
83 | local($sym, $prefix) = @_;
|
---|
84 |
|
---|
85 | print FILE "#undef ",$prefix,$sym,"\n";
|
---|
86 | }
|
---|
87 |
|
---|
88 | #
|
---|
89 | # CN[hfBNeBu𶬷é
|
---|
90 | #
|
---|
91 | sub generate_include
|
---|
92 | {
|
---|
93 | local($file, $prefix) = @_;
|
---|
94 |
|
---|
95 | $file =~ s/([>"])$/_$prefix.h$1/;
|
---|
96 | $includes .= "#include ".$file."\n";
|
---|
97 | }
|
---|
98 |
|
---|
99 | #
|
---|
100 | # G[`FbN
|
---|
101 | #
|
---|
102 | if ($#ARGV != 0) {
|
---|
103 | die "Usage: genrename <prefix>\n";
|
---|
104 | }
|
---|
105 |
|
---|
106 | #
|
---|
107 | # ú»
|
---|
108 | #
|
---|
109 | @syms = ();
|
---|
110 | $name = $ARGV[0];
|
---|
111 | $NAME = $name; $NAME =~ y/a-z/A-Z/;
|
---|
112 |
|
---|
113 | $infile = $name."_rename.def";
|
---|
114 | $header_defsym = "TOPPERS_".$NAME."_RENAME_H";
|
---|
115 |
|
---|
116 | #
|
---|
117 | # V{XgðÇÝÞ
|
---|
118 | #
|
---|
119 | open(INFILE, $infile) || die "Cannot open $infile";
|
---|
120 | while ($line = <INFILE>) {
|
---|
121 | chomp $line;
|
---|
122 | @syms = (@syms, $line);
|
---|
123 | }
|
---|
124 | close(INFILE);
|
---|
125 |
|
---|
126 | #
|
---|
127 | # ???_rename.h 𶬷é
|
---|
128 | #
|
---|
129 | $includes = "";
|
---|
130 | $file = $name."_rename.h";
|
---|
131 | open(FILE, "> ".$file);
|
---|
132 |
|
---|
133 | print FILE <<END;
|
---|
134 | /* This file is generated from $infile by genrename. */
|
---|
135 |
|
---|
136 | #ifndef $header_defsym
|
---|
137 | #define $header_defsym
|
---|
138 |
|
---|
139 | END
|
---|
140 |
|
---|
141 | foreach $sym (@syms) {
|
---|
142 | if ($sym =~ /^#(.*)$/) {
|
---|
143 | print FILE "/*\n";
|
---|
144 | print FILE " * ",$1,"\n";
|
---|
145 | print FILE " */\n";
|
---|
146 | }
|
---|
147 | elsif ($sym =~ /^INCLUDE[ \t]+(.*)$/) {
|
---|
148 | generate_include($1, "rename");
|
---|
149 | }
|
---|
150 | elsif ($sym ne "") {
|
---|
151 | generate_define($sym, "");
|
---|
152 | }
|
---|
153 | else {
|
---|
154 | print FILE "\n";
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | print FILE <<END;
|
---|
159 |
|
---|
160 | #ifdef TOPPERS_LABEL_ASM
|
---|
161 |
|
---|
162 | END
|
---|
163 |
|
---|
164 | foreach $sym (@syms) {
|
---|
165 | if ($sym =~ /^#(.*)$/) {
|
---|
166 | print FILE "/*\n";
|
---|
167 | print FILE " * ",$1,"\n";
|
---|
168 | print FILE " */\n";
|
---|
169 | }
|
---|
170 | elsif ($sym =~ /^INCLUDE[ \t]+(.*)$/) {
|
---|
171 | # do nothing
|
---|
172 | }
|
---|
173 | elsif ($sym ne "") {
|
---|
174 | generate_define($sym, "_");
|
---|
175 | }
|
---|
176 | else {
|
---|
177 | print FILE "\n";
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | print FILE <<END;
|
---|
182 |
|
---|
183 | #endif /* TOPPERS_LABEL_ASM */
|
---|
184 |
|
---|
185 | $includes
|
---|
186 | #endif /* $header_defsym */
|
---|
187 | END
|
---|
188 |
|
---|
189 | #
|
---|
190 | # ???_unrename.h 𶬷é
|
---|
191 | #
|
---|
192 | $includes = "";
|
---|
193 | $file = $name."_unrename.h";
|
---|
194 | open(FILE, "> ".$file);
|
---|
195 |
|
---|
196 | print FILE <<END;
|
---|
197 | /* This file is generated from $infile by genrename. */
|
---|
198 |
|
---|
199 | /* This file is included only when $name\_rename.h has been included. */
|
---|
200 | #ifdef $header_defsym
|
---|
201 | #undef $header_defsym
|
---|
202 |
|
---|
203 | END
|
---|
204 |
|
---|
205 | foreach $sym (@syms) {
|
---|
206 | if ($sym =~ /^#(.*)$/) {
|
---|
207 | print FILE "/*\n";
|
---|
208 | print FILE " * ",$1,"\n";
|
---|
209 | print FILE " */\n";
|
---|
210 | }
|
---|
211 | elsif ($sym =~ /^INCLUDE[ \t]+(.*)$/) {
|
---|
212 | generate_include($1, "unrename");
|
---|
213 | }
|
---|
214 | elsif ($sym ne "") {
|
---|
215 | generate_undef($sym, "");
|
---|
216 | }
|
---|
217 | else {
|
---|
218 | print FILE "\n";
|
---|
219 | }
|
---|
220 | }
|
---|
221 |
|
---|
222 | print FILE <<END;
|
---|
223 |
|
---|
224 | #ifdef TOPPERS_LABEL_ASM
|
---|
225 |
|
---|
226 | END
|
---|
227 |
|
---|
228 | foreach $sym (@syms) {
|
---|
229 | if ($sym =~ /^#(.*)$/) {
|
---|
230 | print FILE "/*\n";
|
---|
231 | print FILE " * ",$1,"\n";
|
---|
232 | print FILE " */\n";
|
---|
233 | }
|
---|
234 | elsif ($sym =~ /^INCLUDE[ \t]+(.*)$/) {
|
---|
235 | # do nothing
|
---|
236 | }
|
---|
237 | elsif ($sym ne "") {
|
---|
238 | generate_undef($sym, "_");
|
---|
239 | }
|
---|
240 | else {
|
---|
241 | print FILE "\n";
|
---|
242 | }
|
---|
243 | }
|
---|
244 |
|
---|
245 | print FILE <<END;
|
---|
246 |
|
---|
247 | #endif /* TOPPERS_LABEL_ASM */
|
---|
248 |
|
---|
249 | $includes
|
---|
250 | #endif /* $header_defsym */
|
---|
251 | END
|
---|
252 |
|
---|
253 | close(FILE);
|
---|