8 |
|
use ToolBox; |
9 |
|
$buildfile="BuildFile"; |
10 |
|
$toolbox=ToolBox->new(); |
11 |
+ |
$Arch=1; |
12 |
+ |
push @ARCHBLOCK, $Arch; |
13 |
|
} |
14 |
|
|
15 |
|
#Parse the BuildFile |
31 |
|
'ConfigurationClass' => \&OutToMakefile, |
32 |
|
'AssociateGroup' => \&AssociateGroup, |
33 |
|
'none' => \&OutToMakefile, |
34 |
< |
'Bin' => \&OutToMakefile, |
34 |
> |
'Bin' => 'none', |
35 |
|
'Bin_StartTag' => \&Bin_start, |
36 |
|
'ClassPath' => \&OutToMakefile, |
37 |
< |
'ClassPath_StartTag' => \&setBlockClassPath |
37 |
> |
'ClassPath_StartTag' => \&setBlockClassPath, |
38 |
> |
'lib' => 'none', |
39 |
> |
'lib_StartTag' => \&lib_start, |
40 |
> |
'lib_EndTag' => 'none', |
41 |
> |
'ignore' => 'none', |
42 |
> |
'ignore_EndTag' => \&ignoretag_end, |
43 |
> |
'ignore_StartTag' => \&ignoretag, |
44 |
> |
'Architecture_StartTag' => \&Arch_Start, |
45 |
> |
'Architecture_EndTag' => \&Arch_End, |
46 |
> |
'Architecture' => \&OutToMakefile, |
47 |
> |
'LibType_StartTag' => \&LibType_Start, |
48 |
> |
'LibType_EndTag' => 'none', |
49 |
> |
#'LibType' => \&OutToScreen |
50 |
> |
'LibType' => \&LibType_text |
51 |
|
}; |
52 |
|
use Utilities::Switcher; |
53 |
|
$switch=Switcher->new($SupportedTags, $fullfilename); |
66 |
|
close GNUmakefile; |
67 |
|
} |
68 |
|
|
69 |
+ |
sub ParseBuildFile_Export { |
70 |
+ |
my $filename=shift; |
71 |
+ |
use Tool; |
72 |
+ |
# This hash defines which Document Elements we can use |
73 |
+ |
my $SupportedTags={ |
74 |
+ |
'none' => 'none', |
75 |
+ |
'export' => \&OutToMakefile, |
76 |
+ |
'export_StartTag' => \&export_start, |
77 |
+ |
'export_EndTag' => \&export_end, |
78 |
+ |
'lib_StartTag' => \&lib_start_export, |
79 |
+ |
'External_StartTag' => \&Ext_start_export, |
80 |
+ |
'lib' => 'none' |
81 |
+ |
}; |
82 |
+ |
use Utilities::Switcher; |
83 |
+ |
$switchex=Switcher->new($SupportedTags, $filename); |
84 |
+ |
$switchex->{Strict_no_cr}='no'; |
85 |
+ |
$switchex->parse(); # sort out supported tags |
86 |
+ |
} |
87 |
+ |
|
88 |
|
sub initialterms() { |
89 |
|
my $name=shift; |
90 |
|
my @string=@_; |
114 |
|
my @vars=@_; |
115 |
|
|
116 |
|
$hashref=$switch->SetupValueHash(\@vars); |
117 |
+ |
if ( $Arch ) { |
118 |
|
if ( defined $$hashref{'type'} ) { |
119 |
|
$ClassName=$$hashref{'type'}; |
120 |
|
} |
121 |
+ |
} |
122 |
|
} |
123 |
|
|
124 |
|
sub ClassPath_StartTag { |
127 |
|
my $hashref; |
128 |
|
|
129 |
|
$hashref=$switch->SetupValueHash(\@vars); |
130 |
+ |
if ( $Arch ) { |
131 |
|
if ( defined $$hashref{'defaultpath'} ) { |
132 |
|
} |
133 |
+ |
} |
134 |
|
} |
135 |
|
|
136 |
|
sub Bin_start { |
140 |
|
my $fileclass; |
141 |
|
my @tools; |
142 |
|
my $tool; |
143 |
+ |
my $filename; |
144 |
+ |
my $objectname; |
145 |
|
|
146 |
|
$hashref=$switch->SetupValueHash(\@vars); |
147 |
|
$switch->checkparam($hashref, $name, 'file'); |
148 |
+ |
if ( $Arch ) { |
149 |
|
if ( ! defined $$hashref{name} ) { |
150 |
|
($$hashref{name}=$$hashref{file})=~s/\..*//; |
151 |
|
} |
152 |
|
# This stuff for later |
153 |
|
#$fileclass=$toolbox->getclass($file); |
154 |
|
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file ); |
155 |
< |
print GNUmakefile "bin::$$hashref{name}\n"; |
156 |
< |
print GNUmakefile "bin_debug::$$hashref{name}\n"; |
157 |
< |
print GNUmakefile "$$hashref{name}::$$hashref{file}\n"; |
155 |
> |
($filename=$$hashref{file})=~s/\..*//; |
156 |
> |
($objectname=$$hashref{file})=~s/\..*/\.o/; |
157 |
> |
($objectname_d=$$hashref{file})=~s/\..*/_d\.o/; |
158 |
> |
($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/; |
159 |
> |
print GNUmakefile "bin:$$hashref{name}_o\n"; |
160 |
> |
print GNUmakefile "bin_debug:$$hashref{name}_d\n"; |
161 |
> |
print GNUmakefile "bin_debug_local:$$hashref{name}_d_l\n"; |
162 |
> |
print GNUmakefile "bin_insure:$$hashref{name}_Insure\n"; |
163 |
> |
# print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n"; |
164 |
> |
# print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n"; |
165 |
> |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n"; |
166 |
> |
print GNUmakefile "$$hashref{name}_Insure:.psrc\n"; |
167 |
> |
print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
168 |
> |
print GNUmakefile "\t\$(CClinkCmdDebug)\n"; |
169 |
> |
print GNUmakefile "$$hashref{name}_d_l.exe:$objectname_d\n"; |
170 |
> |
print GNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
171 |
> |
print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
172 |
> |
print GNUmakefile "\t\$(CClinkCmdInsure)\n"; |
173 |
> |
print GNUmakefile "$$hashref{name}.exe:$objectname\n"; |
174 |
> |
print GNUmakefile "\t\$(CClinkCmd)\n"; |
175 |
> |
print GNUmakefile "$objectname:$$hashref{name}.dep\n"; |
176 |
> |
print GNUmakefile "$objectname_d:$$hashref{name}.dep\n"; |
177 |
> |
print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n"; |
178 |
> |
print GNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
179 |
> |
print GNUmakefile "-include $$hashref{name}.dep\n"; |
180 |
> |
# print GNUmakefile "$$hashref{name}:$$hashref{file}\n"; |
181 |
> |
print GNUmakefile <<ENDTEXT; |
182 |
> |
$$hashref{name}_d.exe:\$(libslocal_d) |
183 |
> |
$$hashref{name}.exe:\$(libslocal) |
184 |
> |
ifdef MCCABE_DATA_DIR |
185 |
> |
$$hashref{name}_mccabe.exe: \$(libslocal_d) $(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp |
186 |
> |
endif |
187 |
> |
$$hashref{name}_Insure.exe:\$(libslocal_I) |
188 |
> |
$$hashref{name}_d:$$hashref{name}_d.exe |
189 |
> |
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
190 |
> |
$$hashref{name}_d_l:$$hashref{name}_d_l.exe |
191 |
> |
\@cp $$hashref{name}_d_l.exe \$(binarystore)/$$hashref{name} |
192 |
> |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe |
193 |
> |
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
194 |
> |
$$hashref{name}:$$hashref{name}_d.exe |
195 |
> |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
196 |
> |
$$hashref{name}_o:$$hashref{name}.exe |
197 |
> |
\@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name} |
198 |
> |
binfiles+=$$hashref{file} |
199 |
> |
bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure |
200 |
> |
ENDTEXT |
201 |
> |
} |
202 |
> |
} |
203 |
> |
|
204 |
> |
sub Ext_start_export { |
205 |
> |
my $name=shift; |
206 |
> |
my @vars=@_; |
207 |
> |
my $hashref; |
208 |
> |
|
209 |
> |
$hashref=$switch->SetupValueHash(\@vars); |
210 |
> |
if ( $Arch ) { |
211 |
> |
if ( $switchex->context('export') ) { |
212 |
> |
$$hashref{'ref'}=~tr[A-Z][a-z]; |
213 |
> |
print GNUmakefile $$hashref{'ref'}; |
214 |
> |
if ( defined $$hashref{'version'} ) { |
215 |
> |
print GNUmakefile "_V_".$$hashref{'version'}; |
216 |
> |
} |
217 |
> |
print GNUmakefile "=true\n"; |
218 |
> |
} |
219 |
> |
} |
220 |
|
} |
221 |
|
|
222 |
|
sub External_StartTag { |
225 |
|
my $hashref; |
226 |
|
|
227 |
|
$hashref=$switch->SetupValueHash(\@vars); |
228 |
+ |
if ( $Arch ) { |
229 |
|
$$hashref{'ref'}=~tr[A-Z][a-z]; |
230 |
|
print GNUmakefile $$hashref{'ref'}; |
231 |
|
if ( defined $$hashref{'version'} ) { |
232 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
233 |
|
} |
234 |
|
print GNUmakefile "=true\n"; |
235 |
+ |
} |
236 |
|
|
237 |
|
} |
238 |
|
|
243 |
|
|
244 |
|
$hashref=$switch->SetupValueHash(\@vars); |
245 |
|
$switch->checkparam($hashref, $name, 'name'); |
246 |
+ |
if ( $Arch ) { |
247 |
|
print GNUmakefile "GROUP_".$$hashref{'name'}; |
248 |
|
if ( defined $$hashref{'version'} ) { |
249 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
250 |
|
} |
251 |
|
print GNUmakefile "=true\n"; |
252 |
+ |
} |
253 |
|
} |
254 |
|
|
255 |
|
sub External { |
276 |
|
|
277 |
|
$hashref=$switch->SetupValueHash(\@vars); |
278 |
|
$switch->checkparam($hashref, $name, "name"); |
279 |
< |
if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile") |
280 |
< |
ne "" ) { |
281 |
< |
print GNUmakefile "ReqDependencies += $filename\n"; |
279 |
> |
if ( $Arch ) { |
280 |
> |
$filename=SCRAMUtils::checkfile( |
281 |
> |
"$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
282 |
> |
if ( $filename ne "" ) { |
283 |
> |
ParseBuildFile_Export( $filename ); |
284 |
> |
} |
285 |
|
} |
176 |
– |
print GNUmakefile "local__$$hashref{name}=true\n"; |
286 |
|
} |
287 |
|
|
288 |
|
sub CheckBuildFile { |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
+ |
sub ignoretag { |
319 |
+ |
my $name=shift; |
320 |
+ |
my @vars=@_; |
321 |
+ |
|
322 |
+ |
$Arch=0; |
323 |
+ |
push @ARCHBLOCK, $Arch; |
324 |
+ |
} |
325 |
+ |
|
326 |
+ |
sub ignoretag_end { |
327 |
+ |
my $name=shift; |
328 |
+ |
my @vars=@_; |
329 |
+ |
|
330 |
+ |
pop @ARCHBLOCK; |
331 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
332 |
+ |
} |
333 |
+ |
|
334 |
+ |
sub Arch_Start { |
335 |
+ |
my $name=shift; |
336 |
+ |
my @vars=@_; |
337 |
+ |
my $hashref; |
338 |
+ |
|
339 |
+ |
$hashref=$toolswitch->SetupValueHash( \@vars ); |
340 |
+ |
$toolswitch->checkparam($hashref, $name, 'name'); |
341 |
+ |
#( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0; |
342 |
+ |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0); |
343 |
+ |
push @ARCHBLOCK, $Arch; |
344 |
+ |
} |
345 |
+ |
sub Arch_End { |
346 |
+ |
my $name=shift; |
347 |
+ |
my @vars=@_; |
348 |
+ |
|
349 |
+ |
pop @ARCHBLOCK; |
350 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
351 |
+ |
} |
352 |
+ |
|
353 |
|
# Split up the Class Block String into a useable array |
354 |
|
sub _CutBlock { |
355 |
|
my $string= shift @_; |
360 |
|
my $name=shift; |
361 |
|
my @vars=@_; |
362 |
|
|
363 |
< |
print GNUmakefile @vars; |
363 |
> |
if ( $Arch ) { |
364 |
> |
print GNUmakefile @vars; |
365 |
> |
} |
366 |
> |
} |
367 |
> |
sub OutToScreen { |
368 |
> |
my $name=shift; |
369 |
> |
my @vars=@_; |
370 |
> |
|
371 |
> |
if ( $Arch ) { |
372 |
> |
print @vars; |
373 |
> |
} |
374 |
|
} |
375 |
|
sub setBlockClassPath { |
376 |
|
my $name=shift; |
382 |
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path}; |
383 |
|
_CutBlock($$hashref{path}); |
384 |
|
} |
385 |
+ |
|
386 |
+ |
sub export_start { |
387 |
+ |
#Set up a toolfile object |
388 |
+ |
$exporttool=Tool->new(); |
389 |
+ |
} |
390 |
+ |
|
391 |
+ |
sub export_end { |
392 |
+ |
#Write toolfile object to disk |
393 |
+ |
$exporttool->envtomake(\*GNUmakefile); |
394 |
+ |
} |
395 |
+ |
|
396 |
+ |
# |
397 |
+ |
# Export Mode Lib Tag |
398 |
+ |
# |
399 |
+ |
sub lib_start_export { |
400 |
+ |
my $name=shift; |
401 |
+ |
my @vars=@_; |
402 |
+ |
my $hashref; |
403 |
+ |
|
404 |
+ |
$hashref=$switchex->SetupValueHash( \@vars ); |
405 |
+ |
$switchex->checkparam($hashref, $name, 'name'); |
406 |
+ |
if ( $Arch ) { |
407 |
+ |
if ( $switchex->context('export') ) { |
408 |
+ |
#If export mode then add this env to the export tool |
409 |
+ |
$exporttool->addenv('lib',$$hashref{name}); |
410 |
+ |
} |
411 |
+ |
} |
412 |
+ |
} |
413 |
+ |
|
414 |
+ |
# |
415 |
+ |
# Standard lib tag |
416 |
+ |
# |
417 |
+ |
sub lib_start { |
418 |
+ |
my $name=shift; |
419 |
+ |
my @vars=@_; |
420 |
+ |
my $hashref; |
421 |
+ |
|
422 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
423 |
+ |
$switch->checkparam($hashref, $name, 'name'); |
424 |
+ |
if ( $Arch ) { |
425 |
+ |
print GNUmakefile "lib+=$$hashref{name}\n"; |
426 |
+ |
} |
427 |
+ |
} |
428 |
+ |
|
429 |
+ |
# |
430 |
+ |
# libtype specification |
431 |
+ |
# |
432 |
+ |
sub LibType_Start { |
433 |
+ |
my $name=shift; |
434 |
+ |
my @vars=@_; |
435 |
+ |
my $hashref; |
436 |
+ |
|
437 |
+ |
if ( $Arch ) { |
438 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
439 |
+ |
$switch->checkparam($hashref, $name, 'type'); |
440 |
+ |
|
441 |
+ |
print GNUmakefile "# Specify Library Type\n"; |
442 |
+ |
print GNUmakefile "DefaultLibsOff=yes\n"; |
443 |
+ |
if ( $$hashref{'type'}=~/^archive/i ) { |
444 |
+ |
print GNUmakefile "LibArchive=true\n"; |
445 |
+ |
} |
446 |
+ |
elsif ($$hashref{'type'}=~/debug_archive/i ) { |
447 |
+ |
print GNUmakefile "LibDebugArchive=true\n"; |
448 |
+ |
} |
449 |
+ |
elsif ($$hashref{'type'}=~/debug_shared/i ) { |
450 |
+ |
print GNUmakefile "LibDebugShared=true\n"; |
451 |
+ |
} |
452 |
+ |
elsif ($$hashref{'type'}=~/shared/i ) { |
453 |
+ |
print GNUmakefile 'LibShared=true'."\n"; |
454 |
+ |
} |
455 |
+ |
print GNUmakefile "\n"; |
456 |
+ |
} |
457 |
+ |
} |
458 |
+ |
sub LibType_text { |
459 |
+ |
my $name=shift; |
460 |
+ |
my @vars=@_; |
461 |
+ |
|
462 |
+ |
if ( $Arch ) { |
463 |
+ |
print GNUmakefile "libmsg::\n\t\@echo Library info: "; |
464 |
+ |
print GNUmakefile @vars; |
465 |
+ |
print GNUmakefile "\n"; |
466 |
+ |
} |
467 |
+ |
} |
468 |
+ |
|