File: SConstruct

package info (click to toggle)
clam 1.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,836 kB
  • ctags: 20,981
  • sloc: cpp: 92,504; python: 9,721; ansic: 1,602; xml: 444; sh: 239; makefile: 153; perl: 54; asm: 15
file content (220 lines) | stat: -rw-r--r-- 6,656 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python
import os
import glob
import sys

options = Variables('options.cache', ARGUMENTS)
options.Add(PathVariable('clam_prefix', 'The prefix where CLAM was installed', ''))
options.Add(BoolVariable('verbose', 'Display the full command line instead a short command description', 'no') )
options.Add(BoolVariable('crossmingw', 'Enables MinGW crosscompilation from linux', 'no') )

def scanFiles(pattern, paths) :
	files = []
	for path in paths :
		files+=glob.glob(path+"/"+pattern)
	return files

def recursiveDirs(root) :
	return filter( (lambda a : a.rfind( ".svn")==-1 ),  [ a[0] for a in os.walk(root)]  )

def unique(list) :
	return dict.fromkeys(list).keys()



toolchain = 'default'
if sys.platform == "win32" : toolchain = 'mingw'
env = Environment(tools=[toolchain], options=options)
options.Save('options.cache', env)

#TODO: This didn't work for dynamic linking

def renameEmbededFileSymbols(source, target, env) :
	""" Remove the path part of the symbol name for the embeded file"""
	objdumpOutput=os.popen("objdump -x %s | grep _binary'.*'start"%target[0] , "r").read()
	startSymbol=objdumpOutput.split()[-1]
	infix = startSymbol[len('_binary_'):-len("_start")]
	baseName = os.path.split(str(source[0]))[-1]
	newInfix = infix[-len(baseName):]
	return Execute("objcopy %(target)s "
		"--redefine-sym _binary_%(infix)s_start=_binary_%(newInfix)s_start "
		"--redefine-sym _binary_%(infix)s_end=_binary_%(newInfix)s_end "
		"--redefine-sym _binary_%(infix)s_size=_binary_%(newInfix)s_size " % {
			"infix": infix,
			"newInfix": newInfix,
			"target": target[0],
		}
	)
"""
embededFileBuilder = Builder(
	action=Action([
		["ld", "-fPIC", "--shared", "-b", "binary", "-o", "$TARGET", "$SOURCE"],
		renameEmbededFileSymbols,
		],
		),
	suffix='.os',
	)
env['BUILDERS']['EmbededFile']=embededFileBuilder
"""

env.SConsignFile() # Single signature file

crosscompiling=env['crossmingw']

CLAMInstallDir = env['clam_prefix']
clam_sconstoolspath = os.path.join(CLAMInstallDir,'share','clam','sconstools')
env.Tool('clam', toolpath=[clam_sconstoolspath])
env.Tool('qt4', toolpath=[clam_sconstoolspath])
if crosscompiling :
	env.Tool('crossmingw', toolpath=[clam_sconstoolspath])

env['CXXFILESUFFIX'] = '.cxx'
env['QT4_UICDECLSUFFIX'] = '.hxx'
env['QT4_MOCHPREFIX'] = os.path.join('generated','moc_')
env['QT4_UICDECLPREFIX'] = os.path.join('generated','uic_')
env['QT4_QRCCXXPREFIX'] = os.path.join('generated','qrc_')
if not env['verbose']:
	env['CXXCOMSTR'] = '== Compiling $SOURCE'
	env['LINKCOMSTR'] = '== Linking $TARGET'
	env['SHLINKCOMSTR'] = '== Linking library $TARGET'
	env['QT4_RCCCOMSTR'] = '== Embeding resources $SOURCE'
	env['QT4_UICCOMSTR'] = '== Compiling interface $SOURCE'
	env['QT4_LRELEASECOMSTR'] = '== Compiling translation $TARGET'
	env['QT4_MOCFROMHCOMSTR'] = '== Generating metaobjects for $SOURCE'
	env['QT4_MOCFROMCXXCOMSTR'] = '== Generating metaobjects for $SOURCE'

env.AppendUnique(ASFLAGS='-I. ')

env.EnableClamModules(libs=[
	'clam_core',
	'clam_audioio',
	'clam_processing',
	], path=CLAMInstallDir)

env.EnableQt4Modules([
	'QtCore',
	'QtGui',
	'QtOpenGL',
#	'QtSql',
#	'QtNetwork',
#	'QtTest',
#	'QtXml',
#	'QtSvg',
#	'QtUiTools',
#	'QtDesigner',
#	'Qt3Support',
	], debug=False,
	crosscompiling=crosscompiling,
	)


