This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make the expensive ckWARN() be called as late as possible
[perl5.git] / Porting / makemeta
1 #!./perl -w
2 # this script must be run by the current perl to get perl's version right
3
4 use strict;
5 use warnings;
6 use lib "Porting";
7
8 use File::Basename qw( dirname );
9
10 my $file = "META.yml";
11 die "$0: will not override $file, delete it first.\n" if -e $file;
12
13 use Maintainers qw(%Modules get_module_files get_module_pat);
14
15 my @CPAN  = grep { $Modules{$_}{CPAN} } keys %Modules;
16 my @files = map { get_module_files($_) } @CPAN;
17 my @dirs  = grep { -d $_ } map { get_module_pat($_) } @CPAN;
18
19 my %dirs;
20 @dirs{@dirs} = ();
21
22 my $files = join '', map { "    - $_\n" }
23   grep {
24     my $d = $_;
25     while(($d = dirname($d)) ne "."){
26       last if exists $dirs{$d};
27     }
28
29     # if $d is "." it means we tried every parent dir of the file and none
30     # of them were in the private list
31     
32     $d eq "."; 
33   }
34   sort { lc $a cmp lc $b } @files;
35
36 my $dirs  = join '', map { "    - $_\n" } sort { lc $a cmp lc $b } @dirs;
37
38 open my $fh, ">$file" or die "Can't open $file: $!";
39
40 print $fh <<"EOI";
41 name: perl
42 version: $]
43 abstract: Practical Extraction and Reporting Language
44 author: perl5-porters\@perl.org
45 license: perl
46 distribution_type: core
47 private:
48   directory:
49 $dirs
50   file:
51 $files
52 EOI
53
54 close $fh;
55