summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Buildsystem/perl_build.pm
diff options
context:
space:
mode:
authorModestas Vainius <modestas@vainius.eu>2009-03-23 21:32:43 +0200
committerJoey Hess <joey@gnu.kitenet.net>2009-04-10 16:03:38 -0400
commit51dea74baba625b8d63bbf7e19ad7e069d05ab14 (patch)
tree22553bf3688b23cf1e7efee4b6f26fddee2050c6 /Debian/Debhelper/Buildsystem/perl_build.pm
parent93cd875ba2e3ac9eda6adc31b4334d43ef718ea0 (diff)
Modular object-orientied buildsystem implementation.
Dh_Buildsystems: A manager module for buildsystem "plugins". It deals with the following tasks: * Handles common command line and environment options. As currently implemented by the patch they are: - DH_AUTO_BUILDSYSTEM envvar, -m/--build-system - disables autoguessing of the build system and allows the user to specify which one to use. - DH_AUTO_BUILDDIRECTORY envvar, -b/--build-directory - option to enable building outside source if supported by the buildsystem. User can specify the build directory name or let it be autogenerated (currently "obj-`dpkg_architecture('DEB_BUILD_GNU_TYPE')`" as per CDBS convention). Outside source building has an advantage of avoiding sourcedir pollution which the clean routine cannot deal with properly (at least common in cmake or autotools case). The "clean" is simple in such a case - just rm -rf builddir. - -l/--list - lists all buildsystems known to Dh_Buildsystems along with their descriptions. * Manages buildsystem plugins: - provides a way to list them and collect information about them. - provides a way to force loading & use of a specific buildsystem. - determines which build system is applicable to the source in question using common API (::is_buildable() method) exposed by each build system plugin. * @BUILDSYSTEMS variable contains all buildsystems known to the manager in the order of specialization. ----------------------------- ----------------------------- Dh_Buildsystem_Bases.pm: Contains a few classes which define a common interface for buildsystem plugins and implements handling of common features (i.e. two types of the build directory support, see below). Each specific build system plugin is supposed to inherit from any of these base classes or from another build system plugin. Currently implemented classes (packages) inside this .pm are: -- Dh_Buildsystem_Basic -- a basic class describing buildsystem plugin API. It stores build directory internally (can be retrieved with ::get_builddir() or path constructed using ::get_buildpath() (useful in is_buildable())) but does nothing with it. This class is intended to be inherited by the build system plugins which do not support outside-source tree building or there is no way to control this option (as far as tell, Build.PL is like this). It also describes common buildsystem plugin API and lays down the basic architecture: * ::configure/::build/::test/::install/::clean methods - they will be called to perform a respective action. These are wrapper methods by default and provide a place to implement common features specific the action itself (like creating build directory, see Dh_Buildsystem_Chdir::configure()) before calling real buildsystem specific implementation. Default implementations call the respective *_impl() method via another invoke_impl() wrapper. * ::configure_impl/::build_impl/::test_impl/::install_impl/::clean-impl methods - placeholders for the buildsystem specific implementation of the action (by overriding the methods as needed). Default implementations do nothing. * ::invoke_impl($method_name, @args) - a convenient way to hook in the code which needs to be run before or after respective ::*_impl() of *each* action (e.g. a simple case like setting envvar, see perl_build.pm). Default implementation calls $self->$method_name(@args) by default. So we have such a chain by default (and each can be overriden by any derived class): $self->$action() calls: $self->invoke_impl("${action}_impl", @_) calls: $self->$action_impl(@_) <- does buildsystem specific stuff here; -- Dh_Buildsystem_Option -- extends Dh_Buildsystem_Basic and adds support for passing build directory name via command line option to the build script (specific plugins should override ::get_builddir_option() method). ::invoke_impl() is overriden to pass value of $self->get_builddir_option() to each ::$action_impl() method (python distutils use such a way to set "build place", i.e. --build-place=builddir, see python_distutils.pm). -- Dh_Buildsystem_Chdir -- extends Dh_Buildsystem_Option. This class implements support for outside source building when you need to chdir to the building directory before building (like e.g. makefile.pm and its derivatives: autotools.pm and cmake.pm). All the code in there deals with chdir'ing/mkdir'ing to the build directory as needed before calling ::$action_impl() and finally going back. This is done by overriding ::invoke_impl() method. ----------------------------- ----------------------------- And finally we have build system specific plugins as Debian/Debhelper/Buildsystem/*.pm. Currently I have implemented 100% functionality of the former dh_auto_* tools inside these plugins + cmake support in the cmake.pm: $ ./dh_auto_configure -l autotools - support for building GNU Autotools based packages. cmake - support for building CMake based packages (outside-source tree only). perl_build - support for building Perl Build.PL based packages (in-source only). perl_makefile - support for building Perl Makefile.PL based packages (in-source only). python_distutils - support for building Python distutils based packages. makefile - support for building Makefile based packages (make && make install). Current plugin inheritance hierarchy is like this: Buildsystem::perl_build -> Dh_Buildsystem_Basic <- Buildsystem::perl_makefile ^ (maybe it should derive from ::perl_build?) | Buildsystem::python_distutils -> Dh_Buildsystem_Option ^ | Dh_Buildsystem_Chdir ^ | Buildsystem::makefile ^ ^ / \ Buildsystem::autotools Buildsystem::cmake Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Diffstat (limited to 'Debian/Debhelper/Buildsystem/perl_build.pm')
-rw-r--r--Debian/Debhelper/Buildsystem/perl_build.pm67
1 files changed, 67 insertions, 0 deletions
diff --git a/Debian/Debhelper/Buildsystem/perl_build.pm b/Debian/Debhelper/Buildsystem/perl_build.pm
new file mode 100644
index 00000000..74106d9b
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/perl_build.pm
@@ -0,0 +1,67 @@
+# A buildsystem plugin for handling Perl Build based projects.
+#
+# Copyright: © 2008-2009 Joey Hess
+# © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::perl_build;
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+use Debian::Debhelper::Dh_Buildsystem_Bases;
+use base 'Debian::Debhelper::Dh_Buildsystem_Basic';
+
+sub DESCRIPTION {
+ "support for building Perl Build.PL based packages (in-source only)"
+}
+
+sub is_buildable {
+ my ($self, $action) = @_;
+ my $ret = (-e "Build.PL");
+ if ($action ne "configure") {
+ $ret &= (-e "Build");
+ }
+ return $ret;
+}
+
+sub invoke_impl {
+ my $self=shift;
+ $ENV{MODULEBUILDRC} = "/dev/null";
+ return $self->SUPER::invoke_impl(@_);
+}
+
+sub new {
+ my $cls=shift;
+ my $self= $cls->SUPER::new(@_);
+ $self->enforce_in_source_building();
+ return $self;
+}
+
+sub configure_impl {
+ my $self=shift;
+ $ENV{PERL_MM_USE_DEFAULT}=1; # Module::Build can also use this.
+ doit("perl", "Build.PL", "installdirs=vendor", @_);
+}
+
+sub build_impl {
+ my $self=shift;
+ doit("perl", "Build", @_);
+}
+
+sub test_impl {
+ my $self=shift;
+ doit(qw/perl Build test/, @_);
+}
+
+sub install_impl {
+ my $self=shift;
+ my $destdir=shift;
+ doit("perl", "Build", "install", "destdir=$destdir", "create_packlist=0", @_);
+}
+
+sub clean_impl {
+ my $self=shift;
+ doit("perl", "Build", "--allow_mb_mismatch", 1, "distclean", @_);
+}
+
+1;