-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_support.py
executable file
·84 lines (62 loc) · 1.82 KB
/
build_support.py
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
#!python
# Copyright (C) 2017, 2019-2020 FIUBioRG
# SPDX-License-Identifier: MIT
import os
from os import path
import subprocess
from subprocess import Popen, PIPE
import sys
python_version = ".".join(map(str, sys.version_info[0:2]))
###################################################################
# HELPER FUNCTIONS
###################################################################
def SourcePath(*args):
res = []
for p in args:
res.append(path.abspath("./src/" + p))
return res
def ObjectPath(*args):
res = []
for p in args:
res.append(path.abspath("./obj/" + p))
return res
def LibPath(*args):
res = []
for p in args:
res.append(path.abspath("./lib/" + p))
return res
def cmdline(command):
process = Popen(args=command, stdout=PIPE, shell=True)
return process.communicate()[0].decode("utf8")
def CheckPerl(ctx):
ctx.Message("Checking Perl configuration... ")
source = """
use strict;
use Config;
use File::Spec;
sub search {
my $paths = shift;
my $file = shift;
foreach(@{$paths}) {
if (-f "$_/$file") {
return "$_/$file";
last
}
}
return;
}
my $coredir = File::Spec->catfile($Config{installarchlib}, "CORE");
open(F, ">", ".perlconfig.txt");
print F "perl=$Config{perlpath}\\n";
print F "typemap=" . search(\\@INC, "ExtUtils/typemap") . "\\n";
print F "xsubpp=" . search(\\@INC, "ExtUtils/xsubpp" || search([File::Spec->path()], "xsubpp")) . "\\n";
print F "coredir=$coredir\\n";
close F;
"""
f = open(".perltest.pl", "w")
f.write(source)
f.close()
retcode = subprocess.call("perl .perltest.pl", shell=True)
ctx.Result(retcode == 0)
os.unlink(".perltest.pl")
return retcode == 0