ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.2
Committed: Mon Mar 1 11:01:41 1999 UTC (26 years, 2 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.1: +4 -6 lines
Log Message:
get rid of unessary shell invocation stuff in modules

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