ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.18
Committed: Thu Apr 1 17:28:45 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_6
Changes since 1.17: +6 -6 lines
Log Message:
Correct debug files

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