Module::Build

And The "Classic" Build Systems

Joel Berger

In the beginning there was ExtUtils::MakeMaker

  • Generates a Makefile for use by make(1)
    • Requires external tooling
    • Requires knowledge of make (and some insane Perl) in order to extend
  • Mentioned here for completeness

Why use make(1) when we have a glue language already?

And then there was Module::Build

  • Common usage much like EUMM
  • No need for external tools!
  • Easy to extend by subclassing
    • I am the author of a few on CPAN, including Alien::Base::ModuleBuild

So how does it work?

The Build.PL file


use strict; use warnings;
use Module::Build 0.3601;

my $builder = Module::Build->new(
  module_name => 'Tie::Array::CSV',
  dist_author => 'Joel Berger',
  license => 'perl',
  requires => {
    'perl' => 5.006001,
    'Tie::File' => 0,
    'Text::CSV' => 0,
  },
  configure_requires => {
    'Module::Build' => 0.3601,
  },
  meta_merge => {
    resources  => {
      repository => "http://github.com/jberger/Tie-Array-CSV",
      bugtracker => "http://github.com/jberger/Tie-Array-CSV/issues",
    },
  }
);

$builder->create_build_script;

    

ex/Build.PL

Using the script


# prepare release
$ perl Build.PL
$ perl Build manifest
$ perl Build test
$ perl Build dist
$ perl Build distcheck
$ perl Build disttest
# release
$ perl Build realclean
    

Using the script (extended)


$ perl-reversion -bump # from Perl::Version
$ podselect path/to/main.pm > README.pod
$ perl Build.PL
$ perl Build manifest
$ perl Build test
$ perl Build dist
$ perl Build distcheck
$ perl Build disttest
$ mojo cpanify -u JBERGER -p PASSWORD my-dist.tar.gz
$ perl Build realclean
    

Recommendations

  • Don't keep meta or manifest files in VCS
  • Do keep MANIFEST.SKIP and .gitignore in VCS
  • Include README.pod in MANIFEST.SKIP
  • Good templates for MANIFEST.SKIP and .gitignore are easily available

Dispelling some misconceptions

  • Module::Build is NOT deprecated!
  • Removal from the core is primarily because it can be
    • meta files can specify configure requirements
    • modern build chains know how to handle those requirements

Final Thoughts

  • Although some people see this process as "too manual"
  • It's good to know the underlying system
  • You control the process, not some black-box plugin
  • Much easier for contributors to step in quickly

Module::Build::Tiny

  • A minimal reimplentation of the build-phase parts of Module::Build
  • REALLY spartan
  • Mostly for use by author tool like Dist::Zilla ... or ...

App::ModuleBuildTiny

  • A minimal author tool, companion to MBT
  • Still fairly spartan and opinionated, but useful
  • Perhaps not quite enough/ready for beginners