ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.12
Committed: Fri Mar 26 18:10:36 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_5, V0_4, V0_3
Changes since 1.11: +12 -5 lines
Log Message:
Binary Dependencies now work

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