-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
Compiler.pm6
94 lines (80 loc) · 2.85 KB
/
Compiler.pm6
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
class Compiler does Systemic {
has Str $.id;
has Str $.release;
has Str $!build-date;
has Str $.codename;
BEGIN my $id = nqp::sha1(
$*W.handle.Str
~ nqp::atkey(nqp::getcurhllsym('$COMPILER_CONFIG'), 'source-digest')
);
submethod BUILD (
:$!name = 'rakudo',
:$!auth = 'The Perl Foundation',
:$version,
:$release,
:$build-date,
:$codename
--> Nil
) {
# XXX Various issues with this stuff on JVM
my Mu $compiler := nqp::getcurhllsym('$COMPILER_CONFIG');
$!id = nqp::p6box_s(nqp::ifnull(nqp::atkey($compiler,'id'),$id));
# looks like: 2018.01-50-g8afd791c1
$!version = $version
// Version.new(nqp::atkey($compiler, 'version'));
$!release =
$release // nqp::p6box_s(nqp::atkey($compiler, 'release-number'));
$!build-date =
$build-date // nqp::p6box_s(nqp::atkey($compiler, 'build-date'));
$!codename =
$codename // nqp::p6box_s(nqp::atkey($compiler, 'codename'));
}
method build-date() {
DateTime.new($!build-date)
}
method verbose-config(:$say) {
my $compiler := nqp::getcomp("perl6");
my $backend := $compiler.backend;
my $name := $backend.name;
my $items := nqp::list_s;
nqp::push_s($items,$name ~ '::' ~ .key ~ '=' ~ .value)
for $backend.config;
my $language := $compiler.language;
nqp::push_s($items,$language ~ '::' ~ .key ~ '=' ~ .value)
for $compiler.config;
nqp::push_s(
$items,
'repo::chain=' ~ (try $*REPO.repo-chain.map( *.gist ).join(" ")) // ''
);
nqp::push_s($items,"distro::$_={ $*DISTRO."$_"() // '' }")
for <auth desc is-win name path-sep release signature version>;
nqp::push_s($items,"kernel::$_={ $*KERNEL."$_"() // '' }")
for <arch archname auth bits desc
hardware name release signature version>;
try {
require System::Info;
my $sysinfo = System::Info.new;
nqp::push_s($items,"sysinfo::{ .name }={ $sysinfo.$_ // '' }")
for $sysinfo.^methods.grep: { .count == 1 && .name ne 'new' };
}
my str $string = nqp::join("\n",Rakudo::Sorting.MERGESORT-str($items));
if $say {
nqp::say($string);
Nil
}
else {
my %config;
my $iter := nqp::iterator($items);
while $iter {
my ($main,$key,$value) = nqp::shift($iter).split(<:: =>);
%config.AT-KEY($main).AT-KEY($key) = $value
}
%config but role {
has $!string = $string;
proto method Str() { $!string }
proto method gist() { $!string }
}
}
}
}
# vim: ft=perl6 expandtab sw=4