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

# 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 williamc 1.22 'Use' => \&OutToMakefile,
65     'Use_StartTag' => \&Use_start,
66     'External' => \&OutToMakefile,
67     'External_StartTag' => \&External_StartTag,
68 williamc 1.21 '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 williamc 1.22 push @switchstack, $switchex;
79 williamc 1.21 $switchex->parse(); # sort out supported tags
80 williamc 1.22 pop @switchstack;
81     $switchex=$switchstack[$#switchstack]; # Make sure we can Use multiply
82 williamc 1.21 }
83    
84 williamc 1.1 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 williamc 1.12 my $filename;
136     my $objectname;
137 williamc 1.1
138     $hashref=$switch->SetupValueHash(\@vars);
139     $switch->checkparam($hashref, $name, 'file');
140     if ( ! defined $$hashref{name} ) {
141     ($$hashref{name}=$$hashref{file})=~s/\..*//;
142     }
143 williamc 1.4 # This stuff for later
144     #$fileclass=$toolbox->getclass($file);
145     #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
146 williamc 1.12 ($filename=$$hashref{file})=~s/\..*//;
147     ($objectname=$$hashref{file})=~s/\..*/\.o/;
148     ($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
149 williamc 1.14 ($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/;
150 williamc 1.9 print GNUmakefile "bin:$$hashref{name}\n";
151 williamc 1.10 print GNUmakefile "bin_debug:$$hashref{name}_d\n";
152 williamc 1.13 print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
153 williamc 1.12 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
154 williamc 1.13 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
155 williamc 1.12 print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
156 williamc 1.14 print GNUmakefile "$$hashref{name}_Insure:.psrc\n";
157 williamc 1.12 print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
158 williamc 1.16 print GNUmakefile "\t\$(CClinkCmdDebug)\n";
159 williamc 1.13 print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
160 williamc 1.16 print GNUmakefile "\t\$(CClinkCmdInsure)\n";
161 williamc 1.12 print GNUmakefile "$$hashref{name}.exe:$objectname\n";
162 williamc 1.16 print GNUmakefile "\t\$(CClinkCmd)\n";
163 williamc 1.15 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 williamc 1.10 # print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
169 williamc 1.17 print GNUmakefile <<ENDTEXT;
170 williamc 1.19 $$hashref{name}_d.exe:\$(libslocal_d)
171     $$hashref{name}.exe:\$(libslocal)
172     $$hashref{name}_Insure.exe:\$(libslocal_I)
173 williamc 1.17 $$hashref{name}_d:$$hashref{name}_d.exe
174 williamc 1.18 \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
175 williamc 1.17 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
176 williamc 1.18 \@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
177 williamc 1.20 $$hashref{name}:$$hashref{name}_d.exe
178     \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
179     $$hashref{name}_o:$$hashref{name}_o.exe
180 williamc 1.18 \@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name}
181 williamc 1.17 binfiles+=$filename
182     bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure
183     ENDTEXT
184 williamc 1.1 }
185    
186     sub External_StartTag {
187     my $name=shift;
188     my @vars=@_;
189     my $hashref;
190    
191     $hashref=$switch->SetupValueHash(\@vars);
192 williamc 1.21 if ( $Arch ) {
193 williamc 1.6 $$hashref{'ref'}=~tr[A-Z][a-z];
194 williamc 1.1 print GNUmakefile $$hashref{'ref'};
195     if ( defined $$hashref{'version'} ) {
196     print GNUmakefile "_V_".$$hashref{'version'};
197     }
198     print GNUmakefile "=true\n";
199 williamc 1.21 }
200 williamc 1.1
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 williamc 1.2 use Utilities::SCRAMUtils;
238 williamc 1.1
239     $hashref=$switch->SetupValueHash(\@vars);
240     $switch->checkparam($hashref, $name, "name");
241 williamc 1.21 $filename=SCRAMUtils::checkfile(
242     "$ENV{INTsrc}/$$hashref{name}/BuildFile");
243     if ( $filename ne "" ) {
244     ParseBuildFile_Export( $filename );
245 williamc 1.1 }
246     }
247    
248 williamc 1.5 sub CheckBuildFile {
249 williamc 1.1 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 williamc 1.5 sub _CutBlock {
280 williamc 1.1 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 williamc 1.21 }
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 williamc 1.1 }