ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.22
Committed: Wed Apr 14 13:18:41 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.21: +7 -0 lines
Log Message:
Allow External and Use in export

File Contents

# Content
1 package BuildFile;
2 require 5.001;
3 require Exporter;
4 @ISA = qw(Exporter);
5 @EXPORT = qw(CheckBuildFile ParseBuildFile @BlockClassA $DefaultBuildFile);
6
7 BEGIN {
8 use ToolBox;
9 $buildfile="BuildFile";
10 $toolbox=ToolBox->new();
11 $Arch=1;
12 push @ARCHBLOCK, $Arch;
13 }
14
15 #Parse the BuildFile
16 sub ParseBuildFile {
17 my $base=shift;
18 my $path=shift;
19 my $filename=shift @_;
20 my $fullfilename="$base/$path/$filename";
21 #print "Processing $fullfilename\n";
22 # This hash defines which Document Elements we can use
23 my $SupportedTags={
24 'Use' => \&OutToMakefile,
25 'Use_StartTag' => \&Use_start,
26 'Group' => \&OutToMakefile,
27 'Group_StartTag' => \&Group_start,
28 'External' => \&OutToMakefile,
29 'External_StartTag' => \&External_StartTag,
30 'ConfigurationClass_StartTag' => \&Class_StartTag,
31 'ConfigurationClass' => \&OutToMakefile,
32 'AssociateGroup' => \&AssociateGroup,
33 'none' => \&OutToMakefile,
34 'Bin' => 'none',
35 'Bin_StartTag' => \&Bin_start,
36 'ClassPath' => \&OutToMakefile,
37 'ClassPath_StartTag' => \&setBlockClassPath,
38 'lib' => 'none',
39 'lib_StartTag' => \&lib_start,
40 'lib_EndTag' => 'none'
41 };
42 use Utilities::Switcher;
43 $switch=Switcher->new($SupportedTags, $fullfilename);
44 $switch->{Strict_no_cr}='no';
45 #open a temporary gnumakefile to store output.
46 use Utilities::AddDir;
47 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
48 open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
49 if ( -e $ENV{LatestBuildFile} ) {
50 print GNUmakefile "include $ENV{LatestBuildFile}\n";
51 }
52 # print "writing to :\n".
53 # "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
54 $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
55 $switch->parse(); # sort out supported tags
56 close GNUmakefile;
57 }
58
59 sub ParseBuildFile_Export {
60 my $filename=shift;
61 use Tool;
62 # This hash defines which Document Elements we can use
63 my $SupportedTags={
64 'Use' => \&OutToMakefile,
65 'Use_StartTag' => \&Use_start,
66 'External' => \&OutToMakefile,
67 'External_StartTag' => \&External_StartTag,
68 'none' => 'none',
69 'export' => \&OutToMakefile,
70 'export_StartTag' => \&export_start,
71 'export_EndTag' => \&export_end,
72 'lib_StartTag' => \&lib_start_export,
73 'lib' => 'none'
74 };
75 use Utilities::Switcher;
76 $switchex=Switcher->new($SupportedTags, $filename);
77 $switchex->{Strict_no_cr}='no';
78 push @switchstack, $switchex;
79 $switchex->parse(); # sort out supported tags
80 pop @switchstack;
81 $switchex=$switchstack[$#switchstack]; # Make sure we can Use multiply
82 }
83
84 sub initialterms() {
85 my $name=shift;
86 my @string=@_;
87
88 $_=join "", @string;
89 chomp;
90 SWITCH: {
91 last SWITCH if /^#/;
92 if ( /^.*BlockClassPath.*/i ) {
93 s/^.*BlockClassPath *= *//;
94 _CutBlock($_);
95 last SWITCH;
96 }
97 } # end SWITCH
98 }
99
100 # Tag routines - called by the Switcher when tag found
101
102
103
104 #-- Override a class type with the <ConfigurationClass type=xxx> tag
105 # the type tag will pick up a pre-defined class type from project space.
106
107 sub Class_StartTag {
108 my $name=shift;
109 my $hashref;
110 my @vars=@_;
111
112 $hashref=$switch->SetupValueHash(\@vars);
113 if ( defined $$hashref{'type'} ) {
114 $ClassName=$$hashref{'type'};
115 }
116 }
117
118 sub ClassPath_StartTag {
119 my $name=shift;
120 my @vars=@_;
121 my $hashref;
122
123 $hashref=$switch->SetupValueHash(\@vars);
124 if ( defined $$hashref{'defaultpath'} ) {
125 }
126 }
127
128 sub Bin_start {
129 my $name=shift;
130 my @vars=@_;
131 my $hashref;
132 my $fileclass;
133 my @tools;
134 my $tool;
135 my $filename;
136 my $objectname;
137
138 $hashref=$switch->SetupValueHash(\@vars);
139 $switch->checkparam($hashref, $name, 'file');
140 if ( ! defined $$hashref{name} ) {
141 ($$hashref{name}=$$hashref{file})=~s/\..*//;
142 }
143 # This stuff for later
144 #$fileclass=$toolbox->getclass($file);
145 #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
146 ($filename=$$hashref{file})=~s/\..*//;
147 ($objectname=$$hashref{file})=~s/\..*/\.o/;
148 ($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
149 ($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/;
150 print GNUmakefile "bin:$$hashref{name}\n";
151 print GNUmakefile "bin_debug:$$hashref{name}_d\n";
152 print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
153 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
154 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
155 print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
156 print GNUmakefile "$$hashref{name}_Insure:.psrc\n";
157 print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
158 print GNUmakefile "\t\$(CClinkCmdDebug)\n";
159 print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
160 print GNUmakefile "\t\$(CClinkCmdInsure)\n";
161 print GNUmakefile "$$hashref{name}.exe:$objectname\n";
162 print GNUmakefile "\t\$(CClinkCmd)\n";
163 print GNUmakefile "$objectname:$$hashref{name}.dep\n";
164 print GNUmakefile "$objectname_d:$$hashref{name}.dep\n";
165 print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n";
166 print GNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
167 print GNUmakefile "-include $$hashref{name}.dep\n";
168 # print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
169 print GNUmakefile <<ENDTEXT;
170 $$hashref{name}_d.exe:\$(libslocal_d)
171 $$hashref{name}.exe:\$(libslocal)
172 $$hashref{name}_Insure.exe:\$(libslocal_I)
173 $$hashref{name}_d:$$hashref{name}_d.exe
174 \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
175 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
176 \@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
177 $$hashref{name}:$$hashref{name}_d.exe
178 \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
179 $$hashref{name}_o:$$hashref{name}_o.exe
180 \@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name}
181 binfiles+=$filename
182 bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure
183 ENDTEXT
184 }
185
186 sub External_StartTag {
187 my $name=shift;
188 my @vars=@_;
189 my $hashref;
190
191 $hashref=$switch->SetupValueHash(\@vars);
192 if ( $Arch ) {
193 $$hashref{'ref'}=~tr[A-Z][a-z];
194 print GNUmakefile $$hashref{'ref'};
195 if ( defined $$hashref{'version'} ) {
196 print GNUmakefile "_V_".$$hashref{'version'};
197 }
198 print GNUmakefile "=true\n";
199 }
200
201 }
202
203 sub Group_start {
204 my $name=shift;
205 my @vars=@_;
206 my $hashref;
207
208 $hashref=$switch->SetupValueHash(\@vars);
209 $switch->checkparam($hashref, $name, 'name');
210 print GNUmakefile "GROUP_".$$hashref{'name'};
211 if ( defined $$hashref{'version'} ) {
212 print GNUmakefile "_V_".$$hashref{'version'};
213 }
214 print GNUmakefile "=true\n";
215 }
216
217 sub External {
218 my $name=shift;
219 my @vars=@_;
220 # Will simply collect string into a seperate buffer for processind
221 # at the tag closure - used for specifying product defaults
222 # --- Oh oh all of string already in external buffer @!
223 }
224
225 sub External_EndTag {
226 my $name=shift;
227 my @vars=@_;
228
229 # process buffer and check consistency with product dtd
230 }
231
232 sub Use_start {
233 my $name=shift;
234 my @vars=@_;
235 my $hashref;
236 my $filename;
237 use Utilities::SCRAMUtils;
238
239 $hashref=$switch->SetupValueHash(\@vars);
240 $switch->checkparam($hashref, $name, "name");
241 $filename=SCRAMUtils::checkfile(
242 "$ENV{INTsrc}/$$hashref{name}/BuildFile");
243 if ( $filename ne "" ) {
244 ParseBuildFile_Export( $filename );
245 }
246 }
247
248 sub CheckBuildFile {
249 my $classdir=shift;
250 $ClassName="";
251 $thisfile="$classdir/$buildfile";
252
253 if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
254 $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
255 ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
256 }
257 elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
258 $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
259 ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
260 }
261 return $ClassName;
262 }
263
264 # List association groups between <AssociateGroup> tags
265 # seperated by newlines or spaces
266 sub AssociateGroup {
267 my $name=shift;
268 my @vars=@_;
269 my $word;
270
271 foreach $word ( @vars ){
272 chomp $word;
273 next if /^#/;
274 push @groups, $word;
275 }
276 }
277
278 # Split up the Class Block String into a useable array
279 sub _CutBlock {
280 my $string= shift @_;
281 @BlockClassA = split /\//, $string;
282 }
283
284 sub OutToMakefile {
285 my $name=shift;
286 my @vars=@_;
287
288 print GNUmakefile @vars;
289 }
290 sub setBlockClassPath {
291 my $name=shift;
292 my @vars=@_;
293 my $hashref;
294
295 $hashref=$switch->SetupValueHash(\@vars);
296 $switch->checkparam($hashref, $name, 'path');
297 $BlockClassPath=$BlockClassPath.":".$$hashref{path};
298 _CutBlock($$hashref{path});
299 }
300
301 sub export_start {
302 #Set up a toolfile object
303 $exporttool=Tool->new();
304 }
305
306 sub export_end {
307 #Write toolfile object to disk
308 $exporttool->envtomake(\*GNUmakefile);
309 }
310
311 #
312 # Export Mode Lib Tag
313 #
314 sub lib_start_export {
315 my $name=shift;
316 my @vars=@_;
317 my $hashref;
318
319 $hashref=$switchex->SetupValueHash( \@vars );
320 $switchex->checkparam($hashref, $name, 'name');
321 if ( $Arch ) {
322 if ( $switchex->context('export') ) {
323 #If export mode then add this env to the export tool
324 $exporttool->addenv('lib',$$hashref{name});
325 }
326 }
327 }
328
329 #
330 # Standard lib tag
331 #
332 sub lib_start {
333 my $name=shift;
334 my @vars=@_;
335 my $hashref;
336
337 $hashref=$switch->SetupValueHash( \@vars );
338 $switch->checkparam($hashref, $name, 'name');
339 if ( $Arch ) {
340 print GNUmakefile "lib+=$$hashref{name}\n";
341 }
342 }