8 |
|
use ToolBox; |
9 |
|
$buildfile="BuildFile"; |
10 |
|
$toolbox=ToolBox->new(); |
11 |
+ |
$Arch=1; |
12 |
+ |
push @ARCHBLOCK, $Arch; |
13 |
|
} |
14 |
|
|
15 |
|
#Parse the BuildFile |
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' => 'none' |
50 |
|
}; |
51 |
|
use Utilities::Switcher; |
52 |
|
$switch=Switcher->new($SupportedTags, $fullfilename); |
65 |
|
close GNUmakefile; |
66 |
|
} |
67 |
|
|
68 |
+ |
sub ParseBuildFile_Export { |
69 |
+ |
my $filename=shift; |
70 |
+ |
use Tool; |
71 |
+ |
# This hash defines which Document Elements we can use |
72 |
+ |
my $SupportedTags={ |
73 |
+ |
'none' => 'none', |
74 |
+ |
'export' => \&OutToMakefile, |
75 |
+ |
'export_StartTag' => \&export_start, |
76 |
+ |
'export_EndTag' => \&export_end, |
77 |
+ |
'lib_StartTag' => \&lib_start_export, |
78 |
+ |
'lib' => 'none' |
79 |
+ |
}; |
80 |
+ |
use Utilities::Switcher; |
81 |
+ |
$switchex=Switcher->new($SupportedTags, $filename); |
82 |
+ |
$switchex->{Strict_no_cr}='no'; |
83 |
+ |
$switchex->parse(); # sort out supported tags |
84 |
+ |
} |
85 |
+ |
|
86 |
|
sub initialterms() { |
87 |
|
my $name=shift; |
88 |
|
my @string=@_; |
112 |
|
my @vars=@_; |
113 |
|
|
114 |
|
$hashref=$switch->SetupValueHash(\@vars); |
115 |
+ |
if ( $Arch ) { |
116 |
|
if ( defined $$hashref{'type'} ) { |
117 |
|
$ClassName=$$hashref{'type'}; |
118 |
|
} |
119 |
+ |
} |
120 |
|
} |
121 |
|
|
122 |
|
sub ClassPath_StartTag { |
125 |
|
my $hashref; |
126 |
|
|
127 |
|
$hashref=$switch->SetupValueHash(\@vars); |
128 |
+ |
if ( $Arch ) { |
129 |
|
if ( defined $$hashref{'defaultpath'} ) { |
130 |
|
} |
131 |
+ |
} |
132 |
|
} |
133 |
|
|
134 |
|
sub Bin_start { |
143 |
|
|
144 |
|
$hashref=$switch->SetupValueHash(\@vars); |
145 |
|
$switch->checkparam($hashref, $name, 'file'); |
146 |
+ |
if ( $Arch ) { |
147 |
|
if ( ! defined $$hashref{name} ) { |
148 |
|
($$hashref{name}=$$hashref{file})=~s/\..*//; |
149 |
|
} |
154 |
|
($objectname=$$hashref{file})=~s/\..*/\.o/; |
155 |
|
($objectname_d=$$hashref{file})=~s/\..*/_d\.o/; |
156 |
|
($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/; |
157 |
< |
print GNUmakefile "bin:$$hashref{name}\n"; |
157 |
> |
print GNUmakefile "bin:$$hashref{name}_o\n"; |
158 |
|
print GNUmakefile "bin_debug:$$hashref{name}_d\n"; |
159 |
|
print GNUmakefile "bin_insure:$$hashref{name}_Insure\n"; |
160 |
< |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n"; |
161 |
< |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n"; |
160 |
> |
# print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n"; |
161 |
> |
# print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n"; |
162 |
|
print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n"; |
163 |
|
print GNUmakefile "$$hashref{name}_Insure:.psrc\n"; |
164 |
|
print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
176 |
|
print GNUmakefile <<ENDTEXT; |
177 |
|
$$hashref{name}_d.exe:\$(libslocal_d) |
178 |
|
$$hashref{name}.exe:\$(libslocal) |
179 |
+ |
ifdef MCCABE_DATA_DIR |
180 |
+ |
$$hashref{name}_mccabe.exe: \$(libslocal_d) $(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp |
181 |
+ |
endif |
182 |
|
$$hashref{name}_Insure.exe:\$(libslocal_I) |
183 |
|
$$hashref{name}_d:$$hashref{name}_d.exe |
184 |
< |
-\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
184 |
> |
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
185 |
|
$$hashref{name}_Insure:$$hashref{name}_Insure.exe |
186 |
< |
-\@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
187 |
< |
$$hashref{name}:$$hashref{name}.exe |
188 |
< |
-\@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name} |
189 |
< |
binfiles+=$filename |
186 |
> |
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
187 |
> |
$$hashref{name}:$$hashref{name}_d.exe |
188 |
> |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
189 |
> |
$$hashref{name}_o:$$hashref{name}.exe |
190 |
> |
\@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name} |
191 |
> |
binfiles+=$$hashref{file} |
192 |
|
bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure |
193 |
|
ENDTEXT |
194 |
+ |
} |
195 |
|
} |
196 |
|
|
197 |
|
sub External_StartTag { |
200 |
|
my $hashref; |
201 |
|
|
202 |
|
$hashref=$switch->SetupValueHash(\@vars); |
203 |
+ |
if ( $Arch ) { |
204 |
|
$$hashref{'ref'}=~tr[A-Z][a-z]; |
205 |
|
print GNUmakefile $$hashref{'ref'}; |
206 |
|
if ( defined $$hashref{'version'} ) { |
207 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
208 |
|
} |
209 |
|
print GNUmakefile "=true\n"; |
210 |
+ |
} |
211 |
|
|
212 |
|
} |
213 |
|
|
218 |
|
|
219 |
|
$hashref=$switch->SetupValueHash(\@vars); |
220 |
|
$switch->checkparam($hashref, $name, 'name'); |
221 |
+ |
if ( $Arch ) { |
222 |
|
print GNUmakefile "GROUP_".$$hashref{'name'}; |
223 |
|
if ( defined $$hashref{'version'} ) { |
224 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
225 |
|
} |
226 |
|
print GNUmakefile "=true\n"; |
227 |
+ |
} |
228 |
|
} |
229 |
|
|
230 |
|
sub External { |
251 |
|
|
252 |
|
$hashref=$switch->SetupValueHash(\@vars); |
253 |
|
$switch->checkparam($hashref, $name, "name"); |
254 |
< |
if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile") |
255 |
< |
ne "" ) { |
256 |
< |
print GNUmakefile "ReqDependencies += $filename\n"; |
254 |
> |
if ( $Arch ) { |
255 |
> |
$filename=SCRAMUtils::checkfile( |
256 |
> |
"$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
257 |
> |
if ( $filename ne "" ) { |
258 |
> |
ParseBuildFile_Export( $filename ); |
259 |
> |
} |
260 |
|
} |
211 |
– |
print GNUmakefile "local__$$hashref{name}=true\n"; |
261 |
|
} |
262 |
|
|
263 |
|
sub CheckBuildFile { |
290 |
|
} |
291 |
|
} |
292 |
|
|
293 |
+ |
sub ignoretag { |
294 |
+ |
my $name=shift; |
295 |
+ |
my @vars=@_; |
296 |
+ |
|
297 |
+ |
$Arch=0; |
298 |
+ |
push @ARCHBLOCK, $Arch; |
299 |
+ |
} |
300 |
+ |
|
301 |
+ |
sub ignoretag_end { |
302 |
+ |
my $name=shift; |
303 |
+ |
my @vars=@_; |
304 |
+ |
|
305 |
+ |
pop @ARCHBLOCK; |
306 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
307 |
+ |
} |
308 |
+ |
|
309 |
+ |
sub Arch_Start { |
310 |
+ |
my $name=shift; |
311 |
+ |
my @vars=@_; |
312 |
+ |
my $hashref; |
313 |
+ |
|
314 |
+ |
$hashref=$toolswitch->SetupValueHash( \@vars ); |
315 |
+ |
$toolswitch->checkparam($hashref, $name, 'name'); |
316 |
+ |
#( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0; |
317 |
+ |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0); |
318 |
+ |
push @ARCHBLOCK, $Arch; |
319 |
+ |
} |
320 |
+ |
sub Arch_End { |
321 |
+ |
my $name=shift; |
322 |
+ |
my @vars=@_; |
323 |
+ |
|
324 |
+ |
pop @ARCHBLOCK; |
325 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
326 |
+ |
} |
327 |
+ |
|
328 |
|
# Split up the Class Block String into a useable array |
329 |
|
sub _CutBlock { |
330 |
|
my $string= shift @_; |
347 |
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path}; |
348 |
|
_CutBlock($$hashref{path}); |
349 |
|
} |
350 |
+ |
|
351 |
+ |
sub export_start { |
352 |
+ |
#Set up a toolfile object |
353 |
+ |
$exporttool=Tool->new(); |
354 |
+ |
} |
355 |
+ |
|
356 |
+ |
sub export_end { |
357 |
+ |
#Write toolfile object to disk |
358 |
+ |
$exporttool->envtomake(\*GNUmakefile); |
359 |
+ |
} |
360 |
+ |
|
361 |
+ |
# |
362 |
+ |
# Export Mode Lib Tag |
363 |
+ |
# |
364 |
+ |
sub lib_start_export { |
365 |
+ |
my $name=shift; |
366 |
+ |
my @vars=@_; |
367 |
+ |
my $hashref; |
368 |
+ |
|
369 |
+ |
$hashref=$switchex->SetupValueHash( \@vars ); |
370 |
+ |
$switchex->checkparam($hashref, $name, 'name'); |
371 |
+ |
if ( $Arch ) { |
372 |
+ |
if ( $switchex->context('export') ) { |
373 |
+ |
#If export mode then add this env to the export tool |
374 |
+ |
$exporttool->addenv('lib',$$hashref{name}); |
375 |
+ |
} |
376 |
+ |
} |
377 |
+ |
} |
378 |
+ |
|
379 |
+ |
# |
380 |
+ |
# Standard lib tag |
381 |
+ |
# |
382 |
+ |
sub lib_start { |
383 |
+ |
my $name=shift; |
384 |
+ |
my @vars=@_; |
385 |
+ |
my $hashref; |
386 |
+ |
|
387 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
388 |
+ |
$switch->checkparam($hashref, $name, 'name'); |
389 |
+ |
if ( $Arch ) { |
390 |
+ |
print GNUmakefile "lib+=$$hashref{name}\n"; |
391 |
+ |
} |
392 |
+ |
} |
393 |
+ |
|
394 |
+ |
# |
395 |
+ |
# libtype specification |
396 |
+ |
# |
397 |
+ |
sub LibType_Start { |
398 |
+ |
my $name=shift; |
399 |
+ |
my @vars=@_; |
400 |
+ |
my $hashref; |
401 |
+ |
|
402 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
403 |
+ |
$switch->checkparam($hashref, $name, 'type'); |
404 |
+ |
|
405 |
+ |
print GNUmakefile "# Specify Library Type\n"; |
406 |
+ |
print GNUmakefile "DefaultLibsOff=yes\n"; |
407 |
+ |
if ( $$hashref{'type'}=~/^archive/i ) { |
408 |
+ |
print GNUmakefile "LibArchive=true\n"; |
409 |
+ |
} |
410 |
+ |
elsif ($$hashref{'type'}=~/debugarchive/i ) { |
411 |
+ |
print GNUmakefile "LibDebugArchive=true\n"; |
412 |
+ |
} |
413 |
+ |
elsif ($$hashref{'type'}=~/shared/i ) { |
414 |
+ |
print GNUmakefile 'LibShared=true'."\n"; |
415 |
+ |
} |
416 |
+ |
elsif ($$hashref{'type'}=~/debugshared/i ) { |
417 |
+ |
print GNUmakefile "LibDebugShared=true\n"; |
418 |
+ |
} |
419 |
+ |
print GNUmakefile "\n"; |
420 |
+ |
} |