-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile.PL
More file actions
150 lines (125 loc) · 4.15 KB
/
Makefile.PL
File metadata and controls
150 lines (125 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/perl
use 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
use File::Find;
my $do_xs = can_cc();
for (@ARGV) {
/^-pm/ and $do_xs = 0;
/^-xs/ and $do_xs = 1;
}
my $mm_ver = $ExtUtils::MakeMaker::VERSION;
if ($mm_ver =~ /_/) {
$mm_ver = eval $mm_ver;
die $@ if $@;
}
my %test_requires = (
'Test::DBGp' => '0.07',
'DBGp::Client' => '0.10',
);
my %pm = (
'perl5db.pl' => 'blib/lib/dbgp-helper/perl5db.pl',
);
{
open my $fh, '>', 'DB/DbgrXS.pm' or die "Unable to open 'DB/DbgrXS.pm: $!";
printf $fh <<'EOT', ($do_xs ? 1 : 0);
# generated file, don't edit
package DB::DbgrXS;
sub HAS_XS() { %s }
1;
EOT
}
sub _fill_dbgp {
return unless -f $_ && /\.pm$/;
$pm{$_} = "blib/lib/dbgp-helper/$_";
}
sub _fill_lib {
return unless -f $_ && /\.pm$/;
$pm{$_} = "blib/lib/$_";
}
find({ wanted => \&_fill_dbgp, no_chdir => 1 }, 'DB');
find({ wanted => \&_fill_lib, no_chdir => 1 }, 'Devel');
WriteMakefile(
NAME => "Devel::Debug::DBGp",
PM => \%pm,
VERSION_FROM => "Devel/Debug/DBGp.pm",
ABSTRACT_FROM => "Devel/Debug/DBGp.pm",
AUTHOR => 'Mattia Barbon <mbarbon@cpan.org>',
MAN3PODS => {
# do not generate manpages for all internal POD
'Devel/Debug/DBGp.pm' =>
'blib/man3/Devel::Debug::DBGp.3',
},
clean => { FILES => 'DB/DbgrXS.pm' },
$do_xs ? (
XS => { 'perl5db.xs' => undef },
OBJECT => 'perl5db.o',
) : (
XS => { },
OBJECT => '',
C => [ ],
),
( $mm_ver >= 6.48 ? ( MIN_PERL_VERSION => 5.008 ) :
() ),
( $mm_ver >= 6.64 ? ( TEST_REQUIRES => \%test_requires ) :
$mm_ver >= 6.5503 ? ( BUILD_REQUIRES => \%test_requires ) :
( PREREQ_PM => \%test_requires ) ),
( $mm_ver >= 6.31 ? ( LICENSE => 'artistic' ) :
() ),
( $mm_ver >= 6.46 ?
( META_MERGE => {
"meta-spec" => { version => 2 },
no_index => {
file => [ 'perl5db.pl' ],
directory => [ 'DB' ],
},
resources => {
license => [ 'http://dev.perl.org/licenses/artistic.html' ],
# homepage => 'https://github.com/mbarbon/perl-remote-debugging-client',
bugtracker => {
web => 'https://github.com/mbarbon/perl-remote-debugging-client/issues',
},
repository => {
url => 'git@github.com:mbarbon/perl-remote-debugging-client.git',
web => 'https://github.com/mbarbon/perl-remote-debugging-client',
type => 'git',
},
},
},
) : () ),
);
# stolen from an old Scalar-List-Utils version
sub can_cc {
foreach my $cmd (split(/ /, $Config::Config{cc})) {
my $_cmd = $cmd;
return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
my $abs = File::Spec->catfile($dir, $cmd);
return $abs if (-x $abs or $abs = MM->maybe_command($abs));
}
}
return;
}
package MY;
sub init_PM {
my $self = shift;
# without this, MakeMaker defaults to building Devel/Debug/DBGp.so,
# which works, but I prefer the consistency
$self->{PARENT_NAME} = '';
$self->{BASEEXT} = 'perl5db';
$self->{FULLEXT} = 'dbgp-helper/perl5db';
return $self->SUPER::init_PM(@_);
}
# run tests twice, once for the XS version, once for the pure-Perl one
sub test_via_harness {
my ($self, $perl, $tests) = @_;
my $cmd = $self->SUPER::test_via_harness($perl, $tests);
# use our own test harness wrapper
$cmd =~ s{(FULLPERLRUN\S+)\s}{$1 -I. };
$cmd =~ s{-MExtUtils::Command::MM}{-Mt::lib::Harness};
$cmd =~ s{(test_harness\s*\()}{${1}DBGP_RUN_PP, };
(my $cmd_pp = $cmd) =~ s{DBGP_RUN_PP}{q[perl]};
(my $cmd_xs = $cmd) =~ s{DBGP_RUN_PP}{q[xs]};
return ($cmd_pp, $cmd_xs);
}