ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.10
Committed: Fri Mar 26 15:14:37 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.9: +14 -2 lines
Log Message:
Fix binary targets - dependencies not yet working

File Contents

# User Rev Content
1 williamc 1.1 package BuildFile;
2 williamc 1.2 require 5.001;
3 williamc 1.1 require Exporter;
4     @ISA = qw(Exporter);
5     @EXPORT = qw(CheckBuildFile ParseBuildFile @BlockClassA $DefaultBuildFile);
6    
7     BEGIN {
8     use ToolBox;
9     $buildfile="BuildFile";
10 williamc 1.4 $toolbox=ToolBox->new();
11 williamc 1.1 }
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 williamc 1.8 'Bin' => 'none',
33 williamc 1.1 'Bin_StartTag' => \&Bin_start,
34     'ClassPath' => \&OutToMakefile,
35     'ClassPath_StartTag' => \&setBlockClassPath
36     };
37 williamc 1.2 use Utilities::Switcher;
38 williamc 1.1 $switch=Switcher->new($SupportedTags, $fullfilename);
39     $switch->{Strict_no_cr}='no';
40     #open a temporary gnumakefile to store output.
41 williamc 1.2 use Utilities::AddDir;
42 williamc 1.3 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
43 williamc 1.1 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 williamc 1.4 # This stuff for later
112     #$fileclass=$toolbox->getclass($file);
113     #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
114 williamc 1.9 print GNUmakefile "bin:$$hashref{name}\n";
115 williamc 1.10 print GNUmakefile "bin_debug:$$hashref{name}_d\n";
116     print GNUmakefile ".SECONDARY:$$hashref{name}_d.exe ".
117     "$$hashref{name}.exe\n";
118     print GNUmakefile "$$hashref{name}_d.exe:$$hashref{file}\n";
119     print GNUmakefile "$$hashref{name}.exe:$$hashref{file}\n";
120     # print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
121     print GNUmakefile "$$hashref{name}_d:$$hashref{name}_d.exe\n";
122     print GNUmakefile "\t\@mv $$hashref{name}_d.exe \$(binarystore)/".
123     "$$hashref{name}\n";
124     print GNUmakefile "$$hashref{name}:$$hashref{name}.exe\n";
125     print GNUmakefile "\t\@mv $$hashref{name}.exe \$(binarystore)/".
126     "$$hashref{name}\n";
127     print GNUmakefile "files+=$$hashref{file}\n";
128    
129 williamc 1.1 }
130    
131     sub External_StartTag {
132     my $name=shift;
133     my @vars=@_;
134     my $hashref;
135    
136     $hashref=$switch->SetupValueHash(\@vars);
137 williamc 1.6 $$hashref{'ref'}=~tr[A-Z][a-z];
138 williamc 1.1 print GNUmakefile $$hashref{'ref'};
139     if ( defined $$hashref{'version'} ) {
140     print GNUmakefile "_V_".$$hashref{'version'};
141     }
142     print GNUmakefile "=true\n";
143    
144     }
145    
146     sub Group_start {
147     my $name=shift;
148     my @vars=@_;
149     my $hashref;
150    
151     $hashref=$switch->SetupValueHash(\@vars);
152     $switch->checkparam($hashref, $name, 'name');
153     print GNUmakefile "GROUP_".$$hashref{'name'};
154     if ( defined $$hashref{'version'} ) {
155     print GNUmakefile "_V_".$$hashref{'version'};
156     }
157     print GNUmakefile "=true\n";
158     }
159    
160     sub External {
161     my $name=shift;
162     my @vars=@_;
163     # Will simply collect string into a seperate buffer for processind
164     # at the tag closure - used for specifying product defaults
165     # --- Oh oh all of string already in external buffer @!
166     }
167    
168     sub External_EndTag {
169     my $name=shift;
170     my @vars=@_;
171    
172     # process buffer and check consistency with product dtd
173     }
174    
175     sub Use_start {
176     my $name=shift;
177     my @vars=@_;
178     my $hashref;
179     my $filename;
180 williamc 1.2 use Utilities::SCRAMUtils;
181 williamc 1.1
182     $hashref=$switch->SetupValueHash(\@vars);
183     $switch->checkparam($hashref, $name, "name");
184     if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile")
185     ne "" ) {
186     print GNUmakefile "ReqDependencies += $filename\n";
187     }
188     print GNUmakefile "local__$$hashref{name}=true\n";
189     }
190    
191 williamc 1.5 sub CheckBuildFile {
192 williamc 1.1 my $classdir=shift;
193     $ClassName="";
194     $thisfile="$classdir/$buildfile";
195    
196     if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
197     $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
198     ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
199     }
200     elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
201     $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
202     ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
203     }
204     return $ClassName;
205     }
206    
207     # List association groups between <AssociateGroup> tags
208     # seperated by newlines or spaces
209     sub AssociateGroup {
210     my $name=shift;
211     my @vars=@_;
212     my $word;
213    
214     foreach $word ( @vars ){
215     chomp $word;
216     next if /^#/;
217     push @groups, $word;
218     }
219     }
220    
221     # Split up the Class Block String into a useable array
222 williamc 1.5 sub _CutBlock {
223 williamc 1.1 my $string= shift @_;
224     @BlockClassA = split /\//, $string;
225     }
226    
227     sub OutToMakefile {
228     my $name=shift;
229     my @vars=@_;
230    
231     print GNUmakefile @vars;
232     }
233     sub setBlockClassPath {
234     my $name=shift;
235     my @vars=@_;
236     my $hashref;
237    
238     $hashref=$switch->SetupValueHash(\@vars);
239     $switch->checkparam($hashref, $name, 'path');
240     $BlockClassPath=$BlockClassPath.":".$$hashref{path};
241     _CutBlock($$hashref{path});
242     }