Codebase list libmodule-build-tiny-perl / upstream/0.028
Imported Upstream version 0.028 gregor herrmann 10 years ago
7 changed file(s) with 76 addition(s) and 81 deletion(s). Raw diff Collapse all Expand all
0 use 5.006;
01 use lib 'lib';
1 use Module::Build::Tiny ;
2 use Module::Build::Tiny;
23 Build_PL(@ARGV);
00 Revision history for Module::Build::Tiny
1
2 0.028 2013-09-29 19:58:39 Europe/Amsterdam
3 Revert "Removed clean and realclean actions"
4 Build .c and .o in temp/ instead of lib
5 Got rid of IO layers
6 Separate libdoc and bindoc checks
17
28 0.027 2013-09-09 11:43:12 Europe/Amsterdam
39 Various documentation updates
44 "David Golden <dagolden@cpan.org>"
55 ],
66 "dynamic_config" : 0,
7 "generated_by" : "Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.132140",
7 "generated_by" : "Dist::Zilla version 4.300038, CPAN::Meta::Converter version 2.120921",
88 "license" : [
99 "perl_5"
1010 ],
8282 "File::Spec" : "0",
8383 "File::Temp" : "0",
8484 "IO::File" : "0",
85 "IO::Handle" : "0",
8586 "IPC::Open2" : "0",
87 "IPC::Open3" : "0",
8688 "Test::More" : "0.88",
8789 "XSLoader" : "0",
8890 "blib" : "0",
105107 "web" : "https://github.com/Leont/module-build-tiny"
106108 }
107109 },
108 "version" : "0.027"
110 "version" : "0.028"
109111 }
110112
99 File::Spec: 0
1010 File::Temp: 0
1111 IO::File: 0
12 IO::Handle: 0
1213 IPC::Open2: 0
14 IPC::Open3: 0
1315 Test::More: 0.88
1416 XSLoader: 0
1517 blib: 0
3739 conflicts:
3840 local::lib: '< 1.006008'
3941 dynamic_config: 0
40 generated_by: 'Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.132140'
42 generated_by: 'Dist::Zilla version 4.300038, CPAN::Meta::Converter version 2.120921'
4143 license: perl
4244 meta-spec:
4345 url: http://module-build.sourceforge.net/META-spec-v1.4.html
6870 resources:
6971 bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Module-Build-Tiny
7072 repository: git://github.com/Leont/module-build-tiny.git
71 version: 0.027
73 version: 0.028
00
11
22 This archive contains the distribution Module-Build-Tiny,
3 version 0.027:
3 version 0.028:
44
55 A tiny replacement for Module::Build
66
00 package Module::Build::Tiny;
11 {
2 $Module::Build::Tiny::VERSION = '0.027';
2 $Module::Build::Tiny::VERSION = '0.028';
33 }
44 use strict;
55 use warnings;
1313 use ExtUtils::InstallPaths 0.002;
1414 use File::Basename qw/basename dirname/;
1515 use File::Find ();
16 use File::Path qw/mkpath/;
16 use File::Path qw/mkpath rmtree/;
1717 use File::Spec::Functions qw/catfile catdir rel2abs abs2rel splitdir/;
1818 use Getopt::Long qw/GetOptions/;
1919 use JSON::PP 2 qw/encode_json decode_json/;
2020
2121 sub write_file {
22 my ($filename, $mode, $content) = @_;
23 open my $fh, ">:$mode", $filename or die "Could not open $filename: $!\n";;
22 my ($filename, $content) = @_;
23 open my $fh, '>', $filename or die "Could not open $filename: $!\n";
2424 print $fh $content;
2525 }
2626 sub read_file {
2727 my ($filename, $mode) = @_;
28 open my $fh, "<:$mode", $filename or die "Could not open $filename: $!\n";
28 open my $fh, '<', $filename or die "Could not open $filename: $!\n";
2929 return do { local $/; <$fh> };
3030 }
3131
5252 my (undef, @dirnames) = splitdir(dirname($source));
5353 my $file_base = basename($source, '.xs');
5454 my $archdir = catdir(qw/blib arch auto/, @dirnames, $file_base);
55
56 my $c_file = catfile('lib', @dirnames, "$file_base.c");
55 my $tempdir = 'temp';
56
57 my $c_file = catfile($tempdir, "$file_base.c");
5758 require ExtUtils::ParseXS;
59 mkpath($tempdir, $options->{verbose}, oct '755');
5860 ExtUtils::ParseXS::process_file(filename => $source, prototypes => 0, output => $c_file);
5961
6062 my $version = $options->{meta}->version;
6365 my $ob_file = $builder->compile(source => $c_file, defines => { VERSION => qq/"$version"/, XS_VERSION => qq/"$version"/ });
6466
6567 mkpath($archdir, $options->{verbose}, oct '755') unless -d $archdir;
66 return $builder->link(objects => $ob_file, lib_file => catfile($archdir, "$file_base.".$options->{config}->get('dlext')), module_name => join '::', @dirnames, $file_base);
68 return $builder->link(objects => $ob_file, lib_file => catfile($archdir, "$file_base." . $options->{config}->get('dlext')), module_name => join '::', @dirnames, $file_base);
6769 }
6870
6971 sub find {
7981 system $^X, $_ and die "$_ returned $?\n" for find(qr/\.PL$/, 'lib');
8082 my %modules = map { $_ => catfile('blib', $_) } find(qr/\.p(?:m|od)$/, 'lib');
8183 my %scripts = map { $_ => catfile('blib', $_) } find(qr//, 'script');
82 my %shared = map { $_ => catfile(qw/blib lib auto share dist/, $opt{meta}->name, abs2rel($_, 'share')) } find(qr//, 'share');
84 my %shared = map { $_ => catfile(qw/blib lib auto share dist/, $opt{meta}->name, abs2rel($_, 'share')) } find(qr//, 'share');
8385 pm_to_blib({ %modules, %scripts, %shared }, catdir(qw/blib lib auto/));
8486 make_executable($_) for values %scripts;
8587 mkpath(catdir(qw/blib arch/), $opt{verbose});
8688 process_xs($_, \%opt) for find(qr/.xs$/, 'lib');
8789
90 if ($opt{install_paths}->install_destination('bindoc') && $opt{install_paths}->is_default_installable('bindoc')) {
91 manify($_, catfile('blib', 'bindoc', man1_pagename($_)), $opt{config}->get('man1ext'), \%opt) for keys %scripts;
92 }
8893 if ($opt{install_paths}->install_destination('libdoc') && $opt{install_paths}->is_default_installable('libdoc')) {
89 manify($_, catfile('blib', 'bindoc', man1_pagename($_)), $opt{config}->get('man1ext'), \%opt) for keys %scripts;
9094 manify($_, catfile('blib', 'libdoc', man3_pagename($_)), $opt{config}->get('man3ext'), \%opt) for keys %modules;
9195 }
9296 },
9498 my %opt = @_;
9599 die "Must run `./Build build` first\n" if not -d 'blib';
96100 require TAP::Harness;
97 my $tester = TAP::Harness->new({verbosity => $opt{verbose}, lib => [ map { rel2abs(catdir(qw/blib/, $_)) } qw/arch lib/ ], color => -t STDOUT});
101 my $tester = TAP::Harness->new({ verbosity => $opt{verbose}, lib => [ map { rel2abs(catdir(qw/blib/, $_)) } qw/arch lib/ ], color => -t STDOUT });
98102 $tester->runtests(sort +find(qr/\.t$/, 't'))->has_errors and exit 1;
99103 },
100104 install => sub {
101105 my %opt = @_;
102106 die "Must run `./Build build` first\n" if not -d 'blib';
103107 install($opt{install_paths}->install_map, @opt{qw/verbose dry_run uninst/});
108 },
109 clean => sub {
110 my %opt = @_;
111 rmtree($_, $opt{verbose}) for qw/blib temp/;
112 },
113 realclean => sub {
114 my %opt = @_;
115 rmtree($_, $opt{verbose}) for qw/blib temp Build _build_params MYMETA.yml MYMETA.json/;
104116 },
105117 );
106118
107119 sub Build {
108120 my $action = @ARGV && $ARGV[0] =~ /\A\w+\z/ ? shift @ARGV : 'build';
109121 die "No such action '$action'\n" if not $actions{$action};
110 unshift @ARGV, @{ decode_json(read_file('_build_params', 'utf8')) };
122 unshift @ARGV, @{ decode_json(read_file('_build_params')) };
111123 GetOptions(\my %opt, qw/install_base=s install_path=s% installdirs=s destdir=s prefix=s config=s% uninst:1 verbose:1 dry_run:1 pureperl-only:1 create_packlist=i/);
112124 $_ = detildefy($_) for grep { defined } @opt{qw/install_base destdir prefix/}, values %{ $opt{install_path} };
113 @opt{'config', 'meta'} = (ExtUtils::Config->new($opt{config}), get_meta());
125 @opt{ 'config', 'meta' } = (ExtUtils::Config->new($opt{config}), get_meta());
114126 $actions{$action}->(%opt, install_paths => ExtUtils::InstallPaths->new(%opt, dist_name => $opt{meta}->name));
115127 }
116128
118130 my $meta = get_meta();
119131 printf "Creating new 'Build' script for '%s' version '%s'\n", $meta->name, $meta->version;
120132 my $dir = $meta->name eq 'Module-Build-Tiny' ? "use lib 'lib';" : '';
121 write_file('Build', 'raw', "#!perl\n$dir\nuse Module::Build::Tiny;\nBuild();\n");
133 write_file('Build', "#!perl\n$dir\nuse Module::Build::Tiny;\nBuild();\n");
122134 make_executable('Build');
123135 my @env = defined $ENV{PERL_MB_OPT} ? split_like_shell($ENV{PERL_MB_OPT}) : ();
124 write_file('_build_params', 'utf8', encode_json([ @env, @ARGV ]));
125 $meta->save(@$_) for ['MYMETA.json'], ['MYMETA.yml' => { version => 1.4 }];
136 write_file('_build_params', encode_json([ @env, @ARGV ]));
137 $meta->save(@$_) for ['MYMETA.json'], [ 'MYMETA.yml' => { version => 1.4 } ];
126138 }
127139
128140 1;
142154
143155 =head1 VERSION
144156
145 version 0.027
157 version 0.028
146158
147159 =head1 SYNOPSIS
148160
0 #!perl
1
20 use strict;
31 use warnings;
42
5 use Test::More;
3 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.033
4
5 use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
66
77
88
9 use File::Find;
10 use File::Temp qw{ tempdir };
11
12 my @modules;
13 find(
14 sub {
15 return if $File::Find::name !~ /\.pm\z/;
16 my $found = $File::Find::name;
17 $found =~ s{^lib/}{};
18 $found =~ s{[/\\]}{::}g;
19 $found =~ s/\.pm$//;
20 # nothing to skip
21 push @modules, $found;
22 },
23 'lib',
9 my @module_files = (
10 'Module/Build/Tiny.pm'
2411 );
2512
26 sub _find_scripts {
27 my $dir = shift @_;
2813
29 my @found_scripts = ();
30 find(
31 sub {
32 return unless -f;
33 my $found = $File::Find::name;
34 # nothing to skip
35 open my $FH, '<', $_ or do {
36 note( "Unable to open $found in ( $! ), skipping" );
37 return;
38 };
39 my $shebang = <$FH>;
40 return unless $shebang =~ /^#!.*?\bperl\b\s*$/;
41 push @found_scripts, $found;
42 },
43 $dir,
44 );
4514
46 return @found_scripts;
15 # no fake home requested
16
17 use File::Spec;
18 use IPC::Open3;
19 use IO::Handle;
20
21 my @warnings;
22 for my $lib (@module_files)
23 {
24 # see L<perlfaq8/How can I capture STDERR from an external command?>
25 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
26 my $stderr = IO::Handle->new;
27
28 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, '-Mblib', '-e', "require q[$lib]");
29 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
30 my @_warnings = <$stderr>;
31 waitpid($pid, 0);
32 is($? >> 8, 0, "$lib loaded ok");
33
34 if (@_warnings)
35 {
36 warn @_warnings;
37 push @warnings, @_warnings;
38 }
4739 }
4840
49 my @scripts;
50 do { push @scripts, _find_scripts($_) if -d $_ }
51 for qw{ bin script scripts };
5241
53 my $plan = scalar(@modules) + scalar(@scripts);
54 $plan ? (plan tests => $plan) : (plan skip_all => "no tests to run");
5542
56 {
57 # fake home for cpan-testers
58 # no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 );
43 is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING};
5944
60 like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" )
61 for sort @modules;
6245
63 SKIP: {
64 eval "use Test::Script 1.05; 1;";
65 skip "Test::Script needed to test script compilation", scalar(@scripts) if $@;
66 foreach my $file ( @scripts ) {
67 my $script = $file;
68 $script =~ s!.*/!!;
69 script_compiles( $file, "$script script compiles" );
70 }
71 }
72
73 }