1 |
#
|
2 |
# Build.pm
|
3 |
#
|
4 |
# Originally Written by Christopher Williams
|
5 |
#
|
6 |
# Description
|
7 |
#
|
8 |
# Interface
|
9 |
# ---------
|
10 |
# new(ConfigArea) : A new Build object
|
11 |
# build(dir,[@targets]) : Build relevant target for a given directory
|
12 |
# dir relative to top. Returns a BuildReport
|
13 |
|
14 |
package BuildSystem::Build;
|
15 |
use BuildSystem::BuildReport;
|
16 |
use BuildSystem::BuildSetup;
|
17 |
use Utilities::Verbose;
|
18 |
require 5.004;
|
19 |
@ISA=qw(Utilities::Verbose);
|
20 |
|
21 |
sub new {
|
22 |
my $class=shift;
|
23 |
my $self={};
|
24 |
bless $self, $class;
|
25 |
$self->{area}=shift;
|
26 |
$self->{area}->copyenv(\%ENV);
|
27 |
$ENV{LOCALTOP}=$self->{area}->location();
|
28 |
|
29 |
# -- set RELEASTOP
|
30 |
my $rarea=$self->{area}->linkarea();
|
31 |
if ( ! defined $rarea ) {
|
32 |
$ENV{RELEASETOP}=$ENV{LOCALTOP};
|
33 |
}
|
34 |
else {
|
35 |
$ENV{RELEASETOP}=$rarea->location();
|
36 |
}
|
37 |
|
38 |
$self->verbose("LOCALTOP=".$ENV{LOCALTOP});
|
39 |
$self->verbose("RELEASETOP=".$ENV{RELEASETOP});
|
40 |
return $self;
|
41 |
}
|
42 |
|
43 |
sub build {
|
44 |
my $self=shift;
|
45 |
my $dir=shift;
|
46 |
|
47 |
# -- set up a report
|
48 |
my $report=BuildSystem::BuildReport->new();
|
49 |
|
50 |
# -- interface with old system
|
51 |
my $fulldir=$self->{area}->location()."/".$dir;
|
52 |
if ( ! -d $fulldir ) {
|
53 |
$report->error("$fulldir does not exist");
|
54 |
$report->status(1); # set to fail
|
55 |
}
|
56 |
else {
|
57 |
chdir $fulldir;
|
58 |
# -- initialise BuildSystem if we dont already have it
|
59 |
if ( ! defined $self->{bs} ) {
|
60 |
$self->{bs}=BuildSystem::BuildSetup->new($self->{area});
|
61 |
$self->{bs}->verbosity(1);
|
62 |
}
|
63 |
$self->verbose("Calling build module with $dir, @_");
|
64 |
my $rv=$self->{bs}->BuildDir($dir,@_);
|
65 |
$report->status($rv);
|
66 |
}
|
67 |
return $report;
|
68 |
}
|