120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
< |
sub BuildSetup { |
124 |
< |
my $self=shift; |
125 |
< |
my $THISDIR=shift; |
126 |
< |
my @Targets=@_; |
127 |
< |
my $DefaultBuildFile=""; |
128 |
< |
my $Class=""; |
129 |
< |
|
130 |
< |
# -- Create working directory |
131 |
< |
chdir $ENV{LOCALTOP}; |
132 |
< |
AddDir::adddir($ENV{INTwork}."/".$THISDIR); |
133 |
< |
|
134 |
< |
my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR); |
135 |
< |
$self->verbose("Class = $Class"); |
136 |
< |
$self->verbose("ClassDir = $ClassDir"); |
123 |
> |
sub BuildSetup |
124 |
> |
{ |
125 |
> |
############################################################### |
126 |
> |
# BuildSetup # |
127 |
> |
############################################################### |
128 |
> |
# modified : Fri Aug 10 16:57:03 2001 / SFA # |
129 |
> |
# params : # |
130 |
> |
# : # |
131 |
> |
# : # |
132 |
> |
# : # |
133 |
> |
# function : Build targets. # |
134 |
> |
# : # |
135 |
> |
# : # |
136 |
> |
############################################################### |
137 |
> |
my $self=shift; |
138 |
> |
my $THISDIR=shift; |
139 |
> |
my @Targets=@_; |
140 |
> |
my $DefaultBuildFile=""; |
141 |
> |
my $Class=""; |
142 |
> |
|
143 |
> |
# -- Create working directory |
144 |
> |
chdir $ENV{LOCALTOP}; |
145 |
> |
AddDir::adddir($ENV{INTwork}."/".$THISDIR); |
146 |
> |
|
147 |
> |
my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR); |
148 |
> |
$self->verbose("Class = $Class"); |
149 |
> |
$self->verbose("ClassDir = $ClassDir"); |
150 |
|
|
151 |
< |
if ( $bf->ignore() ) { |
152 |
< |
print "Nothing to be done - empty group\n"; |
153 |
< |
exit; |
154 |
< |
} |
155 |
< |
shift; |
156 |
< |
$self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile"); |
157 |
< |
|
158 |
< |
# set up the workdir variable |
159 |
< |
$ENV{workdir}=$ENV{INTwork}."/".$ClassDir; |
160 |
< |
my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir}; |
161 |
< |
|
162 |
< |
# set up projdeps variable |
163 |
< |
my $projectfile=$ENV{projconfigdir}."/External_Dependencies"; |
164 |
< |
if ( -e $ENV{LOCALTOP}."/".$projectfile ) { |
151 |
> |
if ( $bf->ignore() ) |
152 |
> |
{ |
153 |
> |
print "Nothing to be done - empty group\n"; |
154 |
> |
exit; |
155 |
> |
} |
156 |
> |
shift; |
157 |
> |
$self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile"); |
158 |
> |
|
159 |
> |
# set up the workdir variable |
160 |
> |
$ENV{workdir}=$ENV{INTwork}."/".$ClassDir; |
161 |
> |
my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir}; |
162 |
> |
|
163 |
> |
# set up projdeps variable |
164 |
> |
my $projectfile=$ENV{projconfigdir}."/External_Dependencies"; |
165 |
> |
if ( -e $ENV{LOCALTOP}."/".$projectfile ) |
166 |
> |
{ |
167 |
|
$ENV{projdeps}=$ENV{LOCALTOP}."/".$projectfile; |
168 |
< |
} |
169 |
< |
elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) { |
168 |
> |
} |
169 |
> |
elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) |
170 |
> |
{ |
171 |
|
$ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile; |
172 |
< |
} |
173 |
< |
if ( $DefaultBuildFile eq "" ) { |
172 |
> |
} |
173 |
> |
if ( $DefaultBuildFile eq "" ) |
174 |
> |
{ |
175 |
|
# Map Relevant makefile classmakefile directory |
176 |
|
my $classmakefile=$ENV{projconfigdir}."/".$Class."_makefile.mk"; |
177 |
< |
if ( -e $ENV{LOCALTOP}."/".$classmakefile ) { |
178 |
< |
$ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile; |
179 |
< |
} |
180 |
< |
elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) { |
177 |
> |
if ( -e $ENV{LOCALTOP}."/".$classmakefile ) |
178 |
> |
{ |
179 |
> |
$ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile; |
180 |
> |
} |
181 |
> |
elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) |
182 |
> |
{ |
183 |
|
$ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile; |
184 |
< |
} |
185 |
< |
else { |
186 |
< |
print "\nUnable to locate $classmakefile\n"; |
187 |
< |
print " Not in $ENV{LOCALTOP}\n"; |
188 |
< |
print " Not in $ENV{RELEASETOP}\n"; |
189 |
< |
exit 1; |
190 |
< |
} |
184 |
> |
} |
185 |
> |
else |
186 |
> |
{ |
187 |
> |
print "\nUnable to locate $classmakefile\n"; |
188 |
> |
print " Not in $ENV{LOCALTOP}\n"; |
189 |
> |
print " Not in $ENV{RELEASETOP}\n"; |
190 |
> |
exit 1; |
191 |
> |
} |
192 |
|
$DefaultBuildFile=$ENV{classmakefile}; # TODO - only for override |
193 |
< |
} |
194 |
< |
|
195 |
< |
$ENV{ClassDir}=$ClassDir; |
196 |
< |
$ENV{Class}=$Class; |
197 |
< |
$ENV{DefaultBuildFile}=$DefaultBuildFile; |
198 |
< |
|
199 |
< |
chdir $fullworkdir || die "Unable to enter working directory $!"; |
200 |
< |
|
201 |
< |
# Set up some other useful variables fo the Build |
202 |
< |
# list of directories available |
203 |
< |
opendir IDR, "$ENV{LOCALTOP}/$THISDIR"; |
204 |
< |
@allfiles= grep !/^\.\.?$/, readdir IDR; |
205 |
< |
foreach $file ( @allfiles ) { |
206 |
< |
if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) { # only add if its a directory |
207 |
< |
$ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file; |
208 |
< |
} |
209 |
< |
else { |
210 |
< |
$ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file; |
211 |
< |
} |
212 |
< |
} |
213 |
< |
$targetnumber=$#Targets; |
214 |
< |
foreach $word ( @Targets ) { |
215 |
< |
if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target |
193 |
> |
} |
194 |
> |
|
195 |
> |
$ENV{ClassDir}=$ClassDir; |
196 |
> |
$ENV{Class}=$Class; |
197 |
> |
$ENV{DefaultBuildFile}=$DefaultBuildFile; |
198 |
> |
|
199 |
> |
chdir $fullworkdir || die "Unable to enter working directory $!"; |
200 |
> |
|
201 |
> |
# Set up some other useful variables fo the Build |
202 |
> |
# list of directories available |
203 |
> |
opendir IDR, "$ENV{LOCALTOP}/$THISDIR"; |
204 |
> |
@allfiles= grep !/^\.\.?$/, readdir IDR; |
205 |
> |
foreach $file ( @allfiles ) |
206 |
> |
{ |
207 |
> |
if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) |
208 |
> |
{ # only add if its a directory |
209 |
> |
$ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file; |
210 |
> |
} |
211 |
> |
else |
212 |
> |
{ |
213 |
> |
$ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file; |
214 |
> |
} |
215 |
> |
} |
216 |
> |
$targetnumber=$#Targets; |
217 |
> |
|
218 |
> |
foreach $word ( @Targets ) |
219 |
> |
{ |
220 |
> |
if ( $word=~/.*=.*/ ) |
221 |
> |
{ # if we have an assignment it cant be a target |
222 |
|
$targetnumber--; |
223 |
< |
} |
224 |
< |
elsif ( $word=~/^-/ ) { |
223 |
> |
} |
224 |
> |
elsif ( $word=~/^-/ ) |
225 |
> |
{ |
226 |
|
$targetnumber--; |
227 |
+ |
} |
228 |
+ |
else |
229 |
+ |
{ |
230 |
+ |
$ENV{"MAKETARGET_".$word}=$word; |
231 |
+ |
} |
232 |
|
} |
201 |
– |
else { |
202 |
– |
$ENV{"MAKETARGET_".$word}=$word; |
203 |
– |
} |
204 |
– |
} |
233 |
|
|
234 |
< |
# If not specified default to the class name target |
235 |
< |
if ( $targetnumber == -1 ) { |
236 |
< |
push @Targets,$Class; |
237 |
< |
} |
234 |
> |
# If not specified default to the class name target |
235 |
> |
if ( $targetnumber == -1 ) |
236 |
> |
{ |
237 |
> |
push @Targets,$Class; |
238 |
> |
} |
239 |
|
|
240 |
< |
$ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk"; |
240 |
> |
$ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk"; |
241 |
|
|
242 |
< |
$SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk"; |
243 |
< |
if ( -f $SCRAM_GROUPSDIR ) { |
242 |
> |
$SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk"; |
243 |
> |
if ( -f $SCRAM_GROUPSDIR ) |
244 |
> |
{ |
245 |
|
$ENV{SCRAM_GROUPSDIR}=$SCRAM_GROUPSDIR; |
246 |
< |
} |
246 |
> |
} |
247 |
> |
|
248 |
> |
# Do a datestamp check so that make will build files that have changed |
249 |
> |
# rather than just those which are older than their dependencies |
250 |
> |
# The main build here |
251 |
> |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config); |
252 |
> |
|
253 |
> |
my $gmakejobsflag = "-j"; |
254 |
> |
chomp(my $currentOS = `uname`); |
255 |
> |
|
256 |
> |
# Only use -j option if there are more then 1 cpu's..... |
257 |
> |
if ( $currentOS eq "Linux" ) |
258 |
> |
{ |
259 |
> |
chomp($ncpu=`cat /proc/cpuinfo | grep -c processor`); |
260 |
> |
} |
261 |
> |
elsif ( $currentOS eq "SunOS" ) |
262 |
> |
{ |
263 |
> |
($ncpu) = (`/usr/sbin/psrinfo | wc -l` =~ /\s+(\d+)/); |
264 |
> |
} |
265 |
> |
else |
266 |
> |
# Who knows what the OS is? Leave as default: |
267 |
> |
{ |
268 |
> |
$ncpu = 1; |
269 |
> |
} |
270 |
> |
|
271 |
> |
# Print a little debug message: |
272 |
> |
print "\n","scram BUILDSYSTEM(v1.0) >> Scram has determined that your system has ",$ncpu," CPU(s).","\n"; |
273 |
> |
# Temporarily hard-code ncpu as 1: |
274 |
> |
# $ncpu = 1; |
275 |
> |
print " >> Multi-CPU builds not supported yet.","\n\n"; |
276 |
> |
|
277 |
> |
# Modify: try to force make to spawn more than one job (option: -j ). |
278 |
> |
$rv=system("gmake","--no-print-directory","$gmakejobsflag","$ncpu","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets); |
279 |
|
|
280 |
< |
# Do a datestamp check so that make will build files that have changed |
281 |
< |
# rather than just those which are older than their dependencies |
220 |
< |
# The main build here |
221 |
< |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config); |
222 |
< |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets); |
223 |
< |
return $rv/256; # return the exit status of gmake |
224 |
< |
} |
280 |
> |
return $rv/256; # return the exit status of gmake |
281 |
> |
} |
282 |
|
|
283 |
|
sub getclass { |
284 |
|
my $self=shift; |
286 |
|
my $Class="DEFAULT"; |
287 |
|
my $ClassDir=""; |
288 |
|
|
232 |
– |
#return if $dirname eq ""; |
289 |
|
@DIRA=split /\//, $dirname; |
290 |
|
|
291 |
|
$thispath="."; |