summaryrefslogtreecommitdiff
path: root/Debian
diff options
context:
space:
mode:
authorModestas Vainius <modestas@vainius.eu>2009-06-11 10:54:55 +0300
committerModestas Vainius <modestas@vainius.eu>2009-06-11 11:04:47 +0300
commit6f84d7f67943b67d2630985722085c7b4132ce0a (patch)
treeccee58b960829ea6d2f50142bfe0a19df96d0377 /Debian
parent23d1e4255bf7ddfadf5e5d3eaa40505e1df4dfc5 (diff)
Refactor build directory setting into separate method and solve a few bugs.
* Move setting of new build directory from constructor to _set_builddir() method including detection if directory (current or source) it should be relative to. * Even if a new build directory was specified, detect if it matches the source directory and unset it in such a case. * Use _set_builddir() in enforce_out_of_source_tree() methods. Previous implementation didn't handle default build directory properly (i.e. relativeness to current or source directory). Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Diffstat (limited to 'Debian')
-rw-r--r--Debian/Debhelper/Buildsystem.pm54
1 files changed, 38 insertions, 16 deletions
diff --git a/Debian/Debhelper/Buildsystem.pm b/Debian/Debhelper/Buildsystem.pm
index 6842e348..f8028619 100644
--- a/Debian/Debhelper/Buildsystem.pm
+++ b/Debian/Debhelper/Buildsystem.pm
@@ -77,20 +77,7 @@ sub new {
$this->{sourcedir} = File::Spec->abs2rel($abspath, $curdir);
}
if (exists $opts{builddir}) {
- if ($opts{builddir}) {
- if ($opts{builddir} =~ m!^\./(.*)!) {
- # Specified as relative to the current directory
- $this->{builddir} = $1;
- }
- else {
- # Specified as relative to the source directory
- $this->{builddir} = $this->_canonpath($this->get_sourcepath($opts{builddir}));
- }
- }
- else {
- # Relative to the source directory by default
- $this->{builddir} = $this->get_sourcepath($this->DEFAULT_BUILD_DIRECTORY());
- }
+ $this->_set_builddir($opts{builddir});
}
if (exists $opts{build_step}) {
if (defined $opts{build_step}) {
@@ -103,6 +90,36 @@ sub new {
return $this;
}
+# Private method to set a build directory. If undef, use default.
+# Do $this->{builddir} = undef or pass $this->get_sourcedir() to
+# unset the build directory.
+sub _set_builddir {
+ my $this=shift;
+ my $builddir=shift;
+ if ($builddir) {
+ if ($builddir =~ m!^\./(.*)!) {
+ # Specified as relative to the current directory
+ $this->{builddir} = $1;
+ }
+ else {
+ # Specified as relative to the source directory
+ $this->{builddir} = $this->get_sourcepath($builddir);
+ }
+ }
+ else {
+ # Relative to the source directory by default
+ $this->{builddir} = $this->get_sourcepath($this->DEFAULT_BUILD_DIRECTORY());
+ }
+
+ # Canonicalize. If build directory ends up the same as source directory, drop it
+ if (defined $this->{builddir}) {
+ $this->{builddir} = $this->_canonpath($this->{builddir});
+ if ($this->{builddir} eq $this->get_sourcedir()) {
+ $this->{builddir} = undef;
+ }
+ }
+}
+
# Test is_buildable flag of the object.
sub is_buildable {
my $this=shift;
@@ -143,8 +160,13 @@ sub enforce_in_source_building {
# out of source building even if the user didn't request it.
sub enforce_out_of_source_building {
my ($this, $builddir) = @_;
- if (!defined $this->{builddir}) {
- $this->{builddir} = ($builddir && $builddir ne ".") ? $builddir : $this->DEFAULT_BUILD_DIRECTORY();
+ if (!defined $this->get_builddir()) {
+ $this->_set_builddir($builddir);
+ # The build directory might have been dropped if it matched the
+ # source directory. Just set to default in this case.
+ if (!defined $this->get_builddir()) {
+ $this->_set_builddir();
+ }
}
}