ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.1
Committed: Mon Mar 1 10:37:52 1999 UTC (26 years, 2 months ago) by williamc
Content type: text/plain
Branch: MAIN
Log Message:
Initial setup

File Contents

# Content
1 #!/usr/local/bin/perl5
2 #
3
4 package BuildFile;
5 require Exporter;
6 @ISA = qw(Exporter);
7 @EXPORT = qw(CheckBuildFile ParseBuildFile @BlockClassA $DefaultBuildFile);
8
9 BEGIN {
10 use ToolBox;
11 $buildfile="BuildFile";
12 #$toolbox=ToolBox->new();
13 }
14
15 #Parse the BuildFile
16 sub ParseBuildFile {
17 my $base=shift;
18 my $path=shift;
19 my $filename=shift @_;
20 my $fullfilename="$base/$path/$filename";
21 #print "Processing $fullfilename\n";
22 # This hash defines which Document Elements we can use
23 my $SupportedTags={
24 'Use' => \&OutToMakefile,
25 'Use_StartTag' => \&Use_start,
26 'Group' => \&OutToMakefile,
27 'Group_StartTag' => \&Group_start,
28 'External' => \&OutToMakefile,
29 'External_StartTag' => \&External_StartTag,
30 'ConfigurationClass_StartTag' => \&Class_StartTag,
31 'ConfigurationClass' => \&OutToMakefile,
32 'AssociateGroup' => \&AssociateGroup,
33 'none' => \&OutToMakefile,
34 'Bin' => \&OutToMakefile,
35 'Bin_StartTag' => \&Bin_start,
36 'ClassPath' => \&OutToMakefile,
37 'ClassPath_StartTag' => \&setBlockClassPath
38 };
39 use Switcher;
40 $switch=Switcher->new($SupportedTags, $fullfilename);
41 $switch->{Strict_no_cr}='no';
42 #open a temporary gnumakefile to store output.
43 use AddDir;
44 adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
45 open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
46 if ( -e $ENV{LatestBuildFile} ) {
47 print GNUmakefile "include $ENV{LatestBuildFile}\n";
48 }
49 # print "writing to :\n".
50 # "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
51 $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
52 $switch->parse(); # sort out supported tags
53 close GNUmakefile;
54 }
55
56 sub initialterms() {
57 my $name=shift;
58 my @string=@_;
59
60 $_=join "", @string;
61 chomp;
62 SWITCH: {
63 last SWITCH if /^#/;
64 if ( /^.*BlockClassPath.*/i ) {
65 s/^.*BlockClassPath *= *//;
66 _CutBlock($_);
67 last SWITCH;
68 }
69 } # end SWITCH
70 }
71
72 # Tag routines - called by the Switcher when tag found
73
74
75
76 #-- Override a class type with the <ConfigurationClass type=xxx> tag
77 # the type tag will pick up a pre-defined class type from project space.
78
79 sub Class_StartTag {
80 my $name=shift;
81 my $hashref;
82 my @vars=@_;
83
84 $hashref=$switch->SetupValueHash(\@vars);
85 if ( defined $$hashref{'type'} ) {
86 $ClassName=$$hashref{'type'};
87 }
88 }
89
90 sub ClassPath_StartTag {
91 my $name=shift;
92 my @vars=@_;
93 my $hashref;
94
95 $hashref=$switch->SetupValueHash(\@vars);
96 if ( defined $$hashref{'defaultpath'} ) {
97 }
98 }
99
100 sub Bin_start {
101 my $name=shift;
102 my @vars=@_;
103 my $hashref;
104 my $fileclass;
105 my @tools;
106 my $tool;
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 $fileclass=getclass($file);
114 $toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
115 print GNUmakefile "bin::$file\n\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 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($directory) {
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($string) {
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 }