-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
gen-version.pl
50 lines (38 loc) · 1.23 KB
/
gen-version.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
#! perl
=head1 TITLE
gen-version.pl -- script to generate version information for HLL compilers
=cut
use Digest::SHA;
use File::Find;
use POSIX 'strftime';
my $prefix = shift;
my $libdir = shift;
open(my $fh, '<', 'VERSION') or die $!;
my $VERSION = <$fh>;
close($fh);
chomp $VERSION;
my ($version, $release, $codename) = split(' ', $VERSION, 3);
if (-d '.git' && open(my $GIT, '-|', q|git describe --match "2*"|)) {
my $git_version = <$GIT>; # may be empty if we didn't fetch any tags
$version = $git_version || "$version.0000.1";
close($GIT);
}
chomp $version;
my $builddate = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime);
my $sha = Digest::SHA->new;
find(sub { next unless /\.(nqp|pm6)\z/; $sha->addfile($_) }, "src");
my $source_digest = $sha->hexdigest;
print <<"END_VERSION";
sub hll-config(\$config) {
\$config<implementation> := 'Rakudo';
\$config<version> := '$version';
\$config<release-number> := '$release';
\$config<codename> := '$codename';
\$config<build-date> := '$builddate';
\$config<language_version> := '6.c';
\$config<prefix> := '$prefix';
\$config<libdir> := '$libdir';
\$config<source-digest> := '$source_digest';
}
END_VERSION
0;