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