2 |
|
# |
3 |
|
# Interface |
4 |
|
# --------- |
5 |
< |
# new(ConfigArea) : A new BuildSetup |
6 |
< |
# BuildDir(directory,targets) : prepare the ground for a build and build |
5 |
> |
# new(toolbox) : A new BuildSetup |
6 |
> |
# BuildSetup(directory,targets) : prepare the ground for a build and build |
7 |
|
# getclass(directory) : return (Class, ClassDir, BuildFileobject) |
8 |
|
# associated with directory |
9 |
< |
# setup(dir) |
9 |
> |
# |
10 |
|
|
11 |
|
package BuildSystem::BuildSetup; |
12 |
|
require 5.004; |
13 |
|
use Utilities::Verbose; |
14 |
|
use Utilities::SCRAMUtils; |
15 |
|
use BuildSystem::BuildFile; |
16 |
– |
use BuildSystem::DateStampRecord; |
16 |
|
use Utilities::AddDir; |
17 |
|
@ISA=qw(Utilities::Verbose); |
18 |
|
|
20 |
|
my $class=shift; |
21 |
|
my $self={}; |
22 |
|
bless $self,$class; |
23 |
< |
$self->{area}=shift; |
25 |
< |
$self->{toolbox}=$self->{area}->toolbox(); |
26 |
< |
$self->{projconfigdir}=$self->{area}->configurationdir(); |
27 |
< |
$self->{localtop}=$self->{area}->location(); |
28 |
< |
$self->{releasearea}=$self->{area}->linkarea(); |
29 |
< |
if ( ! defined $self->{releasearea} ) { |
30 |
< |
$self->{releasearea}=$self->{area}; |
31 |
< |
} |
32 |
< |
$self->{releasetop}=$self->{releasearea}->location(); |
33 |
< |
$self->{buildfilename}="BuildFile"; |
34 |
< |
$self->_configurationsetup(); |
23 |
> |
$self->{toolbox}=shift; |
24 |
|
return $self; |
25 |
|
} |
26 |
|
|
27 |
< |
sub _generateexternals { |
28 |
< |
my $self=shift; |
29 |
< |
my $outfile=shift; |
30 |
< |
|
31 |
< |
# -- specify these files for dependency information |
32 |
< |
my $depfile=$self->{projconfigdir}."/External_Dependencies"; |
33 |
< |
|
34 |
< |
# -- get list of dependent files |
35 |
< |
my $datadir=$self->{localtop}."/.SCRAM/".$ENV{SCRAM_ARCH}; |
36 |
< |
$fdir=FileHandle->new(); |
37 |
< |
opendir $fdir, $datadir; |
38 |
< |
my @depfiles=grep !/^\.\.?$/, readdir $fdir; |
39 |
< |
undef $fdir; |
40 |
< |
for (my $i=0; $i<=$#depfiles; $i++ ) { |
41 |
< |
$depfiles[$i]=$datadir."/".$depfiles[$i]; |
42 |
< |
} |
43 |
< |
|
44 |
< |
# -- do we need to rebuild? |
45 |
< |
if ( SCRAMUtils::dated($outfile,@depfiles) ) { |
46 |
< |
print "Configuring Local Area\n"; |
47 |
< |
# -- open output file |
48 |
< |
my $fout=FileHandle->new(); |
49 |
< |
$fout->open(">".$outfile) or die "Unable to open $outfile for output". |
50 |
< |
$!."\n"; |
51 |
< |
|
52 |
< |
# -- print out tool/ version info |
53 |
< |
my ($tool,$toolobj,$f,$val,$version); |
54 |
< |
foreach $tool ( $self->{toolbox}->tools() ) { |
55 |
< |
$version=$self->{toolbox}->defaultversion($tool); |
56 |
< |
# default versions |
57 |
< |
print $fout "ifdef $tool\n".$tool."_V_".$version."=true\nendif\n"; |
58 |
< |
# -- set up the different version -- externals |
59 |
< |
foreach $version ( $self->{toolbox}->versions($tool) ) { |
60 |
< |
$toolobj=$self->{toolbox}->gettool($tool,$version); |
61 |
< |
@deps=$toolobj->getfeature("_externals"); |
62 |
< |
foreach $d ( @deps ) { |
63 |
< |
$d=~tr[A-Z][a-z]; |
64 |
< |
print $fout "ifdef ".$tool."_V_".$version."\n $d=true\nendif\n"; |
65 |
< |
} |
66 |
< |
# -- tool info |
67 |
< |
print $fout "ifdef ".$tool."_V_".$version."\n"; |
68 |
< |
foreach $f ( $toolobj->features() ) { |
69 |
< |
foreach $val ( $toolobj->getfeature($f) ) { |
70 |
< |
print $fout "\t".$f." += ".$val."\n"; |
71 |
< |
} |
72 |
< |
} |
73 |
< |
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"; |
126 |
< |
|
127 |
< |
undef $fout; |
128 |
< |
$self->verbose("End Configuration Setup"); |
97 |
< |
} |
98 |
< |
} |
99 |
< |
|
100 |
< |
sub classsetup { |
101 |
< |
my $self=shift; |
102 |
< |
my $THISDIR=shift; |
103 |
< |
|
104 |
< |
my $classmakefile; |
105 |
< |
|
106 |
< |
my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR); |
107 |
< |
$self->verbose("Class = $Class : ClassDir = $ClassDir for directory ". |
108 |
< |
$THISDIR); |
109 |
< |
|
110 |
< |
# -- should we ignore? |
111 |
< |
if ( $bf->ignore() ) { |
112 |
< |
print "Nothing to be done - empty group\n"; |
113 |
< |
exit; |
114 |
< |
} |
115 |
< |
|
116 |
< |
|
117 |
< |
# -- Create a makefile from the class BuildFile |
118 |
< |
my $classbuildfile=$self->{localtop}."/". |
119 |
< |
$self->{projconfigdir}."/".$Class."_BuildFile"; |
120 |
< |
if ( -f $classbuildfile ) { |
121 |
< |
$classmakefile=$self->{localtop}."/".$ENV{INTwork}. |
122 |
< |
"/".$Class."_makefile.mk"; |
123 |
< |
if ( SCRAMUtils::dated($classmakefile, $classbuildfile) ) { |
124 |
< |
# -- generate the new makefile if out of date |
125 |
< |
$self->verbose("Generating $classmakefile from". |
126 |
< |
" $classbuildfile"); |
127 |
< |
my $classbf=BuildSystem::BuildFile->new($self->{area}); |
128 |
< |
undef $ENV{LatestBuildFile}; # gets set by BuildFile |
129 |
< |
$classbf->GenerateMakefile($classbuildfile, $classmakefile); |
130 |
< |
} |
131 |
< |
} |
132 |
< |
else { |
133 |
< |
# -- No BuildFile - maybe its old style makefile |
134 |
< |
$classmakefile=$self->{localtop}."/". |
135 |
< |
$self->{projconfigdir}."/".$Class."_makefile.mk"; |
136 |
< |
if ( ! -f $classmakefile ) { |
137 |
< |
$self->error("Unable to find matching ".$Class. |
138 |
< |
"_BuildFile or ".$Class."_makefile.mk"); |
139 |
< |
} |
140 |
< |
} |
141 |
< |
# -- set LatestBuildFile |
142 |
< |
if ( $bf->buildfile() ne "" ) { |
143 |
< |
$ENV{LatestBuildFile}=$bf->makefile(); |
144 |
< |
} |
145 |
< |
else { |
146 |
< |
$ENV{LatestBuildFile}=$self->{topbf}->makefile(); |
147 |
< |
} |
148 |
< |
|
149 |
< |
return ($Class,$ClassDir,$classmakefile); |
150 |
< |
} |
151 |
< |
|
152 |
< |
sub _configurationsetup { |
153 |
< |
my $self=shift; |
154 |
< |
|
155 |
< |
# -- set working directory |
156 |
< |
$self->{workdir}=$ENV{INTwork}; |
157 |
< |
$self->{fullworkdir}=$self->{localtop}."/".$self->{workdir}; |
158 |
< |
|
159 |
< |
# -- make working directory |
160 |
< |
chdir $self->{localtop}; |
161 |
< |
AddDir::adddir($self->{workdir}); |
162 |
< |
|
163 |
< |
# -- generate tool info |
164 |
< |
$self->_generateexternals($self->{fullworkdir}."/clientmakefile"); |
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 |
< |
# -- process project BuildFile |
131 |
< |
$self->_topbuildfile(); |
132 |
< |
} |
130 |
> |
undef $fout; |
131 |
> |
} |
132 |
> |
} |
133 |
|
|
134 |
< |
sub BuildDir { |
135 |
< |
my $self=shift; |
136 |
< |
my $THISDIR=shift; |
137 |
< |
my @Targets=@_; |
138 |
< |
my $DefaultBuildFile=""; |
139 |
< |
|
140 |
< |
|
141 |
< |
# -- Setup Class specifics |
142 |
< |
($Class,$ClassDir,$classmakefile)=$self->classsetup($THISDIR); |
143 |
< |
$ENV{classmakefile}=$classmakefile; |
144 |
< |
$ENV{Class}=$Class; |
145 |
< |
$ENV{ClassDir}=$ClassDir; |
146 |
< |
$DefaultBuildFile=$ENV{classmakefile}; |
147 |
< |
$ENV{DefaultBuildFile}=$DefaultBuildFile; |
148 |
< |
|
149 |
< |
# -- Create working directory |
150 |
< |
my $workdir=$self->{workdir}."/".$ClassDir; |
151 |
< |
chdir $self->{localtop}; |
152 |
< |
AddDir::adddir($workdir); |
153 |
< |
$ENV{workdir}=$workdir; |
154 |
< |
my $fullworkdir=$self->{localtop}."/".$ENV{workdir}; |
155 |
< |
chdir $fullworkdir || die "Unable to enter working directory $!"; |
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 |
< |
# -- Set up some other useful variables for the Build |
163 |
< |
# set variables listing directories/files available |
164 |
< |
my $fh=FileHandle->new(); |
165 |
< |
opendir $fh, "$self->{localtop}/$ClassDir"; |
166 |
< |
my @allfiles= grep !/^\.\.?$/, readdir $fh; |
167 |
< |
undef $fh; |
168 |
< |
foreach $file ( @allfiles ) { |
169 |
< |
if ( -d "$self->{localtop}/$ClassDir/$file" ) { |
170 |
< |
$ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file; |
171 |
< |
} |
172 |
< |
else { |
173 |
< |
$ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file; |
174 |
< |
} |
175 |
< |
} |
176 |
< |
my $targetnumber=$#Targets; |
177 |
< |
$ENV{"MAKETARGETS"}=""; |
178 |
< |
foreach $word ( @Targets ) { |
179 |
< |
if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target |
180 |
< |
$targetnumber--; |
181 |
< |
} |
182 |
< |
else { |
183 |
< |
# set some variables for use in makefiles |
184 |
< |
$ENV{"MAKETARGET_".$word}=$word; |
185 |
< |
if ( $ENV{"MAKETARGETS"} ne "" ) { |
186 |
< |
$ENV{"MAKETARGETS"}=$ENV{"MAKETARGETS"}." ".$word; |
187 |
< |
} |
188 |
< |
else { |
189 |
< |
$ENV{"MAKETARGETS"}=$word; |
190 |
< |
} |
191 |
< |
} |
192 |
< |
} |
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 ) |
181 |
> |
{ |
182 |
> |
$ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile; |
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 |
> |
{ |
190 |
> |
$ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile; |
191 |
> |
} |
192 |
> |
elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) |
193 |
> |
{ |
194 |
> |
$ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile; |
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 |
> |
} |
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 |
< |
# -- If target not specified default to the class name target |
230 |
< |
if ( $targetnumber == -1 ) { |
231 |
< |
push @Targets,$Class; |
232 |
< |
} |
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 |
> |
} |
244 |
|
|
245 |
< |
$ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk"; |
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"; |
252 |
|
|
253 |
< |
$SCRAM_GROUPSDIR=$self->{localtop}."/".$self->{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 |
< |
} |
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 |
< |
$self->_checkdatestampindir($ClassDir); |
262 |
< |
|
263 |
< |
# -- call the block building method |
264 |
< |
#$report=$bs->build(@Targets); |
265 |
< |
|
266 |
< |
|
267 |
< |
# The main build here |
268 |
< |
$rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}", @Targets); |
269 |
< |
return $rv/256; # return the exit status of gmake |
270 |
< |
|
250 |
< |
} |
251 |
< |
|
252 |
< |
sub BuildIt { |
253 |
< |
my $self=shift; |
254 |
< |
my $dir=shift; |
255 |
< |
|
256 |
< |
# -- get the building block for the directory |
257 |
< |
my $block=$self->_getdirblock($dir); |
258 |
< |
|
259 |
< |
# -- is there a class block associated with the directory? |
260 |
< |
my ($class)=getclass($dir); |
261 |
< |
my $classblock=$self->_getclassblock($class); |
262 |
< |
|
263 |
< |
# -- Search for Blocks up to tree root |
264 |
< |
my @dirblocks=(); |
265 |
< |
my @dirs=split /\//, $dir; |
266 |
< |
my $fulldir=""; |
267 |
< |
foreach $dire ( "/",@dirs ) { |
268 |
< |
$fulldir=$fulldir."/".$dire; # root is // |
269 |
< |
my $block=$self->_getdirblock($fulldir); |
270 |
< |
last if $block->ignore(); # we dont need to go futher |
271 |
< |
push @dirblocks, $block; |
272 |
< |
} |
273 |
< |
foreach $block ( $classblock, @dirblocks ) { |
274 |
< |
# -- merge class blocks together |
275 |
< |
foreach $name ( $block->classes() ) { |
276 |
< |
$object->merge(); |
277 |
< |
} |
278 |
< |
foreach $classinst ( $block->classinst() ) { |
279 |
< |
$types{$classinst->id()}=$class->newinst(); |
280 |
< |
foreach $element ( $classinst ) { |
281 |
< |
$types{$classinst->id()}->setelement($element, |
282 |
< |
$classinst->value($element)); |
283 |
< |
} |
284 |
< |
} |
285 |
< |
} |
286 |
< |
|
287 |
< |
# -- call the builder |
288 |
< |
|
289 |
< |
} |
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 |
< |
sub _getdirblock { |
292 |
< |
my $self=shift; |
293 |
< |
my $dir=shift; |
272 |
> |
$rv=system("gmake","--no-print-directory","$gmakejobsflag","$ncpu","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets); |
273 |
|
|
274 |
< |
if ( ! defined $self->{blocks}{$dir} ) { |
275 |
< |
|
297 |
< |
# -- get a buildfile and do a block parse |
298 |
< |
my $bf=$self->_startbuildfile($dir); |
299 |
< |
$bf->blockparse($self->{blocks}{$dir}); |
300 |
< |
|
301 |
< |
} |
302 |
< |
return $self->{blocks}{$dir}; |
303 |
< |
} |
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 |
|
|
311 |
– |
#return if $dirname eq ""; |
283 |
|
@DIRA=split /\//, $dirname; |
284 |
|
|
285 |
< |
my $thispath="."; |
286 |
< |
# -- construct all class buildfiles in the path |
285 |
> |
$thispath="."; |
286 |
> |
# bootstrap from project buildfile if it exists |
287 |
> |
my $bf=BuildSystem::BuildFile->new($self->{toolbox}); |
288 |
> |
$bf->CheckBuildFile($ENV{projconfigdir}); |
289 |
> |
|
290 |
> |
my @ClassPaths=split /:/, $bf->BlockClassPath(); |
291 |
> |
foreach $BClassPath ( @ClassPaths ) { |
292 |
> |
next if ( $BClassPath eq ""); |
293 |
> |
push @LoBCA, [ split /\//, $BClassPath ]; |
294 |
> |
} |
295 |
|
for ( $i=0; $i<=$#DIRA; $i++ ) { |
296 |
< |
#$thispath=(($thispath eq "")?$DIRA[$i]:$thispath."/".$DIRA[$i]); |
297 |
< |
$thispath=$thispath."/".$DIRA[$i]; |
298 |
< |
if ( ! exists $self->{pathbf}{$thispath} ) { |
320 |
< |
$self->verbose("Initialising BuildFile in $thispath"); |
321 |
< |
$self->{pathbf}{$thispath}=$self->_startbuildfile($thispath); |
322 |
< |
} |
323 |
< |
# -- check class overriden by BuildFile |
324 |
< |
if ( defined $self->{pathbf}{$thispath}->classname() ) { |
325 |
< |
$Class=$self->{pathbf}{$thispath}->classname(); |
296 |
> |
$thispath=$thispath."/".$DIRA[$i]; |
297 |
> |
if ( ($ClassName=$bf->CheckBuildFile($thispath)) ne "" ) { |
298 |
> |
$Class=$ClassName; |
299 |
|
$ClassDir=$thispath; |
300 |
|
} |
301 |
+ |
# TODO --- Must test against position of last new BlockCaseA |
302 |
+ |
# Need to reset array LoBCA to the New BlockPath |
303 |
+ |
# - merge and replace options |
304 |
+ |
# |
305 |
|
else { |
306 |
< |
# -- sort it out from classpath directives |
307 |
< |
foreach $BlockClassA ( @{$self->{LoBCA}} ) { |
308 |
< |
next if ( $#{$BlockClassA} < $i ); |
332 |
< |
$elem=${$BlockClassA}[$i]; |
333 |
< |
if ( $elem=~/^$DIRA[$i]\+/ ) { |
334 |
< |
$elem=~s/^$DIRA[$i]//; |
306 |
> |
foreach $BlockClassA ( @LoBCA ) { |
307 |
> |
if ( $$BlockClassA[0]=~/^$DIRA[$i]\+/ ) { |
308 |
> |
$$BlockClassA[0]=~s/^$DIRA[$i]//; |
309 |
|
} |
310 |
< |
#print $elem." ".$DIRA[$i]."\n"; |
311 |
< |
if ( $elem=~/^\+/ ) { |
338 |
< |
($Class=$elem)=~s/^\+//; |
310 |
> |
if ( $$BlockClassA[0]=~/^\+/ ) { |
311 |
> |
($Class=$$BlockClassA[0])=~s/^\+//; |
312 |
|
$ClassDir=$thispath; |
313 |
+ |
shift @$BlockClassA; |
314 |
+ |
} |
315 |
+ |
else { |
316 |
+ |
@$BlockClassA=(); |
317 |
|
} |
341 |
– |
#} |
342 |
– |
} |
343 |
– |
} |
344 |
– |
} |
345 |
– |
# -- default case |
346 |
– |
if ( $ClassDir eq "" ) { |
347 |
– |
if ( ! defined $self->{pathbf}{'.'}) { |
348 |
– |
$self->{pathbf}{'.'}=$self->_startbuildfile("."); |
349 |
– |
$self->verbose("DEFAULT class initialised : ".$self->{pathbf}{'.'}); |
350 |
– |
} |
351 |
– |
$ClassDir="."; |
352 |
– |
} |
353 |
– |
|
354 |
– |
# -- returns |
355 |
– |
($ClassDir_c=$ClassDir)=~s/^\.\///; |
356 |
– |
return ( $Class, $ClassDir_c, $self->{pathbf}{$ClassDir}); |
357 |
– |
} |
358 |
– |
|
359 |
– |
# |
360 |
– |
# Check to see if the buildfile is local or in the release area and |
361 |
– |
# parse appropriately |
362 |
– |
# |
363 |
– |
sub _startbuildfile { |
364 |
– |
my $self=shift; |
365 |
– |
my $classdir=shift; |
366 |
– |
|
367 |
– |
my $bf=BuildSystem::BuildFile->new($self->{area}); |
368 |
– |
my $thisfile="$classdir/$self->{buildfilename}"; |
369 |
– |
|
370 |
– |
if ( -e $self->{localtop}."/".$thisfile ) { |
371 |
– |
$bf->buildfile($self->{localtop}."/".$thisfile); |
372 |
– |
$bf->ParseBuildFile($self->{localtop}, $classdir, |
373 |
– |
$self->{buildfilename}); |
374 |
– |
} |
375 |
– |
elsif ( -e $self->{releasetop}."/".$thisfile ) { |
376 |
– |
$bf->buildfile($self->{releasetop}."/".$thisfile); |
377 |
– |
$bf->ParseBuildFile($self->{releasetop}, $classdir, |
378 |
– |
$self->{buildfilename}); |
379 |
– |
} |
380 |
– |
return $bf; |
381 |
– |
} |
382 |
– |
|
383 |
– |
sub _topbuildfile { |
384 |
– |
my $self=shift; |
385 |
– |
|
386 |
– |
# -- Analyse project buildfile if it exists |
387 |
– |
$self->{topbf}=BuildSystem::BuildFile->new($self->{area}); |
388 |
– |
|
389 |
– |
$self->{topbf}->buildfile($self->{localtop}."/".$self->{projconfigdir} |
390 |
– |
."/".$self->{buildfilename}); |
391 |
– |
# -- generate top level makefile |
392 |
– |
$self->verbose("Generating Top Level BuildFile"); |
393 |
– |
$self->{topbf}->ParseBuildFile($self->{localtop}, |
394 |
– |
$self->{projconfigdir},$self->{buildfilename}); |
395 |
– |
|
396 |
– |
my @ClassPaths=split /:/, $self->{topbf}->BlockClassPath(); |
397 |
– |
foreach $BClassPath ( @ClassPaths ) { |
398 |
– |
next if ( $BClassPath eq ""); |
399 |
– |
push @{$self->{LoBCA}}, [ split /\//, $BClassPath ]; |
400 |
– |
} |
401 |
– |
|
402 |
– |
} |
403 |
– |
|
404 |
– |
sub _checkdatestampindir { |
405 |
– |
my $self=shift; |
406 |
– |
my $dir=shift; |
407 |
– |
|
408 |
– |
# -- get all local .ds files |
409 |
– |
my $fh=FileHandle->new(); |
410 |
– |
my $ldir=$self->{localtop}."/".$self->{workdir}."/".$dir; |
411 |
– |
opendir $fh, $ldir; |
412 |
– |
my @dsfiles= grep /^.*\.ds$/, readdir $fh; |
413 |
– |
$fh->close(); |
414 |
– |
|
415 |
– |
# -- copy across ds files from releasetop if not existing locally |
416 |
– |
if ( $#dsfiles < 0 ) { |
417 |
– |
# -- get all releasetop .ds files |
418 |
– |
my $rdir=$self->{releasetop}."/".$self->{workdir}."/".$dir; |
419 |
– |
opendir $fh, $rdir; |
420 |
– |
my @releasedsfiles= grep /^.*\.ds$/, readdir $fh; |
421 |
– |
foreach $file ( @releasedsfiles ) { |
422 |
– |
use File::Copy; |
423 |
– |
copy($rdir."/".$file,$ldir."/".$file); |
424 |
– |
} |
425 |
– |
$fh->close(); |
426 |
– |
@dsfiles=@releasedsfiles; |
427 |
– |
} |
428 |
– |
|
429 |
– |
# -- process ds files |
430 |
– |
my $file; |
431 |
– |
foreach $datafile ( @dsfiles ) { |
432 |
– |
my $ds=BuildSystem::DateStampRecord->new($datafile); |
433 |
– |
my $needsupdate; |
434 |
– |
my $productfile=$ds->product(); |
435 |
– |
my (%files,%moddate); |
436 |
– |
|
437 |
– |
# now get dates in our dependency list |
438 |
– |
my @datedfiles=$ds->dated(); |
439 |
– |
if ( $#datedfiles >= 0 ) { |
440 |
– |
$needsupdate=1; |
441 |
– |
$date=$datedfiles[0][1]-1; |
442 |
– |
} |
443 |
– |
else { |
444 |
– |
# -- extra checks for local replacement of files |
445 |
– |
foreach $file ( $ds->contents() ) { |
446 |
– |
# -- only check files |
447 |
– |
if ( -f $file ) { |
448 |
– |
$files{$file}=$ds->filedate($file); |
449 |
– |
# -- check to see if we have a new local copy |
450 |
– |
if ( ($file=~/\Q$self->{releasetop}\E/) && |
451 |
– |
($self->{releasetop} ne $self->{localtop}) ) { |
452 |
– |
($tempfile=$file)=~s/\Q$self->{releasetop}\E/$self->{localtop}/; |
453 |
– |
if ( -f $tempfile ) { |
454 |
– |
$files{$tempfile}=$files{$file}; |
455 |
– |
$file=$tempfile; |
456 |
– |
} |
457 |
– |
} |
458 |
– |
$moddate{$file}=(stat($file))[9]; |
459 |
– |
if ( $moddate{$file} != $files{$file} ) { |
460 |
– |
$self->verbose($file." changed"); |
461 |
– |
$date=$moddate{$file}-1; |
462 |
– |
$needsupdate=1; |
463 |
– |
} |
464 |
– |
} |
465 |
– |
} |
466 |
– |
} |
467 |
– |
# time stamp the product file to be older than the dependencies |
468 |
– |
if ( $needsupdate == 1 ) { # touch file into the past |
469 |
– |
my $newproductfile; |
470 |
– |
if ( $productfile!~/\Q$self->{localtop}\E/ ) { |
471 |
– |
if ( $productfile=~/\Q$self->{releasetop}\E/ ) { |
472 |
– |
($newproductfile=$productfile)=~ |
473 |
– |
s/\Q$self->{releasetop}\E/$self->{localtop}/; |
474 |
– |
$self->verbose("Copying $productfile to $newproductfile"); |
475 |
– |
copy($productfile,$newproductfile); |
476 |
– |
} |
477 |
– |
else { # assume no path to worry about |
478 |
– |
$newproductfile=$self->{localtop}."/".$ENV{workdir}. |
479 |
– |
"/".$productfile; |
480 |
– |
# -- make a local copy of the product file if not already here |
481 |
– |
my $oldproductfile=$self->{releasetop}."/".$ENV{workdir}. |
482 |
– |
"/".$productfile; |
483 |
– |
if ( ! -f $newproductfile ) { |
484 |
– |
if ( -f $oldproductfile ) { |
485 |
– |
$self->verbose("Copying $oldproductfile to $newproductfile"); |
486 |
– |
copy($oldproductfile,$newproductfile); |
487 |
– |
} |
488 |
– |
} |
489 |
– |
} |
490 |
– |
} |
491 |
– |
else { |
492 |
– |
$newproductfile=$productfile; |
318 |
|
} |
494 |
– |
if ( -f $newproductfile ) { |
495 |
– |
$self->verbose("Blasting $newproductfile to the past ($date)"); |
496 |
– |
# If the (local) productfile exists - make it older |
497 |
– |
utime($date,$date,$newproductfile); |
498 |
– |
} |
499 |
– |
else { |
500 |
– |
$self->verbose("SomeThing Wrong(?) with $newproductfile\n". |
501 |
– |
"RELEASETOP=".$self->{releasetop}."\n". |
502 |
– |
"LOCALTOP=".$self->{localtop}."\n". |
503 |
– |
"workdir=".$ENV{workdir}); |
504 |
– |
} |
319 |
|
} |
320 |
< |
else { |
321 |
< |
$self->verbose("No need to touch $productfile"); |
322 |
< |
} |
509 |
< |
} |
510 |
< |
undef $fh; |
320 |
> |
} |
321 |
> |
$ClassDir=~s/^\.\///; |
322 |
> |
return ( $Class, $ClassDir, $bf); |
323 |
|
} |