sourcePaths = []
extraPaths = [
	CLAMInstallDir+'/include',
	CLAMInstallDir+'/include/CLAM', # KLUDGE to keep old style includes
]
includePaths = sourcePaths + extraPaths

sources = scanFiles('*.cxx', sourcePaths)
sources = unique(sources)


singleSourceExamples = [
	"WritingProcessings.cxx",
	"NetworkPersistence_example.cxx",
	"NetworkUsage_example.cxx",
	"AudioApplicationExample.cxx", # TODO: Windows lacks GUIAudioApplication
	"AudioFileReading_example.cxx",
	"AudioFileWriting_example.cxx",
	"AudioIOExample.cxx",
#	"Configurators_example.cxx", # QT4Port
	"DescriptorComputation_example.cxx",
	"FDFilterExample.cxx",
	"FFT_example.cxx",
	"FileInfo_example.cxx",
	"FilePlayback_example.cxx",
	"FundamentalDetect.cxx",
	"LPCAnalysis_example.cxx", # TODO FLTK Dependencies -> Qt4
	"Midi2XmlExample.cxx",
	"MIDIFileReadWriteExample.cxx",
	"MIDIIOExample.cxx",
	"MIDIOut_example.cxx",
	"MIDI_Synthesizer_example.cxx", # TODO: Windows lacks GUIAudioApplication
	"NetworkPersistence_example.cxx",
	"NetworkUsage_example.cxx",
	"OfflineAudioConvolution.cxx",
	"PersistenceThroughDTs_example.cxx",
	"POCompositeExample.cxx",
	"SimplePortsUsage_example.cxx",
	"ProcessingLifeCycle_example.cxx",
	"ProcessingObject_controls_example.cxx",
	"SDIF_And_Segment_example.cxx", # TODO: FLTK Dependencies
	"Spectrum_example.cxx",
	"StereoToMonoFile.cxx",
#	"ThreadedProcessing_example.cxx", # TODO: Depends on Resample and FLTK
	"Tutorial/UserTutorial1.cxx",
	"Tutorial/UserTutorial2.cxx",
	"Tutorial/UserTutorial3.cxx",
	"Tutorial/UserTutorial4.cxx",
	"Tutorial/UserTutorial5.cxx",
	"Tutorial/UserTutorial6.cxx",
]


directoryBasedExamples = [
	"PortsAndControlsUsageExample",
	"ControlArrayExamples",
	"Wav2SDIF",
	"SDIF2Wav",
	"SDIF2WavStreaming",
]

directoryBasedLibraries = [
#	"PluginExamples/ClamLadspaPluginExample",
	"PluginExamples/ClamNativePluginExample",
# TODO: Files to be integred on the Network editor
#	"PluginExamples/LadspaOSCRemoteController",
]

singleSourceLibraries = [
]

env.Append(CPPPATH=includePaths)
env.AppendUnique(CPPFLAGS=["-g", "-Wall"])
#env.AppendUnique(DEFINES=["_DEBUG"])

examples = []

for libsource in singleSourceLibraries :
	library = os.path.basename(libsource)
	examples += [ env.SharedLibrary(source = libsource ) ]

for folder in directoryBasedLibraries :
	librarySources = glob.glob(folder+"/*.cxx")
#	librarySources += [env.EmbededFile(file) for file in glob.glob(folder+"/*.clamnetwork")]
	library = os.path.basename(folder)
	examples += [ env.SharedLibrary(target=library, source = librarySources ) ]

for main in singleSourceExamples :
	executable = os.path.splitext(os.path.basename(main))[0]
	examples += [ env.Program(target=executable, source = sources + [main] ) ]

for folder in directoryBasedExamples :
	exampleSources = glob.glob(folder+"/*.cxx")
	executable = os.path.basename(folder)+"Exe"
	examples += [ env.Program(target=executable, source = sources + exampleSources ) ]

if not crosscompiling :
	# Still having problems crosscompiling aubio
	tickEnv = env.Clone()
	tickEnv.AppendUnique(CPPPATH=['TickExtractor/libresample-0.1.3/include'])
	tickEnv.ParseConfig('pkg-config aubio --cflags --libs')
	tickSrc = glob.glob("TickExtractor/*cxx") + glob.glob("TickExtractor/libresample-0.1.3/src/*.c")
	examples += [ tickEnv.Program(target="TickExtractorExe", source = tickSrc) ]

env.Alias('examples',examples)

env.Default(examples)