-
Notifications
You must be signed in to change notification settings - Fork 3
/
wscript
174 lines (139 loc) · 6.46 KB
/
wscript
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/python
import sys
import os
import os.path, sys
sys.path[0:0] = [os.path.join('dependencies', 'AnyPlatform', 'ohWafHelpers')]
from filetasks import gather_files, build_tree, find_resource_or_fail
from utilfuncs import invoke_test, guess_dest_platform, configure_toolchain, guess_ohnet_location, guess_libplatform_location, guess_libosa_location, is_core_platform
def options(opt):
opt.load('msvc')
opt.load('compiler_cxx')
opt.load('compiler_c')
opt.add_option('--ohnet-include-dir', action='store', default=None)
opt.add_option('--ohnet-lib-dir', action='store', default=None)
opt.add_option('--testharness-dir', action='store', default=os.path.join('dependencies', 'AnyPlatform', 'testharness'))
opt.add_option('--ohnet', action='store', default=None)
opt.add_option('--libplatform', action='store', default=None)
opt.add_option('--libosa', action='store', default=None)
opt.add_option('--debug', action='store_const', dest="debugmode", const="Debug", default="Release")
opt.add_option('--release', action='store_const', dest="debugmode", const="Release", default="Release")
opt.add_option('--dest-platform', action='store', default=None)
opt.add_option('--cross', action='store', default=None)
def configure(conf):
def set_env(conf, varname, value):
conf.msg(
'Setting %s to' % varname,
"True" if value is True else
"False" if value is False else
value)
setattr(conf.env, varname, value)
return value
conf.msg("debugmode:", conf.options.debugmode)
if conf.options.dest_platform is None:
try:
conf.options.dest_platform = guess_dest_platform()
except KeyError:
conf.fatal('Specify --dest-platform')
if is_core_platform(conf):
guess_libosa_location(conf)
guess_libplatform_location(conf)
configure_toolchain(conf)
guess_ohnet_location(conf)
conf.env.dest_platform = conf.options.dest_platform
conf.env.testharness_dir = os.path.abspath(conf.options.testharness_dir)
if conf.options.dest_platform.startswith('Windows'):
conf.env.LIB_OHNET=['ws2_32', 'iphlpapi', 'dbghelp']
conf.env.STLIB_OHNET=['TestFramework', 'ohNetCore']
if is_core_platform(conf):
conf.env.prepend_value('STLIB_OHNET', ['target', 'platform'])
conf.env.append_value('DEFINES', ['DEFINE_TRACE', 'NETWORK_NTOHL_LOCAL', 'NOTERMIOS']) # Tell FLAC to use local ntohl implementation
conf.env.INCLUDES = [
'.',
conf.path.find_node('.').abspath()
]
mono = set_env(conf, 'MONO', [] if conf.options.dest_platform.startswith('Windows') else ["mono", "--debug", "--runtime=v4.0"])
conf.env.STLIB_SHELL = ['Shell']
class GeneratedFile(object):
def __init__(self, xml, domain, type, version, target):
self.xml = xml
self.domain = domain
self.type = type
self.version = version
self.target = target
upnp_services = [
GeneratedFile('OpenHome/NetworkMonitor1.xml', 'av.openhome.org', 'NetworkMonitor', '1', 'AvOpenhomeOrgNetworkMonitor1'),
]
def build(bld):
# Generated provider base classes
t4templatedir = bld.env['T4_TEMPLATE_PATH']
text_transform_exe_node = find_resource_or_fail(bld, bld.root, os.path.join(bld.env['TEXT_TRANSFORM_PATH'], 'TextTransform.exe'))
for service in upnp_services:
for t4Template, prefix, ext, args in [
('DvUpnpCppCoreHeader.tt', 'Dv', '.h', '-a buffer:1'),
('DvUpnpCppCoreSource.tt', 'Dv', '.cpp', ''),
('CpUpnpCppHeader.tt', 'Cp', '.h', '-a buffer:1'),
('CpUpnpCppBufferSource.tt', 'Cp', '.cpp', '')
]:
t4_template_node = find_resource_or_fail(bld, bld.root, os.path.join(t4templatedir, t4Template))
tgt = bld.path.find_or_declare(os.path.join('Generated', prefix + service.target + ext))
bld(
rule="${MONO} " + text_transform_exe_node.abspath() + " -o " + tgt.abspath() + " " + t4_template_node.abspath() + " -a xml:../" + service.xml + " -a domain:" + service.domain + " -a type:" + service.type + " -a version:" + service.version + " " + args,
source=[text_transform_exe_node, t4_template_node, service.xml],
target=tgt
)
bld.add_group()
# Library
bld.stlib(
source=[
'OpenHome/NetworkMonitor.cpp',
'OpenHome/CpNetworkMonitorList1.cpp',
'OpenHome/CpNetworkMonitorList2.cpp',
'Generated/CpAvOpenhomeOrgNetworkMonitor1.cpp',
'Generated/DvAvOpenhomeOrgNetworkMonitor1.cpp',
],
use=['OHNET'],
target='ohNetmon')
# ohNetmon.cpp /may/ have been superceded by TestNetworkMonitor.
# It's built here just in case.
bld.program(
source='OpenHome/ohNetmon.cpp',
use=['OHNET', 'ohNetmon'],
target='ohNetmon-app')
bld.program(
source='OpenHome/TestNetworkMonitor.cpp',
use=['OHNET', 'ohNetmon'],
target='TestNetworkMonitor')
# Bundles
def bundle(ctx):
print 'bundle binaries'
header_files = gather_files(ctx, '{top}', ['OpenHome/NetworkMonitor.h'])
lib_names = ['ohNetmon']
lib_files = gather_files(ctx, '{bld}', (ctx.env.cxxstlib_PATTERN % x for x in lib_names))
bundle_dev_files = build_tree({
'ohNetmon/lib' : lib_files,
'ohNetmon/include' : header_files
})
bundle_dev_files.create_tgz_task(ctx, 'ohNetmon.tar.gz')
# == Command for invoking unit tests ==
def test(tst):
print 'XXX no unit tests available XXX'
return # XXX
if not hasattr(tst, 'test_manifest'):
tst.test_manifest = 'oncommit.test'
print 'Testing using manifest:', tst.test_manifest
rule = 'python {test} -m {manifest} -p {platform} -b {build_dir} -t {tool_dir}'.format(
test = os.path.join(tst.env.testharness_dir, 'Test'),
manifest = '${SRC}',
platform = tst.env.dest_platform,
build_dir = '.',
tool_dir = os.path.join('..', 'dependencies', 'AnyPlatform'))
tst(rule=rule, source=tst.test_manifest)
# == Contexts to make 'waf test' work ==
from waflib.Build import BuildContext
class TestContext(BuildContext):
cmd = 'test'
fun = 'test'
class BundleContext(BuildContext):
cmd = 'bundle'
fun = 'bundle'
# vim: set filetype=python softtabstop=4 expandtab shiftwidth=4 tabstop=4: