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 |
|
|
|
8 |
|
|
#Parse the BuildFile
|
9 |
|
|
sub ParseBuildFile {
|
10 |
|
|
my $base=shift;
|
11 |
|
|
my $path=shift;
|
12 |
|
|
my $filename=shift @_;
|
13 |
|
|
my $fullfilename="$base/$path/$filename";
|
14 |
|
|
#print "Processing $fullfilename\n";
|
15 |
|
|
# This hash defines which Document Elements we can use
|
16 |
|
|
my $SupportedTags={
|
17 |
|
|
'Use' => \&OutToMakefile,
|
18 |
|
|
'Use_StartTag' => \&Use_start,
|
19 |
|
|
'Group' => \&OutToMakefile,
|
20 |
|
|
'Group_StartTag' => \&Group_start,
|
21 |
|
|
'External' => \&OutToMakefile,
|
22 |
|
|
'External_StartTag' => \&External_StartTag,
|
23 |
|
|
'ConfigurationClass_StartTag' => \&Class_StartTag,
|
24 |
|
|
'ConfigurationClass' => \&OutToMakefile,
|
25 |
|
|
'AssociateGroup' => \&AssociateGroup,
|
26 |
|
|
'none' => \&OutToMakefile,
|
27 |
williamc |
1.8 |
'Bin' => 'none',
|
28 |
williamc |
1.1 |
'Bin_StartTag' => \&Bin_start,
|
29 |
|
|
'ClassPath' => \&OutToMakefile,
|
30 |
williamc |
1.21 |
'ClassPath_StartTag' => \&setBlockClassPath,
|
31 |
|
|
'lib' => 'none',
|
32 |
|
|
'lib_StartTag' => \&lib_start,
|
33 |
|
|
'lib_EndTag' => 'none'
|
34 |
williamc |
1.1 |
};
|
35 |
williamc |
1.23 |
use ActiveDoc::Switcher;
|
36 |
williamc |
1.1 |
$switch=Switcher->new($SupportedTags, $fullfilename);
|
37 |
|
|
$switch->{Strict_no_cr}='no';
|
38 |
|
|
#open a temporary gnumakefile to store output.
|
39 |
williamc |
1.2 |
use Utilities::AddDir;
|
40 |
williamc |
1.3 |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
|
41 |
williamc |
1.1 |
open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
|
42 |
|
|
if ( -e $ENV{LatestBuildFile} ) {
|
43 |
|
|
print GNUmakefile "include $ENV{LatestBuildFile}\n";
|
44 |
|
|
}
|
45 |
|
|
# print "writing to :\n".
|
46 |
|
|
# "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
|
47 |
|
|
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
|
48 |
|
|
$switch->parse(); # sort out supported tags
|
49 |
|
|
close GNUmakefile;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
williamc |
1.21 |
sub ParseBuildFile_Export {
|
53 |
|
|
my $filename=shift;
|
54 |
williamc |
1.23 |
#use Tool;
|
55 |
williamc |
1.21 |
# This hash defines which Document Elements we can use
|
56 |
|
|
my $SupportedTags={
|
57 |
williamc |
1.22 |
'Use' => \&OutToMakefile,
|
58 |
|
|
'Use_StartTag' => \&Use_start,
|
59 |
|
|
'External' => \&OutToMakefile,
|
60 |
|
|
'External_StartTag' => \&External_StartTag,
|
61 |
williamc |
1.21 |
'none' => 'none',
|
62 |
|
|
'export' => \&OutToMakefile,
|
63 |
|
|
'export_StartTag' => \&export_start,
|
64 |
|
|
'export_EndTag' => \&export_end,
|
65 |
|
|
'lib_StartTag' => \&lib_start_export,
|
66 |
|
|
'lib' => 'none'
|
67 |
|
|
};
|
68 |
williamc |
1.23 |
use ActiveDoc::Switcher;
|
69 |
williamc |
1.21 |
$switchex=Switcher->new($SupportedTags, $filename);
|
70 |
|
|
$switchex->{Strict_no_cr}='no';
|
71 |
williamc |
1.22 |
push @switchstack, $switchex;
|
72 |
williamc |
1.21 |
$switchex->parse(); # sort out supported tags
|
73 |
williamc |
1.22 |
pop @switchstack;
|
74 |
|
|
$switchex=$switchstack[$#switchstack]; # Make sure we can Use multiply
|
75 |
williamc |
1.21 |
}
|
76 |
|
|
|
77 |
williamc |
1.1 |
sub initialterms() {
|
78 |
|
|
my $name=shift;
|
79 |
|
|
my @string=@_;
|
80 |
|
|
|
81 |
|
|
$_=join "", @string;
|
82 |
|
|
chomp;
|
83 |
|
|
SWITCH: {
|
84 |
|
|
last SWITCH if /^#/;
|
85 |
|
|
if ( /^.*BlockClassPath.*/i ) {
|
86 |
|
|
s/^.*BlockClassPath *= *//;
|
87 |
|
|
_CutBlock($_);
|
88 |
|
|
last SWITCH;
|
89 |
|
|
}
|
90 |
|
|
} # end SWITCH
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
# Tag routines - called by the Switcher when tag found
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
#-- Override a class type with the <ConfigurationClass type=xxx> tag
|
98 |
|
|
# the type tag will pick up a pre-defined class type from project space.
|
99 |
|
|
|
100 |
|
|
sub Class_StartTag {
|
101 |
|
|
my $name=shift;
|
102 |
|
|
my $hashref;
|
103 |
|
|
my @vars=@_;
|
104 |
|
|
|
105 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
106 |
|
|
if ( defined $$hashref{'type'} ) {
|
107 |
|
|
$ClassName=$$hashref{'type'};
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
sub ClassPath_StartTag {
|
112 |
|
|
my $name=shift;
|
113 |
|
|
my @vars=@_;
|
114 |
|
|
my $hashref;
|
115 |
|
|
|
116 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
117 |
|
|
if ( defined $$hashref{'defaultpath'} ) {
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
sub Bin_start {
|
122 |
|
|
my $name=shift;
|
123 |
|
|
my @vars=@_;
|
124 |
|
|
my $hashref;
|
125 |
|
|
my $fileclass;
|
126 |
|
|
my @tools;
|
127 |
|
|
my $tool;
|
128 |
williamc |
1.12 |
my $filename;
|
129 |
|
|
my $objectname;
|
130 |
williamc |
1.1 |
|
131 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
132 |
|
|
$switch->checkparam($hashref, $name, 'file');
|
133 |
|
|
if ( ! defined $$hashref{name} ) {
|
134 |
|
|
($$hashref{name}=$$hashref{file})=~s/\..*//;
|
135 |
|
|
}
|
136 |
williamc |
1.4 |
# This stuff for later
|
137 |
|
|
#$fileclass=$toolbox->getclass($file);
|
138 |
|
|
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
|
139 |
williamc |
1.12 |
($filename=$$hashref{file})=~s/\..*//;
|
140 |
|
|
($objectname=$$hashref{file})=~s/\..*/\.o/;
|
141 |
|
|
($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
|
142 |
williamc |
1.14 |
($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/;
|
143 |
williamc |
1.9 |
print GNUmakefile "bin:$$hashref{name}\n";
|
144 |
williamc |
1.10 |
print GNUmakefile "bin_debug:$$hashref{name}_d\n";
|
145 |
williamc |
1.13 |
print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
|
146 |
williamc |
1.12 |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
|
147 |
williamc |
1.13 |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
|
148 |
williamc |
1.12 |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
|
149 |
williamc |
1.14 |
print GNUmakefile "$$hashref{name}_Insure:.psrc\n";
|
150 |
williamc |
1.12 |
print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
|
151 |
williamc |
1.16 |
print GNUmakefile "\t\$(CClinkCmdDebug)\n";
|
152 |
williamc |
1.13 |
print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
|
153 |
williamc |
1.16 |
print GNUmakefile "\t\$(CClinkCmdInsure)\n";
|
154 |
williamc |
1.12 |
print GNUmakefile "$$hashref{name}.exe:$objectname\n";
|
155 |
williamc |
1.16 |
print GNUmakefile "\t\$(CClinkCmd)\n";
|
156 |
williamc |
1.15 |
print GNUmakefile "$objectname:$$hashref{name}.dep\n";
|
157 |
|
|
print GNUmakefile "$objectname_d:$$hashref{name}.dep\n";
|
158 |
|
|
print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n";
|
159 |
|
|
print GNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
|
160 |
|
|
print GNUmakefile "-include $$hashref{name}.dep\n";
|
161 |
williamc |
1.10 |
# print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
|
162 |
williamc |
1.17 |
print GNUmakefile <<ENDTEXT;
|
163 |
williamc |
1.19 |
$$hashref{name}_d.exe:\$(libslocal_d)
|
164 |
|
|
$$hashref{name}.exe:\$(libslocal)
|
165 |
|
|
$$hashref{name}_Insure.exe:\$(libslocal_I)
|
166 |
williamc |
1.17 |
$$hashref{name}_d:$$hashref{name}_d.exe
|
167 |
williamc |
1.18 |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
|
168 |
williamc |
1.17 |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe
|
169 |
williamc |
1.18 |
\@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
|
170 |
williamc |
1.20 |
$$hashref{name}:$$hashref{name}_d.exe
|
171 |
|
|
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
|
172 |
|
|
$$hashref{name}_o:$$hashref{name}_o.exe
|
173 |
williamc |
1.18 |
\@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name}
|
174 |
williamc |
1.17 |
binfiles+=$filename
|
175 |
|
|
bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure
|
176 |
|
|
ENDTEXT
|
177 |
williamc |
1.1 |
}
|
178 |
|
|
|
179 |
|
|
sub External_StartTag {
|
180 |
|
|
my $name=shift;
|
181 |
|
|
my @vars=@_;
|
182 |
|
|
my $hashref;
|
183 |
|
|
|
184 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
185 |
williamc |
1.21 |
if ( $Arch ) {
|
186 |
williamc |
1.6 |
$$hashref{'ref'}=~tr[A-Z][a-z];
|
187 |
williamc |
1.1 |
print GNUmakefile $$hashref{'ref'};
|
188 |
|
|
if ( defined $$hashref{'version'} ) {
|
189 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
190 |
|
|
}
|
191 |
|
|
print GNUmakefile "=true\n";
|
192 |
williamc |
1.21 |
}
|
193 |
williamc |
1.1 |
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
sub Group_start {
|
197 |
|
|
my $name=shift;
|
198 |
|
|
my @vars=@_;
|
199 |
|
|
my $hashref;
|
200 |
|
|
|
201 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
202 |
|
|
$switch->checkparam($hashref, $name, 'name');
|
203 |
|
|
print GNUmakefile "GROUP_".$$hashref{'name'};
|
204 |
|
|
if ( defined $$hashref{'version'} ) {
|
205 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
206 |
|
|
}
|
207 |
|
|
print GNUmakefile "=true\n";
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
sub External {
|
211 |
|
|
my $name=shift;
|
212 |
|
|
my @vars=@_;
|
213 |
|
|
# Will simply collect string into a seperate buffer for processind
|
214 |
|
|
# at the tag closure - used for specifying product defaults
|
215 |
|
|
# --- Oh oh all of string already in external buffer @!
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
sub External_EndTag {
|
219 |
|
|
my $name=shift;
|
220 |
|
|
my @vars=@_;
|
221 |
|
|
|
222 |
|
|
# process buffer and check consistency with product dtd
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
sub Use_start {
|
226 |
|
|
my $name=shift;
|
227 |
|
|
my @vars=@_;
|
228 |
|
|
my $hashref;
|
229 |
|
|
my $filename;
|
230 |
williamc |
1.2 |
use Utilities::SCRAMUtils;
|
231 |
williamc |
1.1 |
|
232 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
233 |
|
|
$switch->checkparam($hashref, $name, "name");
|
234 |
williamc |
1.21 |
$filename=SCRAMUtils::checkfile(
|
235 |
|
|
"$ENV{INTsrc}/$$hashref{name}/BuildFile");
|
236 |
|
|
if ( $filename ne "" ) {
|
237 |
|
|
ParseBuildFile_Export( $filename );
|
238 |
williamc |
1.1 |
}
|
239 |
|
|
}
|
240 |
|
|
|
241 |
williamc |
1.5 |
sub CheckBuildFile {
|
242 |
williamc |
1.1 |
my $classdir=shift;
|
243 |
|
|
$ClassName="";
|
244 |
|
|
$thisfile="$classdir/$buildfile";
|
245 |
|
|
|
246 |
|
|
if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
|
247 |
|
|
$DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
|
248 |
|
|
ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
|
249 |
|
|
}
|
250 |
|
|
elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
|
251 |
|
|
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
|
252 |
|
|
ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
|
253 |
|
|
}
|
254 |
|
|
return $ClassName;
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
# List association groups between <AssociateGroup> tags
|
258 |
|
|
# seperated by newlines or spaces
|
259 |
|
|
sub AssociateGroup {
|
260 |
|
|
my $name=shift;
|
261 |
|
|
my @vars=@_;
|
262 |
|
|
my $word;
|
263 |
|
|
|
264 |
|
|
foreach $word ( @vars ){
|
265 |
|
|
chomp $word;
|
266 |
|
|
next if /^#/;
|
267 |
|
|
push @groups, $word;
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
# Split up the Class Block String into a useable array
|
272 |
williamc |
1.5 |
sub _CutBlock {
|
273 |
williamc |
1.1 |
my $string= shift @_;
|
274 |
|
|
@BlockClassA = split /\//, $string;
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
sub OutToMakefile {
|
278 |
|
|
my $name=shift;
|
279 |
|
|
my @vars=@_;
|
280 |
|
|
|
281 |
|
|
print GNUmakefile @vars;
|
282 |
|
|
}
|
283 |
|
|
sub setBlockClassPath {
|
284 |
|
|
my $name=shift;
|
285 |
|
|
my @vars=@_;
|
286 |
|
|
my $hashref;
|
287 |
|
|
|
288 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
289 |
|
|
$switch->checkparam($hashref, $name, 'path');
|
290 |
|
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path};
|
291 |
|
|
_CutBlock($$hashref{path});
|
292 |
williamc |
1.21 |
}
|
293 |
|
|
|
294 |
|
|
sub export_start {
|
295 |
|
|
#Set up a toolfile object
|
296 |
williamc |
1.23 |
# $exporttool=Tool->new();
|
297 |
williamc |
1.21 |
}
|
298 |
|
|
|
299 |
|
|
sub export_end {
|
300 |
|
|
#Write toolfile object to disk
|
301 |
|
|
$exporttool->envtomake(\*GNUmakefile);
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
#
|
305 |
|
|
# Export Mode Lib Tag
|
306 |
|
|
#
|
307 |
|
|
sub lib_start_export {
|
308 |
|
|
my $name=shift;
|
309 |
|
|
my @vars=@_;
|
310 |
|
|
my $hashref;
|
311 |
|
|
|
312 |
|
|
$hashref=$switchex->SetupValueHash( \@vars );
|
313 |
|
|
$switchex->checkparam($hashref, $name, 'name');
|
314 |
|
|
if ( $Arch ) {
|
315 |
|
|
if ( $switchex->context('export') ) {
|
316 |
|
|
#If export mode then add this env to the export tool
|
317 |
|
|
$exporttool->addenv('lib',$$hashref{name});
|
318 |
|
|
}
|
319 |
|
|
}
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
#
|
323 |
|
|
# Standard lib tag
|
324 |
|
|
#
|
325 |
|
|
sub lib_start {
|
326 |
|
|
my $name=shift;
|
327 |
|
|
my @vars=@_;
|
328 |
|
|
my $hashref;
|
329 |
|
|
|
330 |
|
|
$hashref=$switch->SetupValueHash( \@vars );
|
331 |
|
|
$switch->checkparam($hashref, $name, 'name');
|
332 |
|
|
if ( $Arch ) {
|
333 |
|
|
print GNUmakefile "lib+=$$hashref{name}\n";
|
334 |
|
|
}
|
335 |
williamc |
1.1 |
}
|