forked from punno2015/kodo-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
124 lines (95 loc) · 4.03 KB
/
Copy pathwscript
File metadata and controls
124 lines (95 loc) · 4.03 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
#! /usr/bin/env python
# encoding: utf-8
import os
APPNAME = 'kodo-python'
VERSION = '16.0.1'
codecs = ['nocode', 'rlnc', 'perpetual', 'fulcrum']
def options(opt):
if opt.is_toplevel():
opt.load('python')
opts = opt.add_option_group('kodo-python options')
opts.add_option(
'--disable_rlnc', default=None, dest='disable_rlnc',
action='store_true', help="Disable the basic RLNC codecs")
opts.add_option(
'--disable_perpetual', default=None, dest='disable_perpetual',
action='store_true', help="Disable the Perpetual RLNC codecs")
opts.add_option(
'--disable_fulcrum', default=None, dest='disable_fulcrum',
action='store_true', help="Disable the Fulcrum RLNC codec")
opts.add_option(
'--enable_codecs', default=None, dest='enable_codecs',
help="Enable the chosen codec or codecs, and disable all others. "
"A comma-separated list of these values: {0}".format(codecs))
def configure(conf):
conf.env['DEFINES_KODO_PYTHON_COMMON'] = []
disabled_codec_groups = 0
if conf.has_tool_option('disable_rlnc') or \
not conf.has_dependency_path('kodo-rlnc'):
conf.env['DEFINES_KODO_PYTHON_COMMON'] += ['KODO_PYTHON_DISABLE_RLNC']
disabled_codec_groups += 1
if conf.has_tool_option('disable_perpetual') or \
not conf.has_dependency_path('kodo-perpetual'):
conf.env['DEFINES_KODO_PYTHON_COMMON'] += \
['KODO_PYTHON_DISABLE_PERPETUAL']
disabled_codec_groups += 1
if conf.has_tool_option('disable_fulcrum') or \
not conf.has_dependency_path('kodo-fulcrum'):
conf.env['DEFINES_KODO_PYTHON_COMMON'] += \
['KODO_PYTHON_DISABLE_FULCRUM']
disabled_codec_groups += 1
if disabled_codec_groups == 3:
conf.fatal('All codec groups are disabled or unavailable. Please make '
'sure that you enable at least one codec group and you '
'have access to the corresponding repositories!')
if conf.has_tool_option('enable_codecs'):
enabled = conf.get_tool_option('enable_codecs').split(',')
# Validate the chosen codecs
for codec in enabled:
if codec not in codecs:
conf.fatal('Invalid codec: "{0}". Please use the following '
'codec names: {1}'.format(codec, codecs))
# Disable the codecs that were not selected
for codec in codecs:
if codec not in enabled:
conf.env['DEFINES_KODO_PYTHON_COMMON'] += \
['KODO_PYTHON_DISABLE_{0}'.format(codec.upper())]
def build(bld):
bld.env.append_unique(
'DEFINES_STEINWURF_VERSION',
'STEINWURF_KODO_PYTHON_VERSION="{}"'.format(VERSION))
bld(features='cxx cxxshlib pyext',
source=bld.path.ant_glob('src/kodo_python/**/*.cpp'),
target='kodo',
name='kodo-python',
use=[
'STEINWURF_VERSION',
'KODO_PYTHON_COMMON',
'pybind11_includes',
'kodo_core',
'kodo_rlnc',
'kodo_perpetual',
'kodo_fulcrum'
]
)
if bld.is_toplevel():
if bld.has_tool_option('run_tests'):
bld.add_post_fun(exec_test_python)
def exec_test_python(bld):
python = bld.env['PYTHON'][0]
env = dict(os.environ)
env['PYTHONPATH'] = os.path.join(bld.out_dir)
# First, run the unit tests in the 'test' folder
if os.path.exists('test'):
for f in sorted(os.listdir('test')):
if f.endswith('.py'):
test = os.path.join('test', f)
bld.cmd_and_log('{0} {1}\n'.format(python, test), env=env)
# Then run the examples in the 'examples' folder
if os.path.exists('examples'):
for f in sorted(os.listdir('examples')):
if f.endswith('.py'):
example = os.path.join('examples', f)
bld.cmd_and_log(
'{0} {1} --dry-run\n'.format(python, example), env=env)
print('-------------------------------\n')