1 |
williamc |
1.1 |
package BuildSetup;
|
2 |
williamc |
1.2 |
require 5.001;
|
3 |
williamc |
1.1 |
require Exporter;
|
4 |
|
|
@ISA=qw(Exporter);
|
5 |
|
|
@EXPORT=qw(BuildSetup);
|
6 |
|
|
use Interface;
|
7 |
|
|
use BuildFile;
|
8 |
williamc |
1.2 |
use Utilities::AddDir;
|
9 |
williamc |
1.1 |
|
10 |
|
|
sub BuildSetup {
|
11 |
|
|
my $THISDIR=shift;
|
12 |
|
|
my @Targets=@_;
|
13 |
|
|
my $DefaultBuildFile="";
|
14 |
|
|
$Class="";
|
15 |
|
|
|
16 |
|
|
# Create working directory
|
17 |
|
|
chdir $ENV{LOCALTOP};
|
18 |
williamc |
1.3 |
AddDir::adddir($ENV{INTwork}."/".$THISDIR);
|
19 |
williamc |
1.1 |
|
20 |
|
|
GetClass($THISDIR);
|
21 |
williamc |
1.4 |
#print "Class = $Class\n";
|
22 |
williamc |
1.5.2.1 |
#print "ClassDir = $ClassDir\n";
|
23 |
williamc |
1.1 |
if ( grep /none/i , @BuildFile::groups) {
|
24 |
|
|
print "Nothing to be done - empty group\n";
|
25 |
|
|
exit
|
26 |
|
|
}
|
27 |
|
|
shift;
|
28 |
|
|
|
29 |
|
|
# set up the workdir variable
|
30 |
|
|
$ENV{workdir}=$ENV{INTwork}."/".$ClassDir;
|
31 |
|
|
$fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir};
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
# set up projdeps variable
|
35 |
|
|
$projectfile=$ENV{projconfigdir}."/External_Dependencies";
|
36 |
|
|
if ( -e $ENV{LOCALTOP}."/".$projectfile ) {
|
37 |
|
|
$ENV{projdeps}=$ENV{LOCALTOP}."/".$projectfile;
|
38 |
|
|
}
|
39 |
|
|
elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) {
|
40 |
|
|
$ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile;
|
41 |
|
|
}
|
42 |
|
|
else {
|
43 |
|
|
print "Warning : Unable to find $projectfile\n";
|
44 |
|
|
}
|
45 |
|
|
# Assume always overrides for now : TODO add merge
|
46 |
|
|
if ( $DefaultBuildFile eq "" ) {
|
47 |
|
|
# Map Relevant makefile classmakefile directory
|
48 |
|
|
$classmakefile=$ENV{projconfigdir}."/".$Class."_makefile.mk";
|
49 |
|
|
if ( -e $ENV{LOCALTOP}."/".$classmakefile ) {
|
50 |
|
|
$ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile;
|
51 |
|
|
}
|
52 |
|
|
elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) {
|
53 |
|
|
$ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile;
|
54 |
|
|
}
|
55 |
|
|
else {
|
56 |
|
|
print "\nUnable to locate $classmakefile\n";
|
57 |
|
|
print " Not in $ENV{LOCALTOP}\n";
|
58 |
|
|
print " Not in $ENV{RELEASETOP}\n";
|
59 |
|
|
exit 1;
|
60 |
|
|
}
|
61 |
|
|
$DefaultBuildFile=$ENV{classmakefile}; # TODO - only for override
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
$ENV{ClassDir}=$ClassDir;
|
65 |
williamc |
1.5.2.3 |
$ENV{Class}=$Class;
|
66 |
williamc |
1.1 |
$ENV{DefaultBuildFile}=$DefaultBuildFile;
|
67 |
|
|
|
68 |
|
|
chdir $fullworkdir || die "Unable to enter working directory $!";
|
69 |
|
|
|
70 |
williamc |
1.5.2.2 |
# Set up some other useful variables fo the Build
|
71 |
|
|
# list of directories available
|
72 |
|
|
opendir IDR, "$ENV{LOCALTOP}/$THISDIR";
|
73 |
|
|
@allfiles= grep !/^\.\.?$/, readdir IDR;
|
74 |
|
|
foreach $file ( @allfiles ) {
|
75 |
|
|
if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) { # only add if its a directory
|
76 |
|
|
$ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file;
|
77 |
|
|
}
|
78 |
|
|
else {
|
79 |
|
|
$ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file;
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
williamc |
1.5.2.4 |
$targetnumber=$#Targets;
|
83 |
|
|
foreach $word ( @Targets ) {
|
84 |
|
|
if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target
|
85 |
|
|
$targetnumber--;
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
williamc |
1.5.2.2 |
|
89 |
williamc |
1.1 |
# If not specified default to the class name target
|
90 |
williamc |
1.5.2.4 |
if ( $targetnumber == -1 ) {
|
91 |
williamc |
1.5.2.5 |
push @Targets,$Class;
|
92 |
williamc |
1.1 |
}
|
93 |
|
|
$ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk";
|
94 |
williamc |
1.5 |
system("gmake","--no-print-directory","-r","-j 1","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",@Targets);
|
95 |
williamc |
1.1 |
}
|