ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.5
Committed: Thu Mar 18 10:32:03 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.4: +2 -2 lines
Log Message:
Remove all subroutine templates - causing problems and not really needed to implement properly

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 }
12
13 #Parse the BuildFile
14 sub ParseBuildFile {
15 my $base=shift;
16 my $path=shift;
17 my $filename=shift @_;
18 my $fullfilename="$base/$path/$filename";
19 #print "Processing $fullfilename\n";
20 # This hash defines which Document Elements we can use
21 my $SupportedTags={
22 'Use' => \&OutToMakefile,
23 'Use_StartTag' => \&Use_start,
24 'Group' => \&OutToMakefile,
25 'Group_StartTag' => \&Group_start,
26 'External' => \&OutToMakefile,
27 'External_StartTag' => \&External_StartTag,
28 'ConfigurationClass_StartTag' => \&Class_StartTag,
29 'ConfigurationClass' => \&OutToMakefile,
30 'AssociateGroup' => \&AssociateGroup,
31 'none' => \&OutToMakefile,
32 'Bin' => \&OutToMakefile,
33 'Bin_StartTag' => \&Bin_start,
34 'ClassPath' => \&OutToMakefile,
35 'ClassPath_StartTag' => \&setBlockClassPath
36 };
37 use Utilities::Switcher;
38 $switch=Switcher->new($SupportedTags, $fullfilename);
39 $switch->{Strict_no_cr}='no';
40 #open a temporary gnumakefile to store output.
41 use Utilities::AddDir;
42 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
43 open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
44 if ( -e $ENV{LatestBuildFile} ) {
45 print GNUmakefile "include $ENV{LatestBuildFile}\n";
46 }
47 # print "writing to :\n".
48 # "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
49 $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
50 $switch->parse(); # sort out supported tags
51 close GNUmakefile;
52 }
53
54 sub initialterms() {
55 my $name=shift;
56 my @string=@_;
57
58 $_=join "", @string;
59 chomp;
60 SWITCH: {
61 last SWITCH if /^#/;
62 if ( /^.*BlockClassPath.*/i ) {
63 s/^.*BlockClassPath *= *//;
64 _CutBlock($_);
65 last SWITCH;
66 }
67 } # end SWITCH
68 }
69
70 # Tag routines - called by the Switcher when tag found
71
72
73
74 #-- Override a class type with the <ConfigurationClass type=xxx> tag
75 # the type tag will pick up a pre-defined class type from project space.
76
77 sub Class_StartTag {
78 my $name=shift;
79 my $hashref;
80 my @vars=@_;
81
82 $hashref=$switch->SetupValueHash(\@vars);
83 if ( defined $$hashref{'type'} ) {
84 $ClassName=$$hashref{'type'};
85 }
86 }
87
88 sub ClassPath_StartTag {
89 my $name=shift;
90 my @vars=@_;
91 my $hashref;
92
93 $hashref=$switch->SetupValueHash(\@vars);
94 if ( defined $$hashref{'defaultpath'} ) {
95 }
96 }
97
98 sub Bin_start {
99 my $name=shift;
100 my @vars=@_;
101 my $hashref;
102 my $fileclass;
103 my @tools;
104 my $tool;
105
106 $hashref=$switch->SetupValueHash(\@vars);
107 $switch->checkparam($hashref, $name, 'file');
108 if ( ! defined $$hashref{name} ) {
109 ($$hashref{name}=$$hashref{file})=~s/\..*//;
110 }
111 # This stuff for later
112 #$fileclass=$toolbox->getclass($file);
113 #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
114 print GNUmakefile "bin::$$hashref{name}\n";
115 print GNUmakefile "$$hashref{name}::$$hashref{file}\n";
116 }
117
118 sub External_StartTag {
119 my $name=shift;
120 my @vars=@_;
121 my $hashref;
122
123 $hashref=$switch->SetupValueHash(\@vars);
124 print GNUmakefile $$hashref{'ref'};
125 if ( defined $$hashref{'version'} ) {
126 print GNUmakefile "_V_".$$hashref{'version'};
127 }
128 print GNUmakefile "=true\n";
129
130 }
131
132 sub Group_start {
133 my $name=shift;
134 my @vars=@_;
135 my $hashref;
136
137 $hashref=$switch->SetupValueHash(\@vars);
138 $switch->checkparam($hashref, $name, 'name');
139 print GNUmakefile "GROUP_".$$hashref{'name'};
140 if ( defined $$hashref{'version'} ) {
141 print GNUmakefile "_V_".$$hashref{'version'};
142 }
143 print GNUmakefile "=true\n";
144 }
145
146 sub External {
147 my $name=shift;
148 my @vars=@_;
149 # Will simply collect string into a seperate buffer for processind
150 # at the tag closure - used for specifying product defaults
151 # --- Oh oh all of string already in external buffer @!
152 }
153
154 sub External_EndTag {
155 my $name=shift;
156 my @vars=@_;
157
158 # process buffer and check consistency with product dtd
159 }
160
161 sub Use_start {
162 my $name=shift;
163 my @vars=@_;
164 my $hashref;
165 my $filename;
166 use Utilities::SCRAMUtils;
167
168 $hashref=$switch->SetupValueHash(\@vars);
169 $switch->checkparam($hashref, $name, "name");
170 if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile")
171 ne "" ) {
172 print GNUmakefile "ReqDependencies += $filename\n";
173 }
174 print GNUmakefile "local__$$hashref{name}=true\n";
175 }
176
177 sub CheckBuildFile {
178 my $classdir=shift;
179 $ClassName="";
180 $thisfile="$classdir/$buildfile";
181
182 if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
183 $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
184 ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
185 }
186 elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
187 $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
188 ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
189 }
190 return $ClassName;
191 }
192
193 # List association groups between <AssociateGroup> tags
194 # seperated by newlines or spaces
195 sub AssociateGroup {
196 my $name=shift;
197 my @vars=@_;
198 my $word;
199
200 foreach $word ( @vars ){
201 chomp $word;
202 next if /^#/;
203 push @groups, $word;
204 }
205 }
206
207 # Split up the Class Block String into a useable array
208 sub _CutBlock {
209 my $string= shift @_;
210 @BlockClassA = split /\//, $string;
211 }
212
213 sub OutToMakefile {
214 my $name=shift;
215 my @vars=@_;
216
217 print GNUmakefile @vars;
218 }
219 sub setBlockClassPath {
220 my $name=shift;
221 my @vars=@_;
222 my $hashref;
223
224 $hashref=$switch->SetupValueHash(\@vars);
225 $switch->checkparam($hashref, $name, 'path');
226 $BlockClassPath=$BlockClassPath.":".$$hashref{path};
227 _CutBlock($$hashref{path});
228 }