forked from AdaCore/gnatcoll-bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·78 lines (69 loc) · 2.73 KB
/
setup.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
#!/usr/bin/env python
import logging
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from setup_support import SetupApp
class GNATCollGMP(SetupApp):
name = 'gnatcoll-gmp'
project = 'gnatcoll-gmp.gpr'
description = 'GNATColl GMP bindings'
def create(self):
super(GNATCollGMP, self).create()
self.build_cmd.add_argument(
'--disable-shared',
help='if set disable build of shared libraries',
dest='enable_shared',
default=True,
action="store_false")
self.build_cmd.add_argument(
'--debug',
help='build project in debug mode',
action="store_true",
default=False)
def update_config(self, config, args):
# The first element in library_types list define the default type of
# library that will be used. Do not rely on the default set in the
# project file.
if args.enable_shared:
config.set_data('library_types',
['static', 'static-pic', 'relocatable'])
else:
config.set_data('library_types',
['static'])
logging.info('%-26s %s',
'Libraries kind', ", ".join(config.data['library_types']))
# Set library version
with open(os.path.join(config.source_dir, '..',
'version_information'), 'rb') as fd:
version = fd.read().strip()
config.set_data('GNATCOLL_VERSION', version, sub='gprbuild')
# Set build mode
config.set_data('BUILD', 'DEBUG' if args.debug else 'PROD',
sub='gprbuild')
logging.info('%-26s %s', 'Build mode',
config.data['gprbuild']['BUILD'])
# Set GNATCOLL_OS
if 'darwin' in config.data['canonical_target']:
gnatcoll_os = 'osx'
elif 'windows' in config.data['canonical_target']:
gnatcoll_os = 'windows'
else:
# Assume this is an Unix system
gnatcoll_os = 'unix'
config.set_data('GNATCOLL_OS', gnatcoll_os, sub='gprbuild')
def variants(self, config, cmd):
result = []
for library_type in config.data['library_types']:
gpr_vars = {'LIBRARY_TYPE': library_type,
'XMLADA_BUILD': library_type}
if cmd == 'install':
result.append((['--build-name=%s' % library_type,
'--build-var=LIBRARY_TYPE'],
gpr_vars))
else:
result.append(([], gpr_vars))
return result
if __name__ == '__main__':
app = GNATCollGMP()
sys.exit(app.run())