ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.20
Committed: Thu Apr 8 12:55:49 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_8
Changes since 1.19: +3 -1 lines
Log Message:
Fix clean targets and make bin name default to the debug version

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