ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.8
Committed: Tue Mar 23 08:42:09 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.7: +1 -1 lines
Log Message:
do not export bin documentation to GNUmakefile

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