forked from Raku/nqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-version.pl
executable file
·48 lines (35 loc) · 973 Bytes
/
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
#!/usr/bin/env perl
=head1 TITLE
gen-version.pl -- script to generate version information for HLL compilers
=cut
use 5.008;
use strict;
use warnings;
use Digest::SHA;
use File::Find;
use POSIX 'strftime';
my $prefix = shift // '';
my $nqp_home = shift // '';
my $libdir = shift // '';
open(my $fh, '<', 'VERSION') or die $!;
my $VERSION = <$fh>;
close($fh);
# .git is a file and not a directory in submodule
if (-e '.git' && open(my $GIT, '-|', 'git describe --tags "--match=20*"')) {
$VERSION = <$GIT>;
close($GIT);
}
chomp $VERSION;
my $sha = Digest::SHA->new;
find(sub { return unless /\.nqp\z/; $sha->addfile($_) }, "src");
my $source_digest = $sha->hexdigest;
print <<"END_VERSION";
sub hll-config(\$config) {
\$config<version> := '$VERSION';
\$config<prefix> := '$prefix';
\$config<nqp_home> := '$nqp_home';
\$config<libdir> := '$libdir';
\$config<source-digest> := '$source_digest';
}
END_VERSION
0;