ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.13
Committed: Wed Mar 31 13:34:47 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.12: +6 -0 lines
Log Message:
Add Insure Support

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' => 'none',
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 my $filename;
106 my $objectname;
107
108 $hashref=$switch->SetupValueHash(\@vars);
109 $switch->checkparam($hashref, $name, 'file');
110 if ( ! defined $$hashref{name} ) {
111 ($$hashref{name}=$$hashref{file})=~s/\..*//;
112 }
113 # This stuff for later
114 #$fileclass=$toolbox->getclass($file);
115 #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
116 ($filename=$$hashref{file})=~s/\..*//;
117 ($objectname=$$hashref{file})=~s/\..*/\.o/;
118 ($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
119 print GNUmakefile "bin:$$hashref{name}\n";
120 print GNUmakefile "bin_debug:$$hashref{name}_d\n";
121 print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
122 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
123 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
124 print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
125 print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
126 print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
127 print GNUmakefile "$$hashref{name}.exe:$objectname\n";
128 # print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
129 print GNUmakefile "$$hashref{name}_d:$$hashref{name}_d.exe\n";
130 print GNUmakefile "\t\@mv $$hashref{name}_d.exe \$(binarystore)/".
131 "$$hashref{name}\n";
132 print GNUmakefile "$$hashref{name}_Insure:$$hashref{name}_Insure.exe\n";
133 print GNUmakefile "\t\@mv $$hashref{name}_Insure.exe \$(binarystore)/".
134 "$$hashref{name}\n";
135 print GNUmakefile "$$hashref{name}:$$hashref{name}.exe\n";
136 print GNUmakefile "\t\@mv $$hashref{name}.exe \$(binarystore)/".
137 "$$hashref{name}\n";
138 print GNUmakefile "binfiles+=$filename\n";
139 print GNUmakefile "bintargets+=$$hashref{name} $$hashref{name}_d\n";
140 print GNUmakefile "files+=$$hashref{file}\n";
141
142 }
143
144 sub External_StartTag {
145 my $name=shift;
146 my @vars=@_;
147 my $hashref;
148
149 $hashref=$switch->SetupValueHash(\@vars);
150 $$hashref{'ref'}=~tr[A-Z][a-z];
151 print GNUmakefile $$hashref{'ref'};
152 if ( defined $$hashref{'version'} ) {
153 print GNUmakefile "_V_".$$hashref{'version'};
154 }
155 print GNUmakefile "=true\n";
156
157 }
158
159 sub Group_start {
160 my $name=shift;
161 my @vars=@_;
162 my $hashref;
163
164 $hashref=$switch->SetupValueHash(\@vars);
165 $switch->checkparam($hashref, $name, 'name');
166 print GNUmakefile "GROUP_".$$hashref{'name'};
167 if ( defined $$hashref{'version'} ) {
168 print GNUmakefile "_V_".$$hashref{'version'};
169 }
170 print GNUmakefile "=true\n";
171 }
172
173 sub External {
174 my $name=shift;
175 my @vars=@_;
176 # Will simply collect string into a seperate buffer for processind
177 # at the tag closure - used for specifying product defaults
178 # --- Oh oh all of string already in external buffer @!
179 }
180
181 sub External_EndTag {
182 my $name=shift;
183 my @vars=@_;
184
185 # process buffer and check consistency with product dtd
186 }
187
188 sub Use_start {
189 my $name=shift;
190 my @vars=@_;
191 my $hashref;
192 my $filename;
193 use Utilities::SCRAMUtils;
194
195 $hashref=$switch->SetupValueHash(\@vars);
196 $switch->checkparam($hashref, $name, "name");
197 if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile")
198 ne "" ) {
199 print GNUmakefile "ReqDependencies += $filename\n";
200 }
201 print GNUmakefile "local__$$hashref{name}=true\n";
202 }
203
204 sub CheckBuildFile {
205 my $classdir=shift;
206 $ClassName="";
207 $thisfile="$classdir/$buildfile";
208
209 if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
210 $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
211 ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
212 }
213 elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
214 $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
215 ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
216 }
217 return $ClassName;
218 }
219
220 # List association groups between <AssociateGroup> tags
221 # seperated by newlines or spaces
222 sub AssociateGroup {
223 my $name=shift;
224 my @vars=@_;
225 my $word;
226
227 foreach $word ( @vars ){
228 chomp $word;
229 next if /^#/;
230 push @groups, $word;
231 }
232 }
233
234 # Split up the Class Block String into a useable array
235 sub _CutBlock {
236 my $string= shift @_;
237 @BlockClassA = split /\//, $string;
238 }
239
240 sub OutToMakefile {
241 my $name=shift;
242 my @vars=@_;
243
244 print GNUmakefile @vars;
245 }
246 sub setBlockClassPath {
247 my $name=shift;
248 my @vars=@_;
249 my $hashref;
250
251 $hashref=$switch->SetupValueHash(\@vars);
252 $switch->checkparam($hashref, $name, 'path');
253 $BlockClassPath=$BlockClassPath.":".$$hashref{path};
254 _CutBlock($$hashref{path});
255 }