| 1 | package Module::Release::ModuleBuild; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use base qw(Exporter Module::Release); | ||
| 7 | our @EXPORT = qw(clean build_makefile); | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Module::Release::ModuleBuild - grok Module::Build when using Module::Release | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | In F<.releaserc> | ||
| 16 | |||
| 17 | release_subclass Module::Release::Build | ||
| 18 | |||
| 19 | In your subclasses of Module::Release: | ||
| 20 | |||
| 21 | use base qw(Module::Release::Build); | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | Module::Release::ModuleBuild subclasses Module::Release, and rewrites | ||
| 26 | some methods so that modules that build using Module::Build (with a | ||
| 27 | Build.PL, and so on) can be released using Module::Release. | ||
| 28 | |||
| 29 | These methods are B<automatically> exported in to the callers namespace | ||
| 30 | using Exporter. | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | sub clean { | ||
| 35 | my $self = shift; | ||
| 36 | |||
| 37 | if(-e 'Build') { | ||
| 38 | print "Cleaning directory... "; | ||
| 39 | |||
| 40 | $self->run("$self->{perl} Build realclean 2>&1"); | ||
| 41 | print "done\n"; | ||
| 42 | } else { | ||
| 43 | $self->SUPER::clean(); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | sub build_makefile { | ||
| 48 | my $self = shift; | ||
| 49 | |||
| 50 | # If Build.PL exists then assume the module uses Module::Build. If | ||
| 51 | # this is the case, "make <anything>" should be "perl Build <anything>", | ||
| 52 | # and the initial "perl Makefile.PL" becomes "perl Build.PL" | ||
| 53 | # | ||
| 54 | # In addition, many of the methods in Module::Release check for the | ||
| 55 | # existence of Makefile.PL, even if they don't do anything with it. | ||
| 56 | # So create a dummy Makefile.PL if one doesn't exist, to keep them | ||
| 57 | # quiet. | ||
| 58 | # | ||
| 59 | # Otherwise, fall back to the default behaviour | ||
| 60 | if(-e 'Build.PL') { | ||
| 61 | print "Recreating build file... "; | ||
| 62 | $self->{make} = 'perl Build'; | ||
| 63 | $self->run("$self->{perl} Build.PL 2>&1"); | ||
| 64 | print "done\n"; | ||
| 65 | |||
| 66 | if(! -e 'Makefile.PL') { | ||
| 67 | print "Creating dummy Makefile.PL... "; | ||
| 68 | open(F, '> Makefile.PL') or die "open() failed: $!\n"; | ||
| 69 | print F "# This is an automatically created file\n"; | ||
| 70 | close(F); | ||
| 71 | print "done\n"; | ||
| 72 | } | ||
| 73 | } else { | ||
| 74 | $self->SUPER::build_makefile(); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Nik Clayton <nik@FreeBSD.org> | ||
| 81 | |||
| 82 | Copyright 2004 Nik Clayton. All Rights Reserved. | ||
| 83 | |||
| 84 | This program is free software; you can redistribute it | ||
| 85 | and/or modify it under the same terms as Perl itself. | ||
| 86 | |||
| 87 | =head1 BUGS | ||
| 88 | |||
| 89 | None known. | ||
| 90 | |||
| 91 | Bugs should be reported to me via the CPAN RT system. | ||
| 92 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module::Release::Extras>. | ||
| 93 | |||
| 94 | =head1 SEE ALSO | ||
| 95 | |||
| 96 | Module::Release | ||
| 97 | |||
| 98 | =cut | ||
| 99 | |||
| 100 | 1; |