Skip to content

Commit

Permalink
Switched to ExtUtils::MakeMaker
Browse files Browse the repository at this point in the history
This should take care of robertkrimen#2.
  • Loading branch information
Chris White committed Jun 7, 2019
1 parent 058b7bf commit 202b4d5
Show file tree
Hide file tree
Showing 21 changed files with 251 additions and 2,628 deletions.
4 changes: 0 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ build_script:
# Grab the dependencies
- cpanm --installdeps --notest --verbose .

# Need . for M::I
- cmd: set PERL5LIB=.
- sh: export PERL5LIB=.

# Build it
- perl Makefile.PL
- cmd: gmake
Expand Down
5 changes: 5 additions & 0 deletions .cvsignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ pm_to_blib*
.lwpcookies
Text-Chomped-*
cover_db
MYMETA.*
*.bak
*.swp
~*
*~
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ pm_to_blib*
Text-Chomped-*
cover_db
MYMETA.*
*.bak
*.swp
~*
*~
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ perl:
- "5.10"
- "5.08"

env:
# Because Text-Chomped uses M::I and needs `use inc:...` to work
- PERL5LIB=.

install:
- cpanm ExtUtils::MakeMaker
# Because EUMM v6.66 doesn't seem to generate the correct MYMETA.json,
# causing lib::relative not to be loaded as a dependency. See, e.g.,
# https://travis-ci.org/cxw42/Class-Tiny-ConstrainedAccessor/jobs/535823908
- perl -V
- cpanm --with-recommends --verbose --installdeps --notest .
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
0.02 2019-06-07
- New code to support using `$_` if no argument is provided
(GH-1, RT#129721)
- Changed build system to ExtUtils::MakeMaker to support
CI builds (GH-2)

0.01 Tuesday May 26 15:06:57 PDT 2009:
- Initial release (and hopefully final)
23 changes: 0 additions & 23 deletions GNUmakefile

This file was deleted.

19 changes: 5 additions & 14 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
.editorconfig
Changes
MANIFEST
lib/Text/Chomped.pm
Makefile.PL
MANIFEST
MANIFEST.SKIP
README
inc/Module/AutoInstall.pm
inc/Module/Install.pm
inc/Module/Install/AutoInstall.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/Text/Chomped.pm
META.yml
t/00-load.t
t/01-basic.t
t/02-topic.t
t/release/boilerplate.t
t/release/pod-coverage.t
t/release/pod.t
72 changes: 72 additions & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
\.appveyor\.yml
\.travis\.yml
\.screenrc
Text-Chomped
META_new

#!start included /usr/share/perl5/5.26/ExtUtils/MANIFEST.SKIP
# Avoid version control files.
\bRCS\b
\bCVS\b
\bSCCS\b
,v$
\B\.svn\b
\B\.git\b
\B\.gitignore\b
\b_darcs\b
\B\.cvsignore$

# Avoid VMS specific MakeMaker generated files
\bDescrip.MMS$
\bDESCRIP.MMS$
\bdescrip.mms$

# Avoid Makemaker generated and utility files.
\bMANIFEST\.bak
\bMakefile$
\bblib/
\bMakeMaker-\d
\bpm_to_blib\.ts$
\bpm_to_blib$
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
\b_eumm/ # 7.05_05 and above

# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/
\bBuild.bat$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$

# and Module::Build::Tiny generated files
\b_build_params$

# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$
\.tmp$
\.#
\.rej$
\..*\.sw.?$

# Avoid OS-specific files/dirs
# Mac OSX metadata
\B\.DS_Store
# Mac OSX SMB mount metadata files
\B\._

# Avoid Devel::Cover and Devel::CoverX::Covered files.
\bcover_db\b
\bcovered\b

# Avoid prove files
\B\.prove$

# Avoid MYMETA files
^MYMETA\.
#!end included /usr/share/perl5/5.26/ExtUtils/MANIFEST.SKIP

190 changes: 156 additions & 34 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,41 +1,163 @@
use inc::Module::Install;

name 'Text-Chomped';
all_from 'lib/Text/Chomped.pm';
author 'Robert Krimen <rkrimen@cpan.org>';
license 'perl';

resources repository => 'http://github.com/robertkrimen/Text-Chomped/tree/master';

{
require ExtUtils::MakeMaker;
use strict;
no strict 'refs';

my $libscan = \&{"ExtUtils::MM_Any::libscan"};
*{"ExtUtils::MM_Any::libscan"} = sub {
return '' unless $libscan->(@_);
return '' if $_[1] =~ /\.sw[p-z]$/;
return $_[1];
};
}
use 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
use File::Spec;
use Config;

{
map { my ($pk, $vr) = split m/\s/; build_requires $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
Test::Most
_END_
my $VERSION_FROM = File::Spec->catfile(qw(lib Text Chomped.pm));
my $IS_TRIAL = check_trial();
my $secure_perl_path = get_perl_filename();
my @provides = ();

map { my ($pk, $vr) = split m/\s/; requires $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
_END_
}
# Check if this is a TRIAL version {{{1
sub check_trial {
TRIAL: {
# Get the VERSION line
open my $fd, '<', $VERSION_FROM or last TRIAL;
my $linetext;
while(<$fd>) {
next unless /VERSION/;
$linetext = $_;
last;
}
close $fd;
return !!($linetext =~ /\bTRIAL\b/);
}
return 0;
} #check_trial()

if (-e 'inc/.author') {
my $all_from = join '/', 'lib', split m/-/, name . '.pm';
`perldoc -tF $all_from > README` if ! -e 'README' || (stat $all_from)[9] > (stat 'README')[9];
}
# }}}1
# Module metadata {{{1
eval {
require Module::Metadata;
@provides =
(provides => Module::Metadata->provides(version => '2', dir => 'lib'));
# Thanks to https://stackoverflow.com/a/28928985/2877364 by LEONT
# for suggesting Module::Metadata.
};

# }}}1
# Get the filename of the Perl interpreter running this. {{{1
# Modified from perlvar.
# The -x test is for cygwin or other systems where $Config{perlpath} has no
# extension and $Config{_exe} is nonempty. E.g., symlink perl->perl5.10.1.exe.
# There is no "perl.exe" on such a system.
sub get_perl_filename {
my $secure_perl_path = $Config{perlpath};
if ($^O ne 'VMS') {
$secure_perl_path .= $Config{_exe}
unless (-x $secure_perl_path) ||
($secure_perl_path =~ m/$Config{_exe}$/i);
}
return $secure_perl_path;
} # get_perl_filename()

# }}}1
# Makefile customization (MY) {{{1
{ package MY;

# dist_core: make `dist` a :: target rather than a : target,
# and add distcheck before dist. Also, add -TRIAL to the tgz if necessary.
sub dist_core {
my $self = shift;
my $text = $self->SUPER::dist_core(@_);
$text =~ s/^dist\s*:[^:]/dist:: distcheck /m;

# Add -TRIAL if it's a trial release
if($IS_TRIAL) {
# Note: we don't have to worry about EOL; Appveyor uses gmake even
# on Windows, and it only uses \n.
print STDERR "TRIAL version\n";
my $newtext .= # Command to rename the tgz. TODO see if this works on Windows.
"\t\"$secure_perl_path\" -MExtUtils::Command -e mv -- " .
'"$(DISTVNAME).tar$(SUFFIX)" ' .
'"$(DISTVNAME)-TRIAL.tar$(SUFFIX)"' . "\n";

# Insert $newtext at the end of the `dist` target
$text =~ s{
^(dist[ \t]*:.*\n # dist header line
(?:[ \t]+\S.*\n)+) # dist body lines. `.` doesn't match `\n`.
# NOTE: on Appveyor, the continuation line
# begins with a space rather than a tab.
# Therefore, look for horizontal whitespace
# after \n. Not \s, because that matches a \n!
}{$1$newtext}mx;
} #endif $IS_TRIAL

return $text;
} # MY::dist_core
} #package MY

# }}}1

auto_install;
# Main options for EUMM
my %opts = (
NAME => 'Text::Chomped',
AUTHOR => q{Robert Krimen <rkrimen@cpan.org>},
VERSION_FROM => $VERSION_FROM,
ABSTRACT_FROM => $VERSION_FROM,
LICENSE => 'perl_5',
PL_FILES => {},
MIN_PERL_VERSION => '5.006',
CONFIGURE_REQUIRES => {
'Config' => '0',
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
},
TEST_REQUIRES => {
'Test::Most' => '0',
},
PREREQ_PM => {
'Exporter' => '0',
'strict' => '0',
'vars' => '0',
'warnings' => '0',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Text-Chomped-*' },

WriteAll;
META_MERGE => {
'meta-spec' => { version => 2 },

resources => {
bugtracker => {
web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Chomped',
},
repository => {
type => 'git',
url => 'https://github.com/robertkrimen/Text-Chomped.git',
web => 'https://github.com/robertkrimen/Text-Chomped',
},
},

prereqs => {
develop => {
requires => {
'Module::Metadata' => '1.000016',
},
},
},

x_contributors => [
'Christopher White <cxw@cpan.org>',
],

@provides,

}, #META_MERGE
);

$opts{META_MERGE}->{release_status} = 'testing' if $IS_TRIAL;

# Some tests run on older versions of EUMM that do not support TEST_REQUIRES.
# This is a workaround, modified from
# https://metacpan.org/source/RJBS/JSON-Typist-0.005/Makefile.PL .
unless( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
$opts{PREREQ_PM}->{$_} = $opts{TEST_REQUIRES}->{$_}
foreach keys %{$opts{TEST_REQUIRES}};
delete $opts{TEST_REQUIRES};
}

WriteMakefile(%opts);
# vi: set fdm=marker: #
Loading

0 comments on commit 202b4d5

Please sign in to comment.