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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
import sys
import os
import imp
from glob import glob
#######################################################
# reusable functions and data structures
#######################################################
def LoadTool(name, env, **kw):
config_path = GetBuildPath('#/Build/Tools/SCons')
file, path, desc = imp.find_module(name, [config_path])
module = imp.load_module(name, file, path, desc)
module.generate(env, **kw)
def MergeListUnique(item_list, items):
for item in items:
if not item in item_list: item_list.append(item)
def MergeItemUnique(item_list, item):
if not item in item_list: item_list.append(item)
def GlobSources(drct, patterns, excluded_files=[]):
root = GetBuildPath('#'+drct)
files = []
for pattern in Split(patterns):
files += glob(root+'/'+pattern)
return [drct+'/'+os.path.basename(x) for x in files if os.path.basename(x) not in excluded_files]
def GetDirPath(dir):
return '#/'+dir
def DeclareBuildDir(dir):
env.VariantDir(dir, GetDirPath(dir), duplicate=0)
def GetIncludeDirs(modules, exclude=None):
dirs = []
for module in Split(modules):
if Modules.has_key(module) and not module == exclude:
dirs += Modules[module].GetIncludeDirs()
else:
dirs += [GetDirPath(module)]
return dirs
def GetLibraries(modules):
libs = []
for module in Split(modules):
if Modules.has_key(module):
libs += Modules[module].GetLibraries()
else:
libs += [module]
return libs
Modules = {}
class Module:
def __init__(self, name, included_modules = [], linked_modules = []):
self.name = name
self.included_modules = included_modules
self.linked_modules = linked_modules
self.product = []
def GetLibraries(self):
return self.product+GetLibraries(self.linked_modules)
def GetIncludeDirs(self):
return GetIncludeDirs(self.included_modules+self.build_include_dirs, self.name)
class LibraryModule(Module):
def __init__(self, name,
build_source_dirs = ['.'],
build_source_files = {},
source_root = 'Source',
build_source_pattern = ['*.c', '*.cpp'],
build_include_dirs = [],
included_modules = [],
included_only_modules = [],
linked_modules = [],
environment = None,
excluded_files = [],
extra_cpp_defines = [],
shared = False,
install = False) :
build_source_dirs = [source_root+'/'+drct for drct in build_source_dirs]
Module.__init__(self,
name,
Split(included_modules)+Split(included_only_modules)+Split(build_source_dirs),
Split(linked_modules)+Split(included_modules))
self.build_include_dirs = build_include_dirs
if environment is None:
self.env = env.Clone()
else:
self.env = environment.Clone()
self.env.AppendUnique(CPPDEFINES = extra_cpp_defines)
# store this new object in the module dictionary
Modules[name] = self
# for each source drct to build, create a VariantDir
# to say where we want the object files to be built,
# and compute the list of source files to build
sources = []
for drct in Split(build_source_dirs):
DeclareBuildDir(drct)
sources += GlobSources(drct, build_source_pattern, excluded_files)
# add cherry-picked files
for drct in build_source_files.keys():
pattern = build_source_files[drct]
drct_path = source_root+'/'+drct
DeclareBuildDir(drct_path)
sources += GlobSources(drct_path, pattern)
# calculate our build include path
cpp_path = GetIncludeDirs(Split(self.build_include_dirs) + Split(build_source_dirs) + self.included_modules + self.linked_modules)
# the product is a library
self.env.AppendUnique(CPPPATH=cpp_path)
if shared is False:
self.product = self.env.Library(target=name, source=sources)
else:
libs = GetLibraries(Split(linked_modules))
self.product = self.env.SharedLibrary(target=name, LIBS=libs, source=sources)
self.env.Alias(name, self.product)
# copy to Targets folder
if install is True:
inst = env.Install(dir=env.GetBuildPath('#/Targets/'+env['target']+'/'+env['build_config']), source=self.product)
if env['build_config'] == 'Release' and env.has_key('STRIP'):
env.AddPostAction(inst, env['STRIP']+' $TARGETS');
def Application(name, dir, deps, install = False):
DeclareBuildDir(dir)
libs = GetLibraries(deps)
cpp_path = GetIncludeDirs(deps)
prog = env.Program(name,
GlobSources(dir, ['*.c', '*.cpp']) + env['NPT_EXTRA_EXECUTABLE_OBJECTS'],
LIBS=libs, CPPPATH=cpp_path)
#env.Alias(name, prog)
if env.has_key('NPT_EXECUTABLE_POST_PROCESSOR'):
env.AddPostAction(prog, env['NPT_EXECUTABLE_POST_PROCESSOR'])
# copy to Targets folder
if install is True:
inst = env.Install(dir=env.GetBuildPath('#/Targets/'+env['target']+'/'+env['build_config']), source=prog)
if env['build_config'] == 'Release' and env.has_key('STRIP'):
env.AddPostAction(inst, env['STRIP']+' $TARGETS');
#######################################################
# Main Build
#######################################################
Import("env")
### defaults
env['NPT_EXTRA_LIBS'] = []
env['NPT_EXTRA_EXECUTABLE_OBJECTS'] = []
if (env['build_config'] == 'Debug'):
env.AppendUnique(CPPDEFINES=['NPT_DEBUG', 'NPT_CONFIG_ENABLE_LOGGING', 'PLATINUM_UPNP_SPECS_STRICT'])
else:
env.AppendUnique(CPPDEFINES=['NDEBUG', 'NPT_CONFIG_ENABLE_LOGGING', 'PLATINUM_UPNP_SPECS_STRICT'])
### try to read in any target specific configuration
target_config_file = env.GetBuildPath('#/Build/Targets/'+env['target']+'/Config.scons')
if os.path.exists(target_config_file):
# Load the target-specific config file
execfile(target_config_file)
#######################################################
# modules
#
# Usage:
#
# The LibraryModule() function declares a code module
# The included_modules parameter is a list of all the modules and/or directories
# that will be added to the include path when building this module AND to
# the include path of any other module that depends on this one.
# The linked_modules parameter is a list of all the modules and/or directories
# that are necessary to build this module. These modules will be added to
# the include path of this module, but not to that of the modules that depend
# on this module. The modules that depend on this module, however, will
# automatically link with the linked_modules.
# Note that the included_modules list is automatically added to the
# linked_modules list, so that you do not need to list in linked_modules
# the modules that are already listed in included_modules.
# If a module needs to export an include path to its dependents that
# is not a module that the dependent can link with (ex: an include dir),
# list it in the included_only_modules.
# To summarize: included_modules should list all the modules that users
# of the public interface should depend on; linked_modules should list
# all the modules not listed in included_modules that are used by the
# module's implementation only.
#######################################################
# Neptune
NPT_SOURCE_ROOT = 'ThirdParty/Neptune'
extra_cpp_flags = []
neptune_extra_linked_modules = []
if not env.has_key('NPT_CONFIG_NO_ZIP'):
extra_cpp_flags = ['NPT_CONFIG_ENABLE_ZIP']
neptune_extra_linked_modules += ['Zlib']
LibraryModule(name = 'Zlib',
source_root = NPT_SOURCE_ROOT,
build_source_dirs = ['ThirdParty/zlib-1.2.3'])
if not env.has_key('NPT_CONFIG_NO_SSL'):
extra_cpp_flags += ['NPT_CONFIG_ENABLE_TLS']
tls_data_dirs = ['Data/TLS']
tls_tests = ['Tls1']
neptune_extra_linked_modules += ['axTLS']
LibraryModule(name = 'axTLS',
source_root = NPT_SOURCE_ROOT,
build_source_dirs = ['ThirdParty/axTLS/crypto', 'ThirdParty/axTLS/ssl', 'ThirdParty/axTLS/config/Generic'])
else:
tls_data_dirs = []
tls_tests = []
if not env.has_key('NPT_CONFIG_NO_CRYPTO'):
extra_cpp_flags += ['NPT_CONFIG_ENABLE_CRYPTO']
neptune_excluded_files = []
else:
neptune_excluded_files = ['NptCrypto.cpp', 'NptDigest.cpp']
LibraryModule(name = 'Neptune',
build_source_dirs = ['Core']+tls_data_dirs,
build_source_files = env['NPT_SYSTEM_SOURCES'],
excluded_files = neptune_excluded_files,
extra_cpp_defines = extra_cpp_flags,
linked_modules = env['NPT_EXTRA_LIBS']+neptune_extra_linked_modules,
source_root = NPT_SOURCE_ROOT + '/Source')
# Platinum
LibraryModule(name = 'Platinum',
build_source_dirs = ['Core', 'Extras'],
build_include_dirs = ['Source/Platinum'],
extra_cpp_defines = extra_cpp_flags,
included_modules = ['Neptune'])
# Platinum MediaServer
LibraryModule(name = 'PltMediaServer',
build_source_dirs = ['MediaServer'],
included_modules = ['Platinum'],
source_root = 'Source/Devices')
# Platinum MediaRenderer
LibraryModule(name = 'PltMediaRenderer',
build_source_dirs = ['MediaRenderer'],
included_modules = ['Platinum', 'PltMediaServer'],
source_root = 'Source/Devices')
# Platinum MediaConnect
LibraryModule(name = 'PltMediaConnect',
build_source_dirs = ['MediaConnect'],
included_modules = ['Platinum', 'PltMediaServer', 'PltMediaRenderer'],
excluded_files = ['MACFromIP.cpp'],
source_root = 'Source/Devices')
for app in ['MicroMediaController', 'MediaCrawler', 'MediaConnect', 'FrameStreamer']:
Application(name = app,
dir = 'Source/Apps/' + app,
deps = ['Platinum', 'PltMediaServer', 'PltMediaRenderer', 'PltMediaConnect'],
install = True)
for test in ['FileMediaServer', 'MediaRenderer', 'LightSample', 'Http', 'Time']:
Application(name = test+'Test',
dir = 'Source/Tests/' + test,
deps = ['Platinum', 'PltMediaServer', 'PltMediaRenderer', 'PltMediaConnect'],
install = True)
for tool in ['TextToHeader']:
Application(name = tool,
dir = 'Source/Tools/' + tool,
deps = ['Platinum'],
install = True)
|