-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.pm
More file actions
40 lines (31 loc) · 946 Bytes
/
Build.pm
File metadata and controls
40 lines (31 loc) · 946 Bytes
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
use v6.c;
use LibraryMake;
use Shell::Command;
class Build {
my $libdir = 'resources/libraries';
method build($dir) {
my %vars = get-vars($dir);
%vars<source> = 'source';
%vars<pyhelper> = to-library-path('pyhelper');
%vars<perl6> = to-library-path('perl6');
my $pyconfig = query-pyconfig-path;
%vars<cflags> = chomp qqx/$pyconfig --cflags/;
%vars<ldflags> = chomp qqx/$pyconfig --ldflags/;
mkdir $libdir;
process-makefile($dir, %vars);
shell(%vars<MAKE>);
}
sub to-library-path($lib) {
$*VM.platform-library-name("$libdir/$lib".IO)
}
sub query-pyconfig-path {
my $pyconfig = %*ENV<PYTHON_CONFIG> // do {
my $locate-pyconfig = 'which python3-config';
qqx/$locate-pyconfig/.lines.first;
} // die 'error: failed to find the python3.*-config';
if $pyconfig.&run('--help', :out, :err).exitcode != 0 {
die "error: failed to find the executable '$pyconfig'"
}
$pyconfig
}
}