forked from wtsi-npg/p4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.PL
107 lines (92 loc) · 2.79 KB
/
Build.PL
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
use strict;
use warnings;
use Module::Build;
my $class = Module::Build->subclass(code => <<'EOF');
sub git_tag {
# adding --tags to allow use of non-annotated tags (as produced by github release tagging)
my $gitver = q[git describe --tags --dirty --always];
my $version = `$gitver` || 'unknown';
$version =~ s/\s$//smxg;
$version=~s/\A(?![\d])/0.0-/smx; #prepend 0.0- if does not start with a number
return $version;
}
sub process_data_files {
`cp -av data blib`;
return;
}
sub ACTION_code {
my $self = shift;
$self->SUPER::ACTION_code;
my $gitver = $self->git_tag();
my @files = ();
if (-d 'blib/lib') {
@files = split q[\n], `find blib/lib -type f -name "*.pm"`;
}
if (-d 'blib/script') {
push @files, split q[\n], `find blib/script -type f`;
}
foreach my $file (@files) {
warn "Changing version of $file to $gitver\n";
my $backup = '.original';
local $^I = $backup;
local @ARGV = ($file);
while (<>) {
s/(\$VERSION\s*=\s*)('?\S+'?)\s*;/${1}'$gitver';/;
print;
}
unlink "$file$backup";
}
return;
}
EOF
my $builder = $class->new(
'module_name' => 'p4',
'dist_author' => q(npg <npg@sanger.ac.uk>),
'dist_version' => $class->git_tag(),
'dist_abstract' => 'Process and Pipe Pipeline Panacea',
'license' => 'gpl',
'configure_requires' => {
'ExtUtils::CBuilder' => 0
},
'build_requires' => {
'Carp' => 0,
'Cwd' => 0,
'English' => 0,
'File::Temp' => 0,
'JSON' => 0,
'Perl6::Slurp' => 0,
'Test::Cmd' => 0,
'Test::Compile' => 0,
'Test::More' => 0,
},
'requires' => {
'Carp' => 0,
'Cwd' => 0,
'Data::Dumper' => 0,
'Fcntl' => 0,
'File::Basename' => 0,
'File::Slurp' => 0,
'File::Spec' => 0,
'File::Temp' => 0,
'File::Which' => 0,
'Getopt::Long' => 0,
'Getopt::Std' => 0,
'Hash::Merge' => 0,
'JSON' => 0,
'List::MoreUtils' => 0,
'POSIX' => 0,
'Readonly' => 0,
'strict' => 0,
'Storable' => 0,
'warnings' => 0,
},
'dist' => { COMPRESS => 'gzip', SUFFIX => 'gz', }
);
if ($builder->install_base()) {
$builder->install_path('data' => join q{/}, $builder->install_base(), 'data');
$builder->add_build_element('data');
} else {
warn "WARNING: '--install_base' option is not given, 'data' element will not be installed\n\n";
}
$builder->create_build_script();
1;