-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.winxed
112 lines (94 loc) · 3.37 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (C) 2012, Parrot Foundation.
// Build system for PACT, using Rosella.Winxed.Distutils
////// Inlines for useful opcodes
inline does(var pbc, string role) return int {
int ret;
${ does ret, pbc, role };
return ret;
}
////// Helpers to add a series of steps for a file.
// Name arguments should not have .winxed, .pir, etc
// Convert winxed file to a packfile
function pbc_winxed(var pact, string name, string dir = 'src/') {
pact['pir_winxed'][name+'.pir'] = dir+name+'.winxed';
pact['pbc_pir' ][name+'.pbc'] = name+'.pir';
}
// Create an installable program from winxed
function installable_winxed(var pact, string name, string prefix) {
pbc_winxed(pact, prefix, '');
pact['installable_pbc'][name] = prefix+'.pbc';
}
// Create an installable library from winxed
function library_winxed(var pact, string name) {
pbc_winxed(pact, name);
pact['header_pbc'][name+'.winxed'] = name+'.pbc';
push(pact['inst_lib'], name+'.pbc');
}
////// Distutils stages
// Create a header file from a pbc
function build_header_pbc(var kv [slurpy, named]) {
if (!exists kv['header_pbc'])
return;
var hash = kv['header_pbc'];
var jobs = new 'ResizableStringArray';
string header, pbc;
for (header in hash) {
var depends = hash[header];
if (does(depends, 'array')) {
if (newer(header, depends))
continue;
pbc = shift(depends);
} else {
pbc = depends;
if (newer(header, pbc))
continue;
}
mkpath(dirname(header), 1 : [named('verbose')]);
string cmd = 'winxed_mk_header ' + pbc + ' > ' + header;
push(jobs, cmd);
}
return run_jobs(jobs);
}
function main[main](var argv) {
int exit_code = 0;
try {
// Load and setup Rosella.Winxed.Distutils
load_bytecode('rosella/winxed.pbc');
Rosella.Winxed.Distutils.winxed_setup();
// Add new distutils stages
register_step_after('build', build_header_pbc);
// Setup build hash
var pact = {
'name' : 'PACT',
'abstract' : 'Parrot Alternate Compiler Toolkit',
'authority' : 'http://github.com/parrot',
'copyright_holder' : 'Parrot Foundation',
'keywords' : ['compiler'],
'license_type' : 'Artistic License 2.0',
'license_uri' : 'http://www.perlfoundation.org/artistic_license_2_0',
'checkout_uri' : 'git://github.com/parrot/PACT.git',
'browser_uri' : 'http://github.com/parrot/PACT',
'project_uri' : 'http://github.com/parrot/PACT',
'winxed_debug' : false,
'pir_winxed' : {},
'pbc_pir' : {},
'header_pbc' : {},
'installable_pbc' : {},
'inst_lib' : [],
'prove_files' : 't/*.t t/*/*.t'
};
library_winxed(pact, 'PACT/Packfile');
library_winxed(pact, 'PACT/Packfile/Decompile');
installable_winxed(pact, 'pact_disasm', 'src/disasm');
// Invoke distutils
argv.shift();
setup(argv, pact);
} catch (e) {
say(e['message']);
for (string bt in e.backtrace_strings())
say(bt);
exit_code = 1;
}
if (exit_code != 0)
exit(exit_code);
}