Clean up libardour tests a bit.
[ardour.git] / libs / ardour / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 import os
5 import re
6 import subprocess
7
8 # Version of this package (even if built as a child)
9 MAJOR = '3'
10 MINOR = '0'
11 MICRO = '0'
12 LIBARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
13
14 # Library version (UNIX style major, minor, micro)
15 # major increment <=> incompatible changes
16 # minor increment <=> compatible changes (additions)
17 # micro increment <=> no interface changes
18 LIBARDOUR_LIB_VERSION = '3.0.0'
19
20 # default state file version for this build
21 CURRENT_SESSION_FILE_VERSION = 3001
22
23 # Variables for 'waf dist'
24 APPNAME = 'libardour3'
25 VERSION = LIBARDOUR_VERSION
26 I18N_PACKAGE = 'libardour3'
27
28 # Mandatory variables
29 top = '.'
30 out = 'build'
31
32 path_prefix = 'libs/ardour/'
33
34 libardour_sources = [
35         'amp.cc',
36         'analyser.cc',
37         'audio_buffer.cc',
38         'audio_diskstream.cc',
39         'audio_library.cc',
40         'audio_playlist.cc',
41         'audio_playlist_importer.cc',
42         'audio_playlist_source.cc',
43         'audio_port.cc',
44         'audio_region_importer.cc',
45         'audio_track.cc',
46         'audio_track_importer.cc',
47         'audioanalyser.cc',
48         'audioengine.cc',
49         'audiofile_tagger.cc',
50         'audiofilesource.cc',
51         'audioregion.cc',
52         'audiosource.cc',
53         'auditioner.cc',
54         'automatable.cc',
55         'automation.cc',
56         'automation_control.cc',
57         'automation_list.cc',
58         'beats_frames_converter.cc',
59         'broadcast_info.cc',
60         'buffer.cc',
61         'buffer_manager.cc',
62         'buffer_set.cc',
63         'bundle.cc',
64         'butler.cc',
65         'callback.cc',
66         'capturing_processor.cc',
67         'chan_count.cc',
68         'chan_mapping.cc',
69         'configuration.cc',
70         'config_text.cc',
71         'control_protocol_manager.cc',
72         'control_protocol_search_path.cc',
73         'cycle_timer.cc',
74         'data_type.cc',
75         'default_click.cc',
76         'debug.cc',
77         'delivery.cc',
78         'directory_names.cc',
79         'diskstream.cc',
80         'element_import_handler.cc',
81         'element_importer.cc',
82         'enums.cc',
83         'event_type_map.cc',
84         'export_channel.cc',
85         'export_channel_configuration.cc',
86         'export_failed.cc',
87         'export_filename.cc',
88         'export_format_base.cc',
89         'export_format_manager.cc',
90         'export_format_specification.cc',
91         'export_formats.cc',
92         'export_formats_search_path.cc',
93         'export_graph_builder.cc',
94         'export_handler.cc',
95         'export_preset.cc',
96         'export_profile_manager.cc',
97         'export_status.cc',
98         'export_timespan.cc',
99         'file_source.cc',
100         'filename_extensions.cc',
101         'filesystem_paths.cc',
102         'filter.cc',
103         'find_session.cc',
104         'globals.cc',
105         'graph.cc',
106         'graphnode.cc',
107         'import.cc',
108         'internal_return.cc',
109         'internal_send.cc',
110         'interpolation.cc',
111         'io.cc',
112         'io_processor.cc',
113         'jack_slave.cc',
114         'ladspa_plugin.cc',
115         'location.cc',
116         'location_importer.cc',
117         'meter.cc',
118         'midi_automation_list_binder.cc',
119         'midi_buffer.cc',
120         'midi_clock_slave.cc',
121         'midi_diskstream.cc',
122         'midi_model.cc',
123         'midi_patch_manager.cc',
124         'midi_patch_search_path.cc',
125         'midi_playlist.cc',
126         'midi_playlist_source.cc',
127         'midi_port.cc',
128         'midi_region.cc',
129         'midi_ring_buffer.cc',
130         'midi_source.cc',
131         'midi_state_tracker.cc',
132         'midi_stretch.cc',
133         'midi_track.cc',
134         'midi_ui.cc',
135         'mix.cc',
136         'monitor_processor.cc',
137         'mtc_slave.cc',
138         'mtdm.cc',
139         'mute_master.cc',
140         'named_selection.cc',
141         'onset_detector.cc',
142         'operations.cc',
143         'pan_controllable.cc',
144         'pannable.cc',
145         'panner.cc',
146         'panner_manager.cc',
147         'panner_search_path.cc',
148         'panner_shell.cc',
149         'pcm_utils.cc',
150         'pi_controller.cc',
151         'playlist.cc',
152         'playlist_factory.cc',
153         'playlist_source.cc',
154         'plugin.cc',
155         'plugin_insert.cc',
156         'plugin_manager.cc',
157         'port.cc',
158         'port_insert.cc',
159         'port_set.cc',
160         'process_thread.cc',
161         'processor.cc',
162         'progress.cc',
163         'quantize.cc',
164         'rc_configuration.cc',
165         'recent_sessions.cc',
166         'region_factory.cc',
167         'resampled_source.cc',
168         'region.cc',
169         'return.cc',
170         'reverse.cc',
171         'route.cc',
172         'route_graph.cc',
173         'route_group.cc',
174         'route_group_member.cc',
175         'rb_effect.cc',
176         'send.cc',
177         'session.cc',
178         'session_butler.cc',
179         'session_click.cc',
180         'session_command.cc',
181         'session_configuration.cc',
182         'session_directory.cc',
183         'session_events.cc',
184         'session_export.cc',
185         'session_handle.cc',
186         'session_metadata.cc',
187         'session_midi.cc',
188         'session_object.cc',
189         'session_playlists.cc',
190         'session_process.cc',
191         'session_rtevents.cc',
192         'session_state.cc',
193         'session_state_utils.cc',
194         'session_time.cc',
195         'session_transport.cc',
196         'session_utils.cc',
197         'slave.cc',
198         'smf_source.cc',
199         'sndfile_helpers.cc',
200         'sndfileimportable.cc',
201         'sndfilesource.cc',
202         'source.cc',
203         'source_factory.cc',
204         'speakers.cc',
205         'strip_silence.cc',
206         'svn_revision.cc',
207         'tape_file_matcher.cc',
208         'template_utils.cc',
209         'tempo.cc',
210         'tempo_map_importer.cc',
211         'thread_buffers.cc',
212         'ticker.cc',
213         'track.cc',
214         'transient_detector.cc',
215         'unknown_processor.cc',
216         'user_bundle.cc',
217         'utils.cc',
218         'version.cc',
219         'worker.cc',
220 ]
221
222 def flac_supported():
223     cmd = subprocess.Popen ("sndfile-info testfile.flac",
224                             stdout = subprocess.PIPE,
225                             stderr = subprocess.STDOUT, shell = True)
226     out = cmd.communicate()[0].decode('utf-8');
227     return re.search ('unknown format', out) == None
228
229 def ogg_supported():
230     cmd = subprocess.Popen ("sndfile-info testfile.ogg",
231                             stdout = subprocess.PIPE,
232                             stderr = subprocess.STDOUT, shell = True)
233     out = cmd.communicate()[0].decode('utf-8');
234     return re.search ('unknown format', out) == None
235
236 def options(opt):
237     autowaf.set_options(opt)
238
239 def configure(conf):
240     conf.load('compiler_cxx')
241     conf.load('gas')
242     autowaf.build_version_files(
243         path_prefix + 'ardour/version.h',
244         path_prefix + 'version.cc',
245         'libardour3', MAJOR, MINOR, MICRO)
246     autowaf.configure(conf)
247     autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO',
248                       atleast_version='0.3.2')
249     autowaf.check_pkg(conf, 'jack', uselib_store='JACK',
250                       atleast_version='0.118.2')
251     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
252     autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF',
253                       atleast_version='0.4.0')
254     autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE',
255                       atleast_version='0.1.0')
256     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP',
257                       atleast_version='2.0')
258     if Options.options.lv2:
259         autowaf.check_pkg(conf, 'lv2', uselib_store='LV2',
260                           atleast_version='1.0.0', mandatory=True)
261         autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD',
262                           atleast_version='0.14.0', mandatory=True)
263         autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',
264                           atleast_version='0.8.0', mandatory=True)
265         autowaf.check_pkg(conf, 'sratom-0', uselib_store='SRATOM',
266                           atleast_version='0.2.0', mandatory=True)
267         autowaf.check_pkg(conf, 'lilv-0', uselib_store='LILV',
268                           atleast_version='0.14.0', mandatory=True)
269         autowaf.check_pkg(conf, 'suil-0', uselib_store='SUIL',
270                           atleast_version='0.6.0', mandatory=False)
271         conf.define ('LV2_SUPPORT', 1)
272
273 #    autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH',
274 #                      mandatory=False)
275     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT',
276                       atleast_version='1.12.0', mandatory=False)
277     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
278     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
279                       atleast_version='1.2.1')
280     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL',
281                       atleast_version='7.0.0')
282
283     # we don't try to detect this, since its part of our source tree
284
285     conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
286     conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
287
288     conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
289
290     conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H',mandatory=False)
291
292     conf.check(header_name='jack/session.h', uselib = [ 'JACK' ],
293                define_name='HAVE_JACK_SESSION')
294
295     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
296
297     conf.check_cc(fragment = '''
298 #include <jack/jack.h>
299 void callback(jack_status_t code, const char* reason, void* arg) { return; }
300 int main(int argc, char **argv) {
301     jack_client_t* c;
302     jack_on_info_shutdown(c, callback, (void*) 0);
303     return 0;
304 }''',
305                   uselib= [ 'JACK' ],
306                   msg = 'Checking for jack_on_info_shutdown',
307                   define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
308                   okmsg = 'present')
309
310     missing_jack_message = 'missing - a version of JACK that supports jack_port_set_latency_range() is required to compile Ardour3.'
311
312     conf.check_cc(fragment = '''
313 #include <jack/jack.h>
314 int main(int argc, char **argv) {
315     jack_port_t* p;
316     jack_latency_range_t r;
317     jack_port_set_latency_range(p, JackCaptureLatency, &r);
318     return 0;
319 }''',
320                   uselib = [ 'JACK' ],
321                   msg = 'Checking for new JACK latency API',
322                   okmsg = 'present',
323                   mandatory = True,
324                   errmsg = missing_jack_message)
325
326     conf.check_cc(fragment = '''
327 #include <jack/jack.h>
328 int main(int argc, char **argv) {
329    jack_port_type_get_buffer_size((jack_client_t*)0, "");
330    return 0;
331 }''',
332                   uselib = [ 'JACK' ],
333                   msg = 'Checking for new jack_port_type_get_buffer_size',
334                   okmsg = 'present',
335                   mandatory = True,
336                   errmsg = missing_jack_message)
337
338     if flac_supported():
339         conf.define ('HAVE_FLAC', 1)
340     if ogg_supported():
341         conf.define ('HAVE_OGG', 1)
342
343     conf.write_config_header('libardour-config.h', remove=False)
344
345     # Boost headers
346     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
347     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
348     autowaf.check_header(conf, 'cxx', 'boost/scoped_ptr.hpp')
349     autowaf.check_header(conf, 'cxx', 'boost/ptr_container/ptr_list.hpp')
350
351
352 def build(bld):
353     # Library
354     obj              = bld(features = 'c cxx cshlib cxxshlib')
355     obj.source       = libardour_sources
356     obj.export_includes = ['.']
357     obj.includes     = ['.', '../surfaces/control_protocol', '..']
358     obj.name         = 'libardour'
359     obj.target       = 'ardour'
360     obj.uselib       = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID',
361                         'JACK','SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS',
362                         'OSX','BOOST','CURL','DL']
363     obj.use          = ['libpbd','libmidipp','libevoral','libvamphost',
364                         'libvampplugin','libtaglib','librubberband',
365                         'libaudiographer']
366     obj.vnum         = LIBARDOUR_LIB_VERSION
367     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
368     obj.defines      = [
369         'PACKAGE="' + I18N_PACKAGE + '"',
370         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
371         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
372         'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
373         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
374         ]
375
376     #obj.source += ' st_stretch.cc st_pitch.cc '
377     #obj.uselib += ' SOUNDTOUCH '
378     #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
379
380     if bld.is_defined('HAVE_LILV') :
381         obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc'] 
382         obj.uselib += ['LILV']
383         if bld.is_defined('HAVE_SUIL'):
384             obj.uselib += ['SUIL']
385
386     if bld.is_defined('WINDOWS_VST_SUPPORT'):
387         obj.source += [ 'windows_vst_plugin.cc']
388         obj.includes += [ '../fst' ]
389         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
390
391     if bld.is_defined('LXVST_SUPPORT'):
392         obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc', 'linux_vst_info_file.cc' ]
393         obj.defines += [ 'LXVST_SUPPORT' ]
394
395     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'):
396         obj.source += [ 'session_vst.cc', 'vst_plugin.cc' ]
397
398     if bld.is_defined('HAVE_COREAUDIO'):
399         obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
400         obj.use    += ['libappleutility']
401
402     if bld.is_defined('AUDIOUNIT_SUPPORT'):
403         obj.source += [ 'audio_unit.cc' ]
404
405     if Options.options.fpu_optimization:
406         if (bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686'):
407             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
408         elif bld.env['build_target'] == 'x86_64':
409             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
410
411     # i18n
412     if bld.is_defined('ENABLE_NLS'):
413         mo_files = bld.path.ant_glob('po/*.mo')
414         for mo in mo_files:
415             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
416             bld.install_as(os.path.join(bld.env['PREFIX'], 'share', 'locale',
417                                         lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
418                            mo)
419
420     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
421         # Unit tests
422         testobj              = bld(features = 'cxx cxxprogram')
423         testobj.source       = '''
424                 test/dummy_lxvst.cc
425                 test/test_needing_session.cc
426                 test/audio_region_test.cc
427                 test/test_globals.cc
428                 test/audio_region_read_test.cc
429                 test/bbt_test.cc
430                 test/tempo_test.cc
431                 test/interpolation_test.cc
432                 test/midi_clock_slave_test.cc
433                 test/resampled_source_test.cc
434                 test/framewalk_to_beats_test.cc
435                 test/framepos_plus_beats_test.cc
436                 test/framepos_minus_beats_test.cc
437                 test/playlist_layering_test.cc
438                 test/playlist_read_test.cc
439                 test/control_surfaces_test.cc
440                 test/combine_regions_test.cc
441                 test/mtdm_test.cc
442                 test/testrunner.cc
443         '''.split()
444
445 # Tests that don't work
446 #                test/mantis_3356_test.cc
447
448         testobj.includes     = obj.includes + ['test', '../pbd']
449         testobj.uselib       = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
450                                 'SAMPLERATE','XML','LRDF','COREAUDIO']
451         testobj.use          = ['libpbd','libmidipp','libardour']
452         testobj.name         = 'libardour-tests'
453         testobj.target       = 'run-tests'
454         testobj.install_path = ''
455         testobj.defines      = [
456             'PACKAGE="libardour3test"',
457             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
458             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
459             'LOCALEDIR="' + os.path.join(
460                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
461             'VAMP_DIR="' + os.path.join(
462                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
463             ]
464         if bld.env['FPU_OPTIMIZATION']:
465             testobj.source += [ 'sse_functions_xmm.cc' ]
466             if (bld.env['build_target'] == 'i386'
467                 or bld.env['build_target'] == 'i686'):
468                 testobj.source += [ 'sse_functions.s' ]
469             elif bld.env['build_target'] == 'x86_64':
470                 testobj.source += [ 'sse_functions_64bit.s' ]
471
472         # Profiling
473         profilingobj = bld(features = 'cxx cxxprogram')
474         profilingobj.source = '''
475                 test/dummy_lxvst.cc
476                 test/profiling/runpc.cc
477         '''.split()
478
479         profilingobj.includes  = obj.includes
480         profilingobj.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
481                              'SAMPLERATE','XML','LRDF','COREAUDIO']
482         profilingobj.use       = ['libpbd','libmidipp','libardour']
483         profilingobj.name      = 'libardour-profiling'
484         profilingobj.target    = 'run-profiling'
485         profilingobj.install_path = ''
486         profilingobj.defines      = [
487             'PACKAGE="libardour3profile"',
488             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
489             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
490             'LOCALEDIR="' + os.path.join(
491                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
492             'VAMP_DIR="' + os.path.join(
493                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
494             ]
495         if bld.env['FPU_OPTIMIZATION']:
496             profilingobj.source += [ 'sse_functions_xmm.cc' ]
497             if (bld.env['build_target'] == 'i386'
498                 or bld.env['build_target'] == 'i686'):
499                 profilingobj.source += [ 'sse_functions.s' ]
500             elif bld.env['build_target'] == 'x86_64':
501                 profilingobj.source += [ 'sse_functions_64bit.s' ]
502
503 def shutdown():
504     autowaf.shutdown()
505
506 def i18n(bld):
507     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
508                        'Paul Davis')
509
510 def i18n_pot(bld):
511     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
512                        'Paul Davis')
513
514 def i18n_po(bld):
515     autowaf.build_i18n_po(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
516                        'Paul Davis')
517
518 def i18n_mo(bld):
519     autowaf.build_i18n_mo(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
520                        'Paul Davis')