-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.winxed
73 lines (56 loc) · 1.57 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
#! winxed
# (C) 2010 Julián Albo
/*
= head1 NAME
setup.winxed - Python distutils style
=head1 DESCRIPTION
Just some testing, not intended for real usage yet.
=head1 USAGE
Handle with care. See DESCRIPTION.
=cut
*/
$load 'Getopt/Obj.pbc';
//**********************************************************************
// Json file read.
function loadData(string filename)
{
var json = load_language('data_json');
var file = open(filename);
if (file == null || file.is_closed())
throw Error("Can't open " + filename);
file.encoding('utf8');
string jsondata = file.readall();
file.close();
var code = json.compile(jsondata);
return code();
}
//**********************************************************************
function main(argv)
{
// Parse command line.
var getopts = new ['Getopt','Obj'];
getopts.notOptStop(1);
getopts.push_string('file=s');
getopts.push_string('v');
string progname = argv.shift();
var opts = getopts.get_options(argv);
int verbose = opts['v'] != null;
var file = opts['file'];
// Get setup data from json file specified in command line
// or default value.
string filename = 'setup.json';
if (file != null)
filename = file;
var data = loadData(filename);
if (verbose) {
string description = data['description'];
say("\tFile: ", filename);
say("\tName: ", data['name']);
say("\tDescription: ", description);
say("\t(C) ", data['copyright_holder']);
say();
}
using extern distutils;
setup(argv:[flat], data:[flat,named]);
}
// End