-# Defines debhelper buildsystem class interface and implementation
+# Defines debhelper build system class interface and implementation
# of common functionality.
#
# Copyright: © 2008-2009 Modestas Vainius
use Debian::Debhelper::Dh_Lib;
# Cache DEB_BUILD_GNU_TYPE value. Performance hit of multiple
-# invocations is noticable when listing buildsystems.
+# invocations is noticable when listing build systems.
our $DEB_BUILD_GNU_TYPE = dpkg_architecture_value("DEB_BUILD_GNU_TYPE");
# Build system name. Defaults to the last component of the class
return $1;
}
else {
- error("ınvalid buildsystem class name: $class");
+ error("ınvalid build system class name: $class");
}
}
my $curdir = Cwd::getcwd();
my $abspath = Cwd::abs_path($opts{sourcedir});
if (! -d $abspath || $abspath !~ /^\Q$curdir\E/) {
- error("Invalid or non-existing path to the source directory: ".$opts{sourcedir});
+ error("invalid or non-existing path to the source directory: ".$opts{sourcedir});
}
$this->{sourcedir} = File::Spec->abs2rel($abspath, $curdir);
}
}
}
-# This instance method is called to check if the build system is capable
+# This instance method is called to check if the build system is able
# to auto build a source package. Additional argument $step describes
# which operation the caller is going to perform (either configure,
# build, test, install or clean). You must override this method for the
# build system module to be ever picked up automatically. This method is
# used in conjuction with @Dh_Buildsystems::BUILDSYSTEMS.
#
-# This method is supposed to be called with source root directory being
-# working directory. Use $this->get_buildpath($path) method to get full
-# path to the files in the build directory.
+# This method is supposed to be called inside the source root directory.
+# Use $this->get_buildpath($path) method to get full path to the files
+# in the build directory.
sub check_auto_buildable {
my $this=shift;
my ($step) = @_;
# Derived class can call this method in its constructor to enforce
# out of source building even if the user didn't request it. However,
-# if $builddir is specified, accept it even if it matches the source
-# directory (soft mode).
+# if 'builddir' named parameter is passed, accept its value as the
+# build directory even if it matches the source directory (meaning out
+# of source is only prefered to in source, not enforced).
sub enforce_out_of_source_building {
- my ($this, $builddir) = @_;
+ my $this=shift;
+ my %args=@_;
if (!defined $this->get_builddir()) {
- $this->_set_builddir($builddir);
- if (!defined $this->get_builddir() && !$builddir) {
+ $this->_set_builddir($args{builddir});
+ if (!defined $this->get_builddir() && !$args{builddir}) {
# If we are here, DEFAULT_BUILD_DIRECTORY matches
# the source directory, building might fail.
error("default build directory is the same as the source directory." .
}
}
-# Changes working directory to the source directory (if needed)
+# Changes working directory to the source directory (if needed),
# calls doit(@_) and changes working directory back to the top
# directory.
sub doit_in_sourcedir {
my $this=shift;
if ($this->get_sourcedir() ne '.') {
- my $sourcedir = get_sourcedir();
+ my $sourcedir = $this->get_sourcedir();
my $curdir = Cwd::getcwd();
$this->_cd($sourcedir);
doit(@_);
# If build directory does not exist, nothing is done and 0 is returned.
sub rmdir_builddir {
my $this=shift;
+ my $only_empty=shift;
if ($this->get_builddir()) {
my $buildpath = $this->get_buildpath();
if (-d $buildpath && ! $dh{NO_ACT}) {
- doit("rm", "-rf", $buildpath);
- # If build directory had 2 or more levels, delete empty
- # parent directories until the source directory level.
my @spdir = File::Spec->splitdir($this->get_build_rel2sourcedir());
my $peek;
- pop @spdir;
+ if (!$only_empty) {
+ doit("rm", "-rf", $buildpath);
+ pop @spdir;
+ }
+ # If build directory had 2 or more levels, delete empty
+ # parent directories until the source directory level.
while (($peek=pop(@spdir)) && $peek ne '.' && $peek ne '..') {
last if ! rmdir($this->get_sourcepath(File::Spec->catdir(@spdir, $peek)));
}
# In case of failure, the method may just error() out.
#
# These methods should be overriden by derived classes to
-# implement buildsystem specific steps needed to build the
+# implement build system specific steps needed to build the
# source. Arbitary number of custom step arguments might be
# passed. Default implementations do nothing.
sub configure {
my $this=shift;
}
-1;
+1