forked from letolabs/parrot-libgit2
/
setup.winxed
96 lines (84 loc) · 2.68 KB
/
setup.winxed
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
95
96
$include_const "iglobals.pasm";
using extern "io_ops";
function main[main](argv) {
var parrot_libgit2 = {
"name" : 'parrot-libgit2',
"abstract" : 'Parrot bindings for libgit2',
"description" : 'Parrot bindings for libgit2 - the linkable git library',
"authority" : 'http://github.com/leto',
"copyright_holder" : 'Jonathan "Duke" Leto',
"keywords" : ["parrot", "git", "libgit2"],
"license_type" : 'Artistic License 2.0',
"license_uri" : 'http://www.perlfoundation.org/artistic_license_2_0',
"checkout_uri" : 'git://github.com/leto/parrot-libgit2.git',
"browser_uri" : 'git://github.com/leto/parrot-libgit2',
"project_uri" : 'git://github.com/leto/parrot-libgit2',
"pir_winxed" : {},
"pbc_pir" : {},
"inst_lib" : [],
"installable_pbc" : {},
"include_winxed" : {},
"manifest_includes" : ["README.md", "setup.winxed"]
};
if (argv[1] == "test")
do_test();
setup_stable_libraries(parrot_libgit2);
load_bytecode('distutils.pir');
using setup;
using register_step_before;
register_step_before("build", check_dependencies);
register_step_before("clean", clean_build_dir);
argv.shift();
setup(argv, parrot_libgit2);
}
function setup_stable_libraries(var parrot_libgit2) {
var libs = [
'Cache',
'Common',
'Index',
'Odb',
'Oid',
'RefCache',
'Repository'
];
string prefix = "./src/Git2/";
for (string source in libs) {
string winxed_file = prefix + source + ".winxed";
string pir_file = prefix + source + ".pir";
string pbc_file = prefix + source + ".pbc";
parrot_libgit2["pir_winxed"][pir_file] = winxed_file;
parrot_libgit2["pbc_pir"][pbc_file] = pir_file;
parrot_libgit2["inst_lib"].push(pbc_file);
}
}
function do_test() {
int result;
string cmd = "parrot-nqp t/harness";
${ spawnw result, cmd };
${ exit result };
}
function check_dependencies() {
var config = getinterp()[IGLOBALS_CONFIG_HASH];
// Check if Parrot is > 3.5.0
int maj = config['MAJOR'];
int min = config['MINOR'];
if (maj < 3 || (maj == 3 && min < 5)) {
die("You need at least Parrot 3.5.0 to use parrot-libgit2");
}
// Check if Parrot has been built/configured with libffi
int has_libffi = config['has_libffi'];
if (!has_libffi) {
die("You need to have Parrot configured with libffi to use parrot-libgit2");
}
}
function clean_build_dir() {
var config = getinterp()[IGLOBALS_CONFIG_HASH];
string exe = "build/git2_test" + string(config['exe']);
int e = 0;
${ stat e, exe, 0 };
if (e) {
say("unlink " + exe);
unlink(exe);
}
unlink("src/git2.pbc");
}