21 |
|
my $self={}; |
22 |
|
bless $self,$class; |
23 |
|
$self->{toolbox}=shift; |
24 |
– |
#$self->init(); |
24 |
|
return $self; |
25 |
|
} |
26 |
|
|
27 |
< |
sub init { |
28 |
< |
my $self=shift; |
29 |
< |
$self->{toolbox}=BuildSystem::ToolBox->new($ENV{LOCALTOP}); |
30 |
< |
} |
31 |
< |
|
32 |
< |
sub _generateexternals { |
33 |
< |
my $self=shift; |
34 |
< |
my $outfile=shift; |
35 |
< |
|
36 |
< |
# -- specifiy these files for dependency information |
37 |
< |
my $depfile=$ENV{projconfigdir}."/External_Dependencies"; |
38 |
< |
|
39 |
< |
# -- get list of dependent files |
40 |
< |
my $datadir=$ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH}; |
41 |
< |
$fdir=FileHandle->new(); |
42 |
< |
opendir $fdir, $datadir; |
43 |
< |
my @depfiles=grep !/^\.\.?$/, readdir $fdir; |
44 |
< |
undef $fdir; |
45 |
< |
for (my $i=0; $i<=$#depfiles; $i++ ) { |
46 |
< |
$depfiles[$i]=$datadir."/".$depfiles[$i]; |
47 |
< |
} |
48 |
< |
|
49 |
< |
# -- do we need to rebuild? |
50 |
< |
if ( SCRAMUtils::dated($outfile,@depfiles) ) { |
51 |
< |
print "Configuring Local Area\n"; |
52 |
< |
# -- open output file |
53 |
< |
my $fout=FileHandle->new(); |
54 |
< |
$fout->open(">".$outfile) or die "Unable to open $outfile for output". |
55 |
< |
$!."\n"; |
56 |
< |
|
57 |
< |
# -- print out tool/ version info |
58 |
< |
my ($tool,$toolobj,$f,$val,$version); |
59 |
< |
foreach $tool ( $self->{toolbox}->tools() ) { |
60 |
< |
$version=$self->{toolbox}->defaultversion($tool); |
61 |
< |
# default versions |
62 |
< |
print $fout "ifdef $tool\n".$tool."_V_".$version."=true\nendif\n"; |
63 |
< |
# -- set up the different version -- externals |
64 |
< |
foreach $version ( $self->{toolbox}->versions($tool) ) { |
65 |
< |
$toolobj=$self->{toolbox}->gettool($tool,$version); |
66 |
< |
@deps=$toolobj->getfeature("_externals"); |
67 |
< |
foreach $d ( @deps ) { |
68 |
< |
$d=~tr[A-Z][a-z]; |
69 |
< |
print $fout "ifdef ".$tool."_V_".$version."\n $d=true\nendif\n"; |
70 |
< |
} |
71 |
< |
# -- tool info |
72 |
< |
print $fout "ifdef ".$tool."_V_".$version."\n"; |
73 |
< |
foreach $f ( $toolobj->features() ) { |
74 |
< |
foreach $val ( $toolobj->getfeature($f) ) { |
75 |
< |
print $fout "\t".$f." += ".$val."\n"; |
76 |
< |
} |
77 |
< |
} |
78 |
< |
print $fout "endif\n"; |
27 |
> |
sub _generateexternals |
28 |
> |
############################################################### |
29 |
> |
# _generateexternals # |
30 |
> |
############################################################### |
31 |
> |
# modified : Thu Jul 12 12:06:50 2001 / SFA # |
32 |
> |
# params : # |
33 |
> |
# : # |
34 |
> |
# : # |
35 |
> |
# : # |
36 |
> |
# function : # |
37 |
> |
# : # |
38 |
> |
# : # |
39 |
> |
############################################################### |
40 |
> |
{ |
41 |
> |
my $self=shift; |
42 |
> |
my $outfile=shift; |
43 |
> |
|
44 |
> |
# -- specifiy these files for dependency information |
45 |
> |
# NB: This file is never used! |
46 |
> |
|
47 |
> |
my $depfile=$ENV{projconfigdir}."/External_Dependencies"; |
48 |
> |
|
49 |
> |
# -- get list of dependent files |
50 |
> |
my $datadir=$ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH}; |
51 |
> |
$fdir=FileHandle->new(); |
52 |
> |
opendir $fdir, $datadir; |
53 |
> |
my @depfiles=grep !/^\.\.?$/, readdir $fdir; |
54 |
> |
undef $fdir; |
55 |
> |
|
56 |
> |
for (my $i=0; $i<=$#depfiles; $i++ ) |
57 |
> |
{ |
58 |
> |
$depfiles[$i]=$datadir."/".$depfiles[$i]; |
59 |
> |
} |
60 |
> |
|
61 |
> |
# -- do we need to rebuild? |
62 |
> |
if ( SCRAMUtils::dated($outfile,@depfiles) ) |
63 |
> |
{ |
64 |
> |
print "Configuring Local Area\n"; |
65 |
> |
# -- open output file |
66 |
> |
my $fout=FileHandle->new(); |
67 |
> |
$fout->open(">".$outfile) or die "Unable to open $outfile for output". |
68 |
> |
$!."\n"; |
69 |
> |
|
70 |
> |
# -- print out tool/ version info |
71 |
> |
my ($tool,$toolobj,$f,$val,$version); |
72 |
> |
|
73 |
> |
foreach $tool ( $self->{toolbox}->tools() ) |
74 |
> |
{ |
75 |
> |
$version=$self->{toolbox}->defaultversion($tool); |
76 |
> |
|
77 |
> |
# default versions |
78 |
> |
print $fout "ifdef $tool\n".$tool."_V_".$version."=true\nendif\n"; |
79 |
> |
|
80 |
> |
# -- set up the different version -- externals |
81 |
> |
foreach $version ( $self->{toolbox}->versions($tool) ) |
82 |
> |
{ |
83 |
> |
$toolobj=$self->{toolbox}->gettool($tool,$version); |
84 |
> |
@deps=$toolobj->getfeature("_externals"); |
85 |
> |
# |
86 |
> |
foreach $d ( @deps ) |
87 |
> |
{ |
88 |
> |
$d=~tr[A-Z][a-z]; |
89 |
> |
print $fout "ifdef ".$tool."_V_".$version."\n $d=true\nendif\n"; |
90 |
> |
} |
91 |
> |
# -- tool info |
92 |
> |
print $fout "ifdef ".$tool."_V_".$version."\n"; |
93 |
> |
|
94 |
> |
foreach $f ( $toolobj->features() ) |
95 |
> |
{ |
96 |
> |
foreach $val ( $toolobj->getfeature($f) ) |
97 |
> |
{ |
98 |
> |
if ( $f eq 'LIBDIR' || $f eq 'INCLUDE' ) |
99 |
> |
{ |
100 |
> |
# Remove duplications: |
101 |
> |
print $fout "\t".$f." := \$(filter-out ".$val.",\$(".$f."))","\n"; |
102 |
> |
print $fout "\t".$f." += ".$val."\n"; |
103 |
> |
} |
104 |
> |
else |
105 |
> |
{ |
106 |
> |
print $fout "\t".$f." += ".$val."\n"; |
107 |
> |
} |
108 |
> |
} |
109 |
> |
} |
110 |
> |
# -- include any makefiles associated with the tool |
111 |
> |
if ( -f $self->{toolbox}->toolmakefile($tool,$version) ) |
112 |
> |
{ |
113 |
> |
print $fout "-include ". |
114 |
> |
$self->{toolbox}->toolmakefile($tool,$version)."\n"; |
115 |
> |
} |
116 |
> |
print $fout "endif\n"; |
117 |
|
} |
118 |
< |
} |
119 |
< |
# some addittional processing of specific vars |
120 |
< |
print $fout 'INCLUDEPATH+=$(addprefix -I,$(INCLUDE))'."\n"; |
121 |
< |
print $fout 'LDFLAGS+=$(addprefix -L,$(LIBDIR))'."\n"; |
122 |
< |
print $fout 'CPPFLAGS+=$(addprefix -D,$(CPPDEFINES))'."\n"; |
123 |
< |
print $fout 'lib+=$(extralib)'."\n"; |
124 |
< |
print $fout 'LDLIBS+=$(addprefix -l,$(lib))'."\n"; |
125 |
< |
print $fout 'LDLIBS+=$(addprefix -l,$(REQUIRES))'."\n"; |
118 |
> |
} |
119 |
> |
# some addittional processing of specific vars |
120 |
> |
print $fout 'INCLUDEPATH+=$(addprefix -I,$(INCLUDE))'."\n"; |
121 |
> |
print $fout 'LDFLAGS+=$(addprefix -L,$(LIBDIR))'."\n"; |
122 |
> |
print $fout 'CPPFLAGS+=$(addprefix -D,$(CPPDEFINES))'."\n"; |
123 |
> |
print $fout 'lib+=$(extralib)'."\n"; |
124 |
> |
# Hack to parse the lib list and remove duplicates: |
125 |
> |
print $fout 'ORDEREDLIB=$(shell $(SCRAMPERL) $(TOOL_HOME)/ProcessLibs $(lib))',"\n"; |
126 |
> |
print $fout 'LDLIBS+=$(addprefix -l,$(ORDEREDLIB))'."\n"; |
127 |
> |
print $fout 'LDLIBS+=$(addprefix -l,$(REQUIRES))'."\n"; |
128 |
> |
print $fout 'LD_LIBRARY_PATH:=$(subst $(space),:,$(LD_LIBRARY_PATH))'."\n"; |
129 |
|
|
130 |
< |
undef $fout; |
131 |
< |
} |
132 |
< |
} |
130 |
> |
undef $fout; |
131 |
> |
} |
132 |
> |
} |
133 |
|
|
134 |
< |
sub BuildSetup { |
135 |
< |
my $self=shift; |
136 |
< |
my $THISDIR=shift; |
137 |
< |
my @Targets=@_; |
138 |
< |
my $DefaultBuildFile=""; |
139 |
< |
my $Class=""; |
140 |
< |
|
141 |
< |
# -- Create working directory |
142 |
< |
chdir $ENV{LOCALTOP}; |
143 |
< |
AddDir::adddir($ENV{INTwork}."/".$THISDIR); |
144 |
< |
|
145 |
< |
my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR); |
146 |
< |
$self->verbose("Class = $Class"); |
147 |
< |
$self->verbose("ClassDir = $ClassDir"); |
134 |
> |
sub BuildSetup |
135 |
> |
{ |
136 |
> |
############################################################### |
137 |
> |
# BuildSetup # |
138 |
> |
############################################################### |
139 |
> |
# modified : Fri Aug 10 16:57:03 2001 / SFA # |
140 |
> |
# params : # |
141 |
> |
# : # |
142 |
> |
# : # |
143 |
> |
# : # |
144 |
> |
# function : Build targets. # |
145 |
> |
# : # |
146 |
> |
# : # |
147 |
> |
############################################################### |
148 |
> |
my $self=shift; |
149 |
> |
my $THISDIR=shift; |
150 |
> |
my @Targets=@_; |
151 |
> |
my $DefaultBuildFile=""; |
152 |
> |
my $Class=""; |
153 |
> |
|
154 |
> |
# -- Create working directory |
155 |
> |
chdir $ENV{LOCALTOP}; |
156 |
> |
AddDir::adddir($ENV{INTwork}."/".$THISDIR); |
157 |
> |
|
158 |
> |
my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR); |
159 |
> |
$self->verbose("Class = $Class"); |
160 |
> |
$self->verbose("ClassDir = $ClassDir"); |
161 |
|
|
162 |
< |
if ( $bf->ignore() ) { |
163 |
< |
print "Nothing to be done - empty group\n"; |
164 |
< |
exit; |
165 |
< |
} |
166 |
< |
shift; |
167 |
< |
$self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile"); |
168 |
< |
|
169 |
< |
# set up the workdir variable |
170 |
< |
$ENV{workdir}=$ENV{INTwork}."/".$ClassDir; |
171 |
< |
my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir}; |
172 |
< |
|
173 |
< |
# set up projdeps variable |
174 |
< |
my $projectfile=$ENV{projconfigdir}."/External_Dependencies"; |
175 |
< |
if ( -e $ENV{LOCALTOP}."/".$projectfile ) { |
162 |
> |
if ( $bf->ignore() ) |
163 |
> |
{ |
164 |
> |
print "Nothing to be done - empty group\n"; |
165 |
> |
exit; |
166 |
> |
} |
167 |
> |
shift; |
168 |
> |
$self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile"); |
169 |
> |
|
170 |
> |
# set up the workdir variable |
171 |
> |
$ENV{workdir}=$ENV{INTwork}."/".$ClassDir; |
172 |
> |
my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir}; |
173 |
> |
|
174 |
> |
# set up projdeps variable |
175 |
> |
my $projectfile=$ENV{projconfigdir}."/External_Dependencies"; |
176 |
> |
if ( -e $ENV{LOCALTOP}."/".$projectfile ) |
177 |
> |
{ |
178 |
|
$ENV{projdeps}=$ENV{LOCALTOP}."/".$projectfile; |
179 |
< |
} |
180 |
< |
elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) { |
179 |
> |
} |
180 |
> |
elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) |
181 |
> |
{ |
182 |
|
$ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile; |
183 |
< |
} |
184 |
< |
if ( $DefaultBuildFile eq "" ) { |
183 |
> |
} |
184 |
> |
if ( $DefaultBuildFile eq "" ) |
185 |
> |
{ |
186 |
|
# Map Relevant makefile classmakefile directory |
187 |
|
my $classmakefile=$ENV{projconfigdir}."/".$Class."_makefile.mk"; |
188 |
< |
if ( -e $ENV{LOCALTOP}."/".$classmakefile ) { |
189 |
< |
$ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile; |
190 |
< |
} |
191 |
< |
elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) { |
188 |
> |
if ( -e $ENV{LOCALTOP}."/".$classmakefile ) |
189 |
> |
{ |
190 |
> |
$ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile; |
191 |
> |
} |
192 |
> |
elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) |
193 |
> |
{ |
194 |
|
$ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile; |
195 |
< |
} |
196 |
< |
else { |
197 |
< |
print "\nUnable to locate $classmakefile\n"; |
198 |
< |
print " Not in $ENV{LOCALTOP}\n"; |
199 |
< |
print " Not in $ENV{RELEASETOP}\n"; |
200 |
< |
exit 1; |
201 |
< |
} |
195 |
> |
} |
196 |
> |
else |
197 |
> |
{ |
198 |
> |
print "\nUnable to locate $classmakefile\n"; |
199 |
> |
print " Not in $ENV{LOCALTOP}\n"; |
200 |
> |
print " Not in $ENV{RELEASETOP}\n"; |
201 |
> |
exit 1; |
202 |
> |
} |
203 |
|
$DefaultBuildFile=$ENV{classmakefile}; # TODO - only for override |
204 |
< |
} |
204 |
> |
} |
205 |
> |
|
206 |
> |
$ENV{ClassDir}=$ClassDir; |
207 |
> |
$ENV{Class}=$Class; |
208 |
> |
$ENV{DefaultBuildFile}=$DefaultBuildFile; |
209 |
> |
|
210 |
> |
chdir $fullworkdir || die "Unable to enter working directory $!"; |
211 |
> |
|
212 |
> |
# Set up some other useful variables fo the Build |
213 |
> |
# list of directories available |
214 |
> |
opendir IDR, "$ENV{LOCALTOP}/$THISDIR"; |
215 |
> |
@allfiles= grep !/^\.\.?$/, readdir IDR; |
216 |
> |
foreach $file ( @allfiles ) |
217 |
> |
{ |
218 |
> |
if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) |
219 |
> |
{ # only add if its a directory |
220 |
> |
$ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file; |
221 |
> |
} |
222 |
> |
else |
223 |
> |
{ |
224 |
> |
$ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file; |
225 |
> |
} |
226 |
> |
} |
227 |
> |
$targetnumber=$#Targets; |
228 |
|
|
229 |
< |
$ENV{ClassDir}=$ClassDir; |
230 |
< |
$ENV{Class}=$Class; |
231 |
< |
$ENV{DefaultBuildFile}=$DefaultBuildFile; |
232 |
< |
|
150 |
< |
chdir $fullworkdir || die "Unable to enter working directory $!"; |
151 |
< |
|
152 |
< |
# Set up some other useful variables fo the Build |
153 |
< |
# list of directories available |
154 |
< |
opendir IDR, "$ENV{LOCALTOP}/$THISDIR"; |
155 |
< |
@allfiles= grep !/^\.\.?$/, readdir IDR; |
156 |
< |
foreach $file ( @allfiles ) { |
157 |
< |
if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) { # only add if its a directory |
158 |
< |
$ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file; |
159 |
< |
} |
160 |
< |
else { |
161 |
< |
$ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file; |
162 |
< |
} |
163 |
< |
} |
164 |
< |
$targetnumber=$#Targets; |
165 |
< |
foreach $word ( @Targets ) { |
166 |
< |
if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target |
229 |
> |
foreach $word ( @Targets ) |
230 |
> |
{ |
231 |
> |
if ( $word=~/.*=.*/ ) |
232 |
> |
{ # if we have an assignment it cant be a target |
233 |
|
$targetnumber--; |
234 |
+ |
} |
235 |
+ |
elsif ( $word=~/^-/ ) |
236 |
+ |
{ |
237 |
+ |
$targetnumber--; |
238 |
+ |
} |
239 |
+ |
else |
240 |
+ |
{ |
241 |
+ |
$ENV{"MAKETARGET_".$word}=$word; |
242 |
+ |
} |
243 |
|
} |
169 |
– |
else { |
170 |
– |
$ENV{"MAKETARGET_".$word}=$word; |
171 |
– |
} |
172 |
– |
} |
244 |
|
|
245 |
< |
# If not specified default to the class name target |
246 |
< |
if ( $targetnumber == -1 ) { |
247 |
< |
push @Targets,$Class; |
248 |
< |
} |
245 |
> |
# If not specified default to the class name target |
246 |
> |
if ( $targetnumber == -1 ) |
247 |
> |
{ |
248 |
> |
push @Targets,$Class; |
249 |
> |
} |
250 |
|
|
251 |
< |
$ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk"; |
251 |
> |
$ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk"; |
252 |
|
|
253 |
< |
$SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk"; |
254 |
< |
if ( -f $SCRAM_GROUPSDIR ) { |
253 |
> |
$SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk"; |
254 |
> |
if ( -f $SCRAM_GROUPSDIR ) |
255 |
> |
{ |
256 |
|
$ENV{SCRAM_GROUPSDIR}=$SCRAM_GROUPSDIR; |
257 |
< |
} |
257 |
> |
} |
258 |
> |
|
259 |
> |
# Do a datestamp check so that make will build files that have changed |
260 |
> |
# rather than just those which are older than their dependencies |
261 |
> |
# The main build here |
262 |
> |
|
263 |
> |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config); |
264 |
> |
|
265 |
> |
# Be verbose: |
266 |
> |
$self->verbose(">> Going to use ".$ENV{DefaultMakefile}." as the default makefile"); |
267 |
> |
|
268 |
> |
my $gmakejobsflag = "-j"; |
269 |
> |
# Temporarily hard-code ncpu as 1: |
270 |
> |
my $ncpu = 1; |
271 |
|
|
272 |
< |
# Do a datestamp check so that make will build files that have changed |
273 |
< |
# rather than just those which are older than their dependencies |
274 |
< |
# The main build here |
275 |
< |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config); |
190 |
< |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets); |
191 |
< |
return $rv/256; # return the exit status of gmake |
192 |
< |
} |
272 |
> |
$rv=system("gmake","--no-print-directory","$gmakejobsflag","$ncpu","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets); |
273 |
> |
|
274 |
> |
return $rv/256; # return the exit status of gmake |
275 |
> |
} |
276 |
|
|
277 |
|
sub getclass { |
278 |
|
my $self=shift; |
280 |
|
my $Class="DEFAULT"; |
281 |
|
my $ClassDir=""; |
282 |
|
|
200 |
– |
#return if $dirname eq ""; |
283 |
|
@DIRA=split /\//, $dirname; |
284 |
|
|
285 |
|
$thispath="."; |