-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathconfigure.pl6
executable file
·61 lines (51 loc) · 1.82 KB
/
configure.pl6
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
#!/usr/bin/env perl6
use v6;
sub MAIN(:$test, :$install is copy) {
configure();
test() or $install = False if $test;
install() if $install;
}
sub configure() {
run('perl', '-e', 'use v5.20;')
or die "\nPerl 5 version requirement not met\n";
run('perl', '-MFilter::Simple', '-e', '1')
or die "\nPlease install the Filter::Simple Perl 5 module!\n";
my %vars;
%vars<CC> = $*VM.config<cc> // $*VM.config<nativecall.cc> // 'cc';
%vars<p5helper> = p5helper().Str;
%vars<perlopts> = run(<perl -MExtUtils::Embed -e ccopts -e ldopts>, :out).out.lines.join('');
%vars<EXECUTABLE> = $*EXECUTABLE;
mkdir "resources" unless "resources".IO.e;
mkdir "resources/libraries" unless "resources/libraries".IO.e;
my $makefile = slurp('Makefile.in');
for %vars.kv -> $k, $v {
$makefile ~~ s:g/\%$k\%/$v/;
}
spurt('Makefile', $makefile);
}
sub test() {
run($*VM.config<make>, 'test').exitcode == 0
}
sub install() {
my $repo = %*ENV<DESTREPO>
?? CompUnit::RepositoryRegistry.repository-for-name(%*ENV<DESTREPO>)
!! (
CompUnit::RepositoryRegistry.repository-for-name('site'),
|$*REPO.repo-chain.grep(CompUnit::Repository::Installable)
).first(*.can-install)
or die "Cannot find a repository to install to";
say "Installing into $repo";
my $dist = Distribution::Path.new($*CWD);
# workaround for missing proper handling of libraries in Distribution::Path
my $p5helper = p5helper;
$dist.meta<files> = (
|$dist.meta<files>.grep(* ne $p5helper.Str),
{'resources/libraries/p5helper' => $p5helper},
);
$repo.install($dist);
say "Installed successfully.";
}
sub p5helper() {
'resources'.IO.child('libraries').child($*VM.platform-library-name('p5helper'.IO))
}
# vim: ft=perl6