ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21
Committed: Tue Apr 13 17:30:19 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_9_2, V0_9_1, V0_9
Branch point for: V0_9branch
Changes since 1.20: +73 -5 lines
Log Message:
Implement Use, lib and export tags

File Contents

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