ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildSetup.pm
Revision: 1.1.2.2
Committed: Wed Apr 19 14:14:32 2000 UTC (25 years ago) by williamc
Content type: text/plain
Branch: V0_9branch
Changes since 1.1.2.1: +7 -8 lines
Log Message:
New ToolBox Regime - no clientsettings anymore

File Contents

# Content
1 #
2 #
3 # Interface
4 # ---------
5 # new() : 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 #
10
11 package BuildSystem::BuildSetup;
12 require 5.004;
13 use Utilities::Verbose;
14 use Utilities::SCRAMUtils;
15 use BuildSystem::BuildFile;
16 use Utilities::AddDir;
17 @ISA=qw(Utilities::Verbose);
18
19 sub new {
20 my $class=shift;
21 my $self={};
22 bless $self,$class;
23 $self->init();
24 return $self;
25 }
26
27 sub init {
28 my $self=shift;
29 $self->{toolbox}=BuildSystem::ToolBox->new();
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 my $clientfile="$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings";
39 my $clientreq="$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/".
40 "clientsettings_reqs";
41 # -- do we need to rebuild?
42 if ( SCRAMUtils::dated($outfile,$depfile, $clientfile,$clientreq) ) {
43 print "Configuring Local Area\n";
44 # -- open output file
45 my $fout=FileHandle->new();
46 $fout->open(">".$outfile) or die "Unable to open $outfile for output".
47 $!."\n";
48
49 # -- print out tool/ version info
50 my ($tool,$toolobj,$f,$val,$version);
51 foreach $toolpair ( $self->{toolbox}->tools() ) {
52 $tool=$$toolpair[0];
53 $version=$$toolpair[1];
54 # default versions
55 print $fout "ifdef $tool\n".$tool."_V_".$version."=true\nendif\n";
56 $toolobj=$self->{toolbox}->gettool($tool,$version);
57 # -- externals
58 @deps=$toolobj->getfeature("_externals");
59 foreach $d ( @deps ) {
60 print $fout "ifdef ".$tool."_V_".$version."\n $d=true\nendif\n";
61 }
62 # -- tool info
63 print $fout "ifdef ".$tool."_V_".$version."\n";
64 foreach $f ( $toolobj->features() ) {
65 foreach $val ( $toolobj->getfeature($f) ) {
66 print $fout "\t".$f." += ".$val."\n";
67 }
68 }
69 print $fout "endif\n";
70 }
71 # some addittional processing of specific vars
72 print $fout 'INCLUDEPATH+=$(addprefix -I,$(INCLUDE))'."\n";
73 print $fout 'LDFLAGS+=$(addprefix -L,$(LIBDIR))'."\n";
74 print $fout 'CPPFLAGS+=$(addprefix -D,$(CPPDEFINES))'."\n";
75 print $fout 'lib+=$(extralib)'."\n";
76 print $fout 'LDLIBS+=$(addprefix -l,$(lib))'."\n";
77 print $fout 'LDLIBS+=$(addprefix -l,$(REQUIRES))'."\n";
78
79 undef $fout;
80 }
81 }
82
83 sub BuildSetup {
84 my $self=shift;
85 my $THISDIR=shift;
86 my @Targets=@_;
87 my $DefaultBuildFile="";
88 my $Class="";
89
90 # -- Create working directory
91 chdir $ENV{LOCALTOP};
92 AddDir::adddir($ENV{INTwork}."/".$THISDIR);
93
94 my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR);
95 $self->verbose("Class = $Class");
96 $self->verbose("ClassDir = $ClassDir");
97
98 if ( $bf->ignore() ) {
99 print "Nothing to be done - empty group\n";
100 exit;
101 }
102 shift;
103 $self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile");
104
105 # set up the workdir variable
106 $ENV{workdir}=$ENV{INTwork}."/".$ClassDir;
107 my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir};
108
109 # set up projdeps variable
110 my $projectfile=$ENV{projconfigdir}."/External_Dependencies";
111 if ( -e $ENV{LOCALTOP}."/".$projectfile ) {
112 $ENV{projdeps}=$ENV{LOCALTOP}."/".$projectfile;
113 }
114 elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) {
115 $ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile;
116 }
117 else {
118 print "Warning : Unable to find $projectfile\n";
119 }
120 if ( $DefaultBuildFile eq "" ) {
121 # Map Relevant makefile classmakefile directory
122 my $classmakefile=$ENV{projconfigdir}."/".$Class."_makefile.mk";
123 if ( -e $ENV{LOCALTOP}."/".$classmakefile ) {
124 $ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile;
125 }
126 elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) {
127 $ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile;
128 }
129 else {
130 print "\nUnable to locate $classmakefile\n";
131 print " Not in $ENV{LOCALTOP}\n";
132 print " Not in $ENV{RELEASETOP}\n";
133 exit 1;
134 }
135 $DefaultBuildFile=$ENV{classmakefile}; # TODO - only for override
136 }
137
138 $ENV{ClassDir}=$ClassDir;
139 $ENV{Class}=$Class;
140 $ENV{DefaultBuildFile}=$DefaultBuildFile;
141
142 chdir $fullworkdir || die "Unable to enter working directory $!";
143
144 # Set up some other useful variables fo the Build
145 # list of directories available
146 opendir IDR, "$ENV{LOCALTOP}/$THISDIR";
147 @allfiles= grep !/^\.\.?$/, readdir IDR;
148 foreach $file ( @allfiles ) {
149 if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) { # only add if its a directory
150 $ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file;
151 }
152 else {
153 $ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file;
154 }
155 }
156 $targetnumber=$#Targets;
157 foreach $word ( @Targets ) {
158 if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target
159 $targetnumber--;
160 }
161 else {
162 $ENV{"MAKETARGET_".$word}=$word;
163 }
164 }
165
166 # If not specified default to the class name target
167 if ( $targetnumber == -1 ) {
168 push @Targets,$Class;
169 }
170
171 $ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk";
172
173 $SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk";
174 if ( -f $SCRAM_GROUPSDIR ) {
175 $ENV{SCRAM_GROUPSDIR}=$SCRAM_GROUPSDIR;
176 }
177
178 # Do a datestamp check so that make will build files that have changed
179 # rather than just those which are older than their dependencies
180 # The main build here
181 $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config);
182 $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets);
183 return $rv/256; # return the exit status of gmake
184 }
185
186 sub getclass {
187 my $self=shift;
188 my $dirname = shift;
189 my $Class="DEFAULT";
190 my $ClassDir="";
191
192 #return if $dirname eq "";
193 @DIRA=split /\//, $dirname;
194
195 $thispath=".";
196 # bootstrap from project buildfile if it exists
197 my $bf=BuildSystem::BuildFile->new($self->{toolbox});
198 $bf->CheckBuildFile($ENV{projconfigdir});
199
200 my @ClassPaths=split /:/, $bf->BlockClassPath();
201 foreach $BClassPath ( @ClassPaths ) {
202 next if ( $BClassPath eq "");
203 push @LoBCA, [ split /\//, $BClassPath ];
204 }
205 for ( $i=0; $i<=$#DIRA; $i++ ) {
206 $thispath=$thispath."/".$DIRA[$i];
207 if ( ($ClassName=$bf->CheckBuildFile($thispath)) ne "" ) {
208 $Class=$ClassName;
209 $ClassDir=$thispath;
210 }
211 # TODO --- Must test against position of last new BlockCaseA
212 # Need to reset array LoBCA to the New BlockPath
213 # - merge and replace options
214 #
215 else {
216 foreach $BlockClassA ( @LoBCA ) {
217 if ( $$BlockClassA[0]=~/^$DIRA[$i]\+/ ) {
218 $$BlockClassA[0]=~s/^$DIRA[$i]//;
219 }
220 if ( $$BlockClassA[0]=~/^\+/ ) {
221 ($Class=$$BlockClassA[0])=~s/^\+//;
222 $ClassDir=$thispath;
223 shift @$BlockClassA;
224 }
225 else {
226 @$BlockClassA=();
227 }
228 }
229 }
230 }
231 $ClassDir=~s/^\.\///;
232 return ( $Class, $ClassDir, $bf);
233 }