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 |
|
}; |
48 |
|
use Utilities::Switcher; |
49 |
|
$switch=Switcher->new($SupportedTags, $fullfilename); |
62 |
|
close GNUmakefile; |
63 |
|
} |
64 |
|
|
65 |
+ |
sub ParseBuildFile_Export { |
66 |
+ |
my $filename=shift; |
67 |
+ |
use Tool; |
68 |
+ |
# This hash defines which Document Elements we can use |
69 |
+ |
my $SupportedTags={ |
70 |
+ |
'none' => 'none', |
71 |
+ |
'export' => \&OutToMakefile, |
72 |
+ |
'export_StartTag' => \&export_start, |
73 |
+ |
'export_EndTag' => \&export_end, |
74 |
+ |
'lib_StartTag' => \&lib_start_export, |
75 |
+ |
'lib' => 'none' |
76 |
+ |
}; |
77 |
+ |
use Utilities::Switcher; |
78 |
+ |
$switchex=Switcher->new($SupportedTags, $filename); |
79 |
+ |
$switchex->{Strict_no_cr}='no'; |
80 |
+ |
$switchex->parse(); # sort out supported tags |
81 |
+ |
} |
82 |
+ |
|
83 |
|
sub initialterms() { |
84 |
|
my $name=shift; |
85 |
|
my @string=@_; |
109 |
|
my @vars=@_; |
110 |
|
|
111 |
|
$hashref=$switch->SetupValueHash(\@vars); |
112 |
+ |
if ( $Arch ) { |
113 |
|
if ( defined $$hashref{'type'} ) { |
114 |
|
$ClassName=$$hashref{'type'}; |
115 |
|
} |
116 |
+ |
} |
117 |
|
} |
118 |
|
|
119 |
|
sub ClassPath_StartTag { |
122 |
|
my $hashref; |
123 |
|
|
124 |
|
$hashref=$switch->SetupValueHash(\@vars); |
125 |
+ |
if ( $Arch ) { |
126 |
|
if ( defined $$hashref{'defaultpath'} ) { |
127 |
|
} |
128 |
+ |
} |
129 |
|
} |
130 |
|
|
131 |
|
sub Bin_start { |
135 |
|
my $fileclass; |
136 |
|
my @tools; |
137 |
|
my $tool; |
138 |
+ |
my $filename; |
139 |
+ |
my $objectname; |
140 |
|
|
141 |
|
$hashref=$switch->SetupValueHash(\@vars); |
142 |
|
$switch->checkparam($hashref, $name, 'file'); |
143 |
+ |
if ( $Arch ) { |
144 |
|
if ( ! defined $$hashref{name} ) { |
145 |
|
($$hashref{name}=$$hashref{file})=~s/\..*//; |
146 |
|
} |
147 |
|
# This stuff for later |
148 |
|
#$fileclass=$toolbox->getclass($file); |
149 |
|
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file ); |
150 |
< |
print GNUmakefile "bin::$$hashref{name}\n"; |
151 |
< |
print GNUmakefile "$$hashref{name}::$$hashref{file}\n"; |
150 |
> |
($filename=$$hashref{file})=~s/\..*//; |
151 |
> |
($objectname=$$hashref{file})=~s/\..*/\.o/; |
152 |
> |
($objectname_d=$$hashref{file})=~s/\..*/_d\.o/; |
153 |
> |
($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/; |
154 |
> |
print GNUmakefile "bin:$$hashref{name}\n"; |
155 |
> |
print GNUmakefile "bin_debug:$$hashref{name}_d\n"; |
156 |
> |
print GNUmakefile "bin_insure:$$hashref{name}_Insure\n"; |
157 |
> |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n"; |
158 |
> |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n"; |
159 |
> |
print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n"; |
160 |
> |
print GNUmakefile "$$hashref{name}_Insure:.psrc\n"; |
161 |
> |
print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
162 |
> |
print GNUmakefile "\t\$(CClinkCmdDebug)\n"; |
163 |
> |
print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
164 |
> |
print GNUmakefile "\t\$(CClinkCmdInsure)\n"; |
165 |
> |
print GNUmakefile "$$hashref{name}.exe:$objectname\n"; |
166 |
> |
print GNUmakefile "\t\$(CClinkCmd)\n"; |
167 |
> |
print GNUmakefile "$objectname:$$hashref{name}.dep\n"; |
168 |
> |
print GNUmakefile "$objectname_d:$$hashref{name}.dep\n"; |
169 |
> |
print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n"; |
170 |
> |
print GNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
171 |
> |
print GNUmakefile "-include $$hashref{name}.dep\n"; |
172 |
> |
# print GNUmakefile "$$hashref{name}:$$hashref{file}\n"; |
173 |
> |
print GNUmakefile <<ENDTEXT; |
174 |
> |
$$hashref{name}_d.exe:\$(libslocal_d) |
175 |
> |
$$hashref{name}.exe:\$(libslocal) |
176 |
> |
$$hashref{name}_Insure.exe:\$(libslocal_I) |
177 |
> |
$$hashref{name}_d:$$hashref{name}_d.exe |
178 |
> |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
179 |
> |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe |
180 |
> |
\@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
181 |
> |
$$hashref{name}:$$hashref{name}_d.exe |
182 |
> |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
183 |
> |
$$hashref{name}_o:$$hashref{name}_o.exe |
184 |
> |
\@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name} |
185 |
> |
binfiles+=$filename |
186 |
> |
bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure |
187 |
> |
ENDTEXT |
188 |
> |
} |
189 |
|
} |
190 |
|
|
191 |
|
sub External_StartTag { |
194 |
|
my $hashref; |
195 |
|
|
196 |
|
$hashref=$switch->SetupValueHash(\@vars); |
197 |
+ |
if ( $Arch ) { |
198 |
+ |
$$hashref{'ref'}=~tr[A-Z][a-z]; |
199 |
|
print GNUmakefile $$hashref{'ref'}; |
200 |
|
if ( defined $$hashref{'version'} ) { |
201 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
202 |
|
} |
203 |
|
print GNUmakefile "=true\n"; |
204 |
+ |
} |
205 |
|
|
206 |
|
} |
207 |
|
|
212 |
|
|
213 |
|
$hashref=$switch->SetupValueHash(\@vars); |
214 |
|
$switch->checkparam($hashref, $name, 'name'); |
215 |
+ |
if ( $Arch ) { |
216 |
|
print GNUmakefile "GROUP_".$$hashref{'name'}; |
217 |
|
if ( defined $$hashref{'version'} ) { |
218 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
219 |
|
} |
220 |
|
print GNUmakefile "=true\n"; |
221 |
+ |
} |
222 |
|
} |
223 |
|
|
224 |
|
sub External { |
245 |
|
|
246 |
|
$hashref=$switch->SetupValueHash(\@vars); |
247 |
|
$switch->checkparam($hashref, $name, "name"); |
248 |
< |
if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile") |
249 |
< |
ne "" ) { |
250 |
< |
print GNUmakefile "ReqDependencies += $filename\n"; |
248 |
> |
if ( $Arch ) { |
249 |
> |
$filename=SCRAMUtils::checkfile( |
250 |
> |
"$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
251 |
> |
if ( $filename ne "" ) { |
252 |
> |
ParseBuildFile_Export( $filename ); |
253 |
> |
} |
254 |
|
} |
174 |
– |
print GNUmakefile "local__$$hashref{name}=true\n"; |
255 |
|
} |
256 |
|
|
257 |
|
sub CheckBuildFile { |
284 |
|
} |
285 |
|
} |
286 |
|
|
287 |
+ |
sub ignoretag { |
288 |
+ |
my $name=shift; |
289 |
+ |
my @vars=@_; |
290 |
+ |
|
291 |
+ |
$Arch=0; |
292 |
+ |
push @ARCHBLOCK, $Arch; |
293 |
+ |
} |
294 |
+ |
|
295 |
+ |
sub ignoretag_end { |
296 |
+ |
my $name=shift; |
297 |
+ |
my @vars=@_; |
298 |
+ |
|
299 |
+ |
pop @ARCHBLOCK; |
300 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
301 |
+ |
} |
302 |
+ |
|
303 |
+ |
sub Arch_Start { |
304 |
+ |
my $name=shift; |
305 |
+ |
my @vars=@_; |
306 |
+ |
my $hashref; |
307 |
+ |
|
308 |
+ |
$hashref=$toolswitch->SetupValueHash( \@vars ); |
309 |
+ |
$toolswitch->checkparam($hashref, $name, 'name'); |
310 |
+ |
#( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0; |
311 |
+ |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0); |
312 |
+ |
push @ARCHBLOCK, $Arch; |
313 |
+ |
} |
314 |
+ |
sub Arch_End { |
315 |
+ |
my $name=shift; |
316 |
+ |
my @vars=@_; |
317 |
+ |
|
318 |
+ |
pop @ARCHBLOCK; |
319 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
320 |
+ |
} |
321 |
+ |
|
322 |
|
# Split up the Class Block String into a useable array |
323 |
|
sub _CutBlock { |
324 |
|
my $string= shift @_; |
341 |
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path}; |
342 |
|
_CutBlock($$hashref{path}); |
343 |
|
} |
344 |
+ |
|
345 |
+ |
sub export_start { |
346 |
+ |
#Set up a toolfile object |
347 |
+ |
$exporttool=Tool->new(); |
348 |
+ |
} |
349 |
+ |
|
350 |
+ |
sub export_end { |
351 |
+ |
#Write toolfile object to disk |
352 |
+ |
$exporttool->envtomake(\*GNUmakefile); |
353 |
+ |
} |
354 |
+ |
|
355 |
+ |
# |
356 |
+ |
# Export Mode Lib Tag |
357 |
+ |
# |
358 |
+ |
sub lib_start_export { |
359 |
+ |
my $name=shift; |
360 |
+ |
my @vars=@_; |
361 |
+ |
my $hashref; |
362 |
+ |
|
363 |
+ |
$hashref=$switchex->SetupValueHash( \@vars ); |
364 |
+ |
$switchex->checkparam($hashref, $name, 'name'); |
365 |
+ |
if ( $Arch ) { |
366 |
+ |
if ( $switchex->context('export') ) { |
367 |
+ |
#If export mode then add this env to the export tool |
368 |
+ |
$exporttool->addenv('lib',$$hashref{name}); |
369 |
+ |
} |
370 |
+ |
} |
371 |
+ |
} |
372 |
+ |
|
373 |
+ |
# |
374 |
+ |
# Standard lib tag |
375 |
+ |
# |
376 |
+ |
sub lib_start { |
377 |
+ |
my $name=shift; |
378 |
+ |
my @vars=@_; |
379 |
+ |
my $hashref; |
380 |
+ |
|
381 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
382 |
+ |
$switch->checkparam($hashref, $name, 'name'); |
383 |
+ |
if ( $Arch ) { |
384 |
+ |
print GNUmakefile "lib+=$$hashref{name}\n"; |
385 |
+ |
} |
386 |
+ |
} |