forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
features.py
1345 lines (1098 loc) · 52.7 KB
/
features.py
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
import os
import util
from mixxx import Feature
import SCons.Script as SCons
import depends
class HSS1394(Feature):
def description(self):
return "HSS1394 MIDI device support"
def enabled(self, build):
if build.platform_is_windows or build.platform_is_osx:
build.flags['hss1394'] = util.get_flags(build.env, 'hss1394', 1)
else:
build.flags['hss1394'] = util.get_flags(build.env, 'hss1394', 0)
if int(build.flags['hss1394']):
return True
return False
def add_options(self, build, vars):
if build.platform_is_windows or build.platform_is_osx:
vars.Add('hss1394',
'Set to 1 to enable HSS1394 MIDI device support.', 1)
def configure(self, build, conf):
if not self.enabled(build):
return
if build.platform_is_windows or build.platform_is_osx:
# if not conf.CheckHeader('HSS1394/HSS1394.h'): # WTF this gives tons of cmath errors on MSVC
# raise Exception('Did not find HSS1394 development headers')
# elif not conf.CheckLib(['libHSS1394', 'HSS1394']):
libs = ['libhss1394', 'hss1394']
if build.platform_is_windows:
if build.msvcdebug:
libs = ['libhss1394-debug', 'hss1394-debug',
'libHSS1394_x64_Debug', 'libHSS1394_x86_Debug']
else:
libs = ['libhss1394', 'hss1394',
'libHSS1394_x64_Release', 'libHSS1394_x86_Release']
if not conf.CheckLib(libs):
raise Exception('Did not find HSS1394 development library')
build.env.Append(CPPDEFINES='__HSS1394__')
if build.platform_is_windows and build.static_dependencies:
conf.CheckLib('user32')
def sources(self, build):
return ['controllers/midi/hss1394controller.cpp',
'controllers/midi/hss1394enumerator.cpp']
class HID(Feature):
HIDAPI_INTERNAL_PATH = '#lib/hidapi-0.8.0-pre'
def description(self):
return "HID controller support"
def enabled(self, build):
build.flags['hid'] = util.get_flags(build.env, 'hid', 1)
if int(build.flags['hid']):
return True
return False
def add_options(self, build, vars):
vars.Add('hid', 'Set to 1 to enable HID controller support.', 1)
def configure(self, build, conf):
if not self.enabled(build):
return
# TODO(XXX) allow external hidapi install, but for now we just use our
# internal one.
build.env.Append(
CPPPATH=[os.path.join(self.HIDAPI_INTERNAL_PATH, 'hidapi')])
if build.platform_is_linux:
build.env.ParseConfig(
'pkg-config libusb-1.0 --silence-errors --cflags --libs')
if (not conf.CheckLib(['libusb-1.0', 'usb-1.0']) or
not conf.CheckHeader('libusb-1.0/libusb.h')):
raise Exception(
'Did not find the libusb 1.0 development library or its header file')
# Optionally add libpthread and librt. Some distros need this.
conf.CheckLib(['pthread', 'libpthread'])
conf.CheckLib(['rt', 'librt'])
# -pthread tells GCC to do the right thing regardless of system
build.env.Append(CCFLAGS='-pthread')
build.env.Append(LINKFLAGS='-pthread')
elif build.platform_is_windows and not conf.CheckLib(['setupapi', 'libsetupapi']):
raise Exception('Did not find the setupapi library, exiting.')
elif build.platform_is_osx:
build.env.AppendUnique(FRAMEWORKS=['IOKit', 'CoreFoundation'])
build.env.Append(CPPDEFINES='__HID__')
def sources(self, build):
sources = ['controllers/hid/hidcontroller.cpp',
'controllers/hid/hidenumerator.cpp',
'controllers/hid/hidcontrollerpresetfilehandler.cpp']
if build.platform_is_windows:
# Requires setupapi.lib which is included by the above check for
# setupapi.
sources.append(
os.path.join(self.HIDAPI_INTERNAL_PATH, "windows/hid.c"))
elif build.platform_is_linux:
sources.append(
os.path.join(self.HIDAPI_INTERNAL_PATH, 'linux/hid-libusb.c'))
elif build.platform_is_osx:
sources.append(
os.path.join(self.HIDAPI_INTERNAL_PATH, 'mac/hid.c'))
return sources
class Bulk(Feature):
def description(self):
return "USB Bulk controller support"
def enabled(self, build):
# For now only make Bulk default on Linux only. Turn on for all
# platforms after the 1.11.0 release.
is_default = 1 if build.platform_is_linux else 0
build.flags['bulk'] = util.get_flags(build.env, 'bulk', is_default)
if int(build.flags['bulk']):
return True
return False
def add_options(self, build, vars):
is_default = 1 if build.platform_is_linux else 0
vars.Add('bulk',
'Set to 1 to enable USB Bulk controller support.', is_default)
def configure(self, build, conf):
if not self.enabled(build):
return
build.env.ParseConfig(
'pkg-config libusb-1.0 --silence-errors --cflags --libs')
if (not conf.CheckLib(['libusb-1.0', 'usb-1.0']) or
not conf.CheckHeader('libusb-1.0/libusb.h')):
raise Exception(
'Did not find the libusb 1.0 development library or its header file, exiting!')
build.env.Append(CPPDEFINES='__BULK__')
def sources(self, build):
sources = ['controllers/bulk/bulkcontroller.cpp',
'controllers/bulk/bulkenumerator.cpp']
if not int(build.flags['hid']):
sources.append(
'controllers/hid/hidcontrollerpresetfilehandler.cpp')
return sources
class Mad(Feature):
def description(self):
return "MAD MP3 Decoder"
def default(self, build):
return 0 if build.platform_is_osx else 1
def enabled(self, build):
build.flags['mad'] = util.get_flags(build.env, 'mad',
self.default(build))
if int(build.flags['mad']):
return True
return False
def add_options(self, build, vars):
vars.Add('mad', 'Set to 1 to enable MAD MP3 decoder support.',
self.default(build))
def configure(self, build, conf):
if not self.enabled(build):
return
if not conf.CheckLib(['libmad', 'mad']):
raise Exception(
'Did not find libmad.a, libmad.lib, or the libmad development header files - exiting!')
if not conf.CheckLib(['libid3tag', 'id3tag', 'libid3tag-release']):
raise Exception(
'Did not find libid3tag.a, libid3tag.lib, or the libid3tag development header files - exiting!')
build.env.Append(CPPDEFINES='__MAD__')
def sources(self, build):
return ['soundsourcemp3.cpp']
class CoreAudio(Feature):
def description(self):
return "CoreAudio MP3/AAC Decoder"
def default(self, build):
return 1 if build.platform_is_osx else 0
def enabled(self, build):
build.flags['coreaudio'] = util.get_flags(
build.env, 'coreaudio', self.default(build))
if int(build.flags['coreaudio']):
return True
return False
def add_options(self, build, vars):
vars.Add(
'coreaudio', 'Set to 1 to enable CoreAudio MP3/AAC decoder support.',
self.default(build))
def configure(self, build, conf):
if not self.enabled(build):
return
if not build.platform_is_osx:
raise Exception('CoreAudio is only supported on OS X!')
build.env.Append(CPPPATH='#lib/apple/')
build.env.AppendUnique(FRAMEWORKS=['AudioToolbox', 'CoreFoundation'])
build.env.Append(CPPDEFINES='__COREAUDIO__')
def sources(self, build):
return ['soundsourcecoreaudio.cpp',
'#lib/apple/CAStreamBasicDescription.cpp']
class MediaFoundation(Feature):
FLAG = 'mediafoundation'
def description(self):
return "Media Foundation AAC Decoder Plugin"
def enabled(self, build):
build.flags[self.FLAG] = util.get_flags(build.env, self.FLAG, 0)
if int(build.flags[self.FLAG]):
return True
return False
def add_options(self, build, vars):
if build.platform_is_windows:
vars.Add(
self.FLAG, "Set to 1 to enable the Media Foundation AAC decoder plugin (Windows Vista with KB2117917 or Windows 7 required)", 0)
def configure(self, build, conf):
if not self.enabled(build):
return
if not build.platform_is_windows:
raise Exception("Media Foundation is only supported on Windows!")
# need to look into this, SDK 6 might be ok?
mssdk_path = util.get_mssdk_path()
if mssdk_path is None:
raise Exception(
"MSSdk environment variable not set, have you run setenv?")
include_path = os.path.join(mssdk_path, "Include")
build.env.Append(CPPPATH=[include_path])
if not conf.CheckLib('Ole32'):
raise Exception('Did not find Ole32.lib - exiting!')
if not conf.CheckLib(['Mfuuid']):
raise Exception('Did not find Mfuuid.lib - exiting!')
if not conf.CheckLib(['Mfplat']):
raise Exception('Did not find Mfplat.lib - exiting!')
if not conf.CheckLib(['Mfreadwrite']): # Only available on Windows 7 and up, or properly updated Vista
raise Exception('Did not find Mfreadwrite.lib - exiting!')
build.env.Append(CPPDEFINES='__MEDIAFOUNDATION__')
return
class IPod(Feature):
def description(self):
return "NOT-WORKING iPod Support"
def enabled(self, build):
build.flags['ipod'] = util.get_flags(build.env, 'ipod', 0)
if int(build.flags['ipod']):
return True
return False
def add_options(self, build, vars):
vars.Add('ipod', 'Set to 1 to enable iPod support through libgpod', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
build.env.Append(CPPDEFINES='__IPOD__')
if build.platform_is_windows:
build.env.Append(LIBS='gpod')
# You must check v-this-v directory out from
# http://publicsvn.songbirdnest.com/vendor-
# binaries/trunk/windows-i686-msvc8/libgpod/
build.env.Append(
LIBPATH='../../../windows-i686-msvc8/libgpod/release/lib')
# Following building the following must be added to the dist folder in order for mixxx to run with ipod support on Windows
# \windows-i686-msvc8\libgpod\release\lib\libgpod.dll
# \windows-i686-msvc8\glib\release\bin\libgobject-2.0-0.dll
# \windows-i686-msvc8\glib\release\bin\libglib-2.0-0.dll
# \windows-i686-msvc8\libiconv\release\bin\iconv.dll
# \windows-i686-msvc8\gettext\release\binintl.dll
if build.platform_is_linux or build.platform_is_osx:
# env.Append(LIBS = 'libgpod-1.0')
# env.Append(LIBS = 'glib-2.0')
build.env.ParseConfig(
'pkg-config libgpod-1.0 --silence-errors --cflags --libs')
build.env.ParseConfig(
'pkg-config glib-2.0 --silence-errors --cflags --libs')
def sources(self, build):
return ['wipodtracksmodel.cpp']
class MSVCDebug(Feature):
# FIXME: this flag is also detected in mixxx.py at line 100 because it's needed sooner than this is processed
# I don't know the best way to fix this and still have it show up with
# scons -h. - Sean, Aug 2012
def description(self):
return "MSVC Debugging"
def enabled(self, build):
build.flags['msvcdebug'] = util.get_flags(build.env, 'msvcdebug', 0)
if int(build.flags['msvcdebug']):
return True
return False
def add_options(self, build, vars):
if build.toolchain_is_msvs:
vars.Add('msvcdebug',
'Set to 1 to link against MS libraries with debugging info (implies debug=1)', 0)
def configure(self, build, conf):
if self.enabled(build):
if not build.toolchain_is_msvs:
raise Exception(
"Error, msvcdebug flag set when toolchain is not MSVS.")
# if build.static_dependencies:
# build.env.Append(CCFLAGS = '/MTd')
# else:
# build.env.Append(CCFLAGS = '/MDd')
build.env.Append(CCFLAGS='/MDd')
build.env.Append(LINKFLAGS='/DEBUG')
build.env.Append(CPPDEFINES='DEBUGCONSOLE')
if build.machine_is_64bit:
build.env.Append(CCFLAGS='/Zi')
build.env.Append(LINKFLAGS='/NODEFAULTLIB:MSVCRT')
else:
build.env.Append(CCFLAGS='/ZI')
elif build.toolchain_is_msvs:
# if build.static_dependencies:
# build.env.Append(CCFLAGS = '/MT')
# else:
# build.env.Append(CCFLAGS = '/MD')
build.env.Append(CCFLAGS='/MD')
class VinylControl(Feature):
def description(self):
return "Vinyl Control"
def enabled(self, build):
build.flags['vinylcontrol'] = util.get_flags(build.env,
'vinylcontrol', 0)
# Existence of the macappstore option forces vinylcontrol off due to
# licensing issues.
if build.flags.has_key('macappstore') and int(build.flags['macappstore']):
return False
if int(build.flags['vinylcontrol']):
return True
return False
def add_options(self, build, vars):
vars.Add('vinylcontrol', 'Set to 1 to enable vinyl control support', 1)
def configure(self, build, conf):
if not self.enabled(build):
return
build.env.Append(CPPDEFINES='__VINYLCONTROL__')
build.env.Append(CPPPATH='#lib/xwax')
build.env.Append(CPPPATH='#lib/scratchlib')
def sources(self, build):
sources = ['vinylcontrol/vinylcontrol.cpp',
'vinylcontrol/vinylcontrolxwax.cpp',
'dlgprefvinyl.cpp',
'vinylcontrol/vinylcontrolsignalwidget.cpp',
'vinylcontrol/vinylcontrolmanager.cpp',
'vinylcontrol/vinylcontrolprocessor.cpp',
'vinylcontrol/steadypitch.cpp',
'engine/vinylcontrolcontrol.cpp', ]
if build.platform_is_windows:
sources.append("#lib/xwax/timecoder_win32.cpp")
sources.append("#lib/xwax/lut_win32.cpp")
else:
sources.append("#lib/xwax/timecoder.c")
sources.append("#lib/xwax/lut.c")
return sources
class Vamp(Feature):
INTERNAL_LINK = False
INTERNAL_VAMP_PATH = '#lib/vamp-2.3'
def description(self):
return "Vamp Analysers support"
def enabled(self, build):
build.flags['vamp'] = util.get_flags(build.env, 'vamp', 1)
if int(build.flags['vamp']):
return True
return False
def add_options(self, build, vars):
vars.Add('vamp', 'Set to 1 to enable vamp analysers', 1)
def configure(self, build, conf):
if not self.enabled(build):
return
# If there is no system vamp-hostdk installed, then we'll directly link
# the vamp-hostsdk.
if not conf.CheckLib(['vamp-hostsdk']):
# For header includes
build.env.Append(CPPPATH=[self.INTERNAL_VAMP_PATH])
self.INTERNAL_LINK = True
# Needed on Linux at least. Maybe needed elsewhere?
if build.platform_is_linux:
# Optionally link libdl and libX11. Required for some distros.
conf.CheckLib(['dl', 'libdl'])
conf.CheckLib(['X11', 'libX11'])
# FFTW3 support
have_fftw3_h = conf.CheckHeader('fftw3.h')
have_fftw3 = conf.CheckLib('fftw3', autoadd=False)
if have_fftw3_h and have_fftw3 and build.platform_is_linux:
build.env.Append(CPPDEFINES='HAVE_FFTW3')
build.env.ParseConfig(
'pkg-config fftw3 --silence-errors --cflags --libs')
def sources(self, build):
sources = ['vamp/vampanalyser.cpp',
'vamp/vamppluginloader.cpp',
'analyserbeats.cpp',
'dlgprefbeats.cpp']
if self.INTERNAL_LINK:
hostsdk_src_path = '%s/src/vamp-hostsdk' % self.INTERNAL_VAMP_PATH
sources.extend(path % hostsdk_src_path for path in
['%s/PluginBufferingAdapter.cpp',
'%s/PluginChannelAdapter.cpp',
'%s/PluginHostAdapter.cpp',
'%s/PluginInputDomainAdapter.cpp',
'%s/PluginLoader.cpp',
'%s/PluginSummarisingAdapter.cpp',
'%s/PluginWrapper.cpp',
'%s/RealTime.cpp'])
return sources
class ModPlug(Feature):
def description(self):
return "Modplug module decoder plugin"
def enabled(self, build):
build.flags['modplug'] = util.get_flags(build.env, 'modplug', 0)
if int(build.flags['modplug']):
return True
return False
def add_options(self, build, vars):
vars.Add('modplug',
'Set to 1 to enable libmodplug based module tracker support.', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
build.env.Append(CPPDEFINES='__MODPLUG__')
have_modplug_h = conf.CheckHeader('libmodplug/modplug.h')
have_modplug = conf.CheckLib(['modplug', 'libmodplug'], autoadd=True)
if not have_modplug_h:
raise Exception('Could not find libmodplug development headers.')
if not have_modplug:
raise Exception('Could not find libmodplug shared library.')
def sources(self, build):
depends.Qt.uic(build)('dlgprefmodplugdlg.ui')
return ['soundsourcemodplug.cpp', 'dlgprefmodplug.cpp']
class FAAD(Feature):
def description(self):
return "FAAD AAC audio file decoder plugin"
def enabled(self, build):
build.flags['faad'] = util.get_flags(build.env, 'faad', 0)
if int(build.flags['faad']):
return True
return False
def add_options(self, build, vars):
vars.Add('faad',
'Set to 1 to enable building the FAAD AAC decoder plugin.', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
have_mp4v2_h = conf.CheckHeader('mp4v2/mp4v2.h')
have_mp4v2 = conf.CheckLib(['mp4v2', 'libmp4v2'], autoadd=False)
have_mp4_h = conf.CheckHeader('mp4.h')
have_mp4 = conf.CheckLib('mp4', autoadd=False)
# Either mp4 or mp4v2 works
have_mp4 = (have_mp4v2_h or have_mp4_h) and (have_mp4v2 or have_mp4)
if not have_mp4:
raise Exception(
'Could not find libmp4, libmp4v2 or the libmp4v2 development headers.')
have_faad = conf.CheckLib(['faad', 'libfaad'], autoadd=False)
if not have_faad:
raise Exception(
'Could not find libfaad or the libfaad development headers.')
class WavPack(Feature):
def description(self):
return "WavPack audio file support plugin"
def enabled(self, build):
build.flags['wv'] = util.get_flags(build.env, 'wv', 0)
if int(build.flags['wv']):
return True
return False
def add_options(self, build, vars):
vars.Add('wv',
'Set to 1 to enable building the WavPack support plugin.', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
have_wv = conf.CheckLib(['wavpack', 'wv'], autoadd=False)
if not have_wv:
raise Exception(
'Could not find libwavpack, libwv or its development headers.')
class ColorDiagnostics(Feature):
def description(self):
return "Color Diagnostics"
def enabled(self, build):
build.flags['color'] = util.get_flags(build.env, 'color', 0)
return bool(int(build.flags['color']))
def add_options(self, build, vars):
vars.Add('color', "Set to 1 to enable Clang color diagnostics.", 0)
def configure(self, build, conf):
if not self.enabled(build):
return
if not build.compiler_is_clang:
raise Exception('Color diagnostics are only available using clang.')
build.env.Append(CCFLAGS='-fcolor-diagnostics')
class AddressSanitizer(Feature):
def description(self):
return "Address Sanitizer"
def enabled(self, build):
build.flags['asan'] = util.get_flags(build.env, 'asan', 0)
return bool(int(build.flags['asan']))
def add_options(self, build, vars):
vars.Add("asan", "Set to 1 to enable linking against the Clang AddressSanitizer.", 0)
def configure(self, build, conf):
if not self.enabled(build):
return
if not build.compiler_is_clang:
raise Exception('Address Sanitizer is only available using clang.')
# -fno-omit-frame-pointer gets much better stack traces in asan output.
build.env.Append(CCFLAGS="-fsanitize=address -fno-omit-frame-pointer")
build.env.Append(LINKFLAGS="-fsanitize=address -fno-omit-frame-pointer")
class PerfTools(Feature):
def description(self):
return "Google PerfTools"
def enabled(self, build):
build.flags['perftools'] = util.get_flags(build.env, 'perftools', 0)
build.flags['perftools_profiler'] = util.get_flags(
build.env, 'perftools_profiler', 0)
if int(build.flags['perftools']):
return True
return False
def add_options(self, build, vars):
vars.Add(
"perftools", "Set to 1 to enable linking against libtcmalloc and Google's performance tools. You must install libtcmalloc from google-perftools to use this option.", 0)
vars.Add("perftools_profiler", "Set to 1 to enable linking against libprofiler, Google's CPU profiler. You must install libprofiler from google-perftools to use this option.", 0)
def configure(self, build, conf):
if not self.enabled(build):
return
build.env.Append(LIBS="tcmalloc")
if int(build.flags['perftools_profiler']):
build.env.Append(LIBS="profiler")
class AsmLib(Feature):
def description(self):
return "Agner Fog\'s ASMLIB"
def enabled(self, build):
if build.msvcdebug:
return False
build.flags['asmlib'] = util.get_flags(build.env, 'asmlib', 0)
if int(build.flags['asmlib']):
return True
return False
def add_options(self, build, vars):
vars.Add(
'asmlib', 'Set to 1 to enable linking against Agner Fog\'s hand-optimized asmlib, found at http://www.agner.org/optimize/', 0)
def configure(self, build, conf):
if build.msvcdebug:
self.status = "Disabled (due to MSVC debug mode)"
return
if not self.enabled(build):
return
build.env.Append(LIBPATH='#/../asmlib')
if build.platform_is_linux:
#Use ASMLIB's functions instead of the compiler's
build.env.Append(CCFLAGS='-fno-builtin')
build.env.Prepend(LIBS='":alibelf%so.a"' % build.bitwidth)
elif build.platform_is_osx:
#Use ASMLIB's functions instead of the compiler's
build.env.Append(CCFLAGS='-fno-builtin')
build.env.Prepend(LIBS='":alibmac%so.a"' % build.bitwidth)
elif build.platform_is_windows:
#Use ASMLIB's functions instead of the compiler's
build.env.Append(CCFLAGS='/Oi-')
build.env.Prepend(LIBS='alibcof%so' % build.bitwidth)
class QDebug(Feature):
def description(self):
return "Debugging message output"
def enabled(self, build):
# Meh, repeating this can't hurt, and we require knowing the status of
# msvcdebug.
build.flags['msvcdebug'] = util.get_flags(build.env, 'msvcdebug', 0)
build.flags['qdebug'] = util.get_flags(build.env, 'qdebug', 0)
if build.platform_is_windows:
if int(build.flags['msvcdebug']):
# Turn general debugging flag on too if msvcdebug is specified
build.flags['qdebug'] = 1
if int(build.flags['qdebug']):
return True
return False
def add_options(self, build, vars):
vars.Add(
'qdebug', 'Set to 1 to enable verbose console debug output.', 1)
def configure(self, build, conf):
if not self.enabled(build):
build.env.Append(CPPDEFINES='QT_NO_DEBUG_OUTPUT')
class Verbose(Feature):
def description(self):
return "Verbose compilation output"
def enabled(self, build):
build.flags['verbose'] = util.get_flags(build.env, 'verbose', 1)
if int(build.flags['verbose']):
return True
return False
def add_options(self, build, vars):
vars.Add('verbose', 'Compile files verbosely.', 1)
def configure(self, build, conf):
if not self.enabled(build):
build.env['CCCOMSTR'] = '[CC] $SOURCE'
build.env['CXXCOMSTR'] = '[CXX] $SOURCE'
build.env['ASCOMSTR'] = '[AS] $SOURCE'
build.env['ARCOMSTR'] = '[AR] $TARGET'
build.env['RANLIBCOMSTR'] = '[RANLIB] $TARGET'
build.env['LDMODULECOMSTR'] = '[LD] $TARGET'
build.env['LINKCOMSTR'] = '[LD] $TARGET'
build.env['QT4_LUPDATECOMSTR'] = '[LUPDATE] $SOURCE'
build.env['QT4_LRELEASECOMSTR'] = '[LRELEASE] $SOURCE'
build.env['QT4_QRCCOMSTR'] = '[QRC] $SOURCE'
build.env['QT4_UICCOMSTR'] = '[UIC4] $SOURCE'
build.env['QT4_MOCFROMHCOMSTR'] = '[MOC] $SOURCE'
build.env['QT4_MOCFROMCXXCOMSTR'] = '[MOC] $SOURCE'
build.env['QT5_LUPDATECOMSTR'] = '[LUPDATE] $SOURCE'
build.env['QT5_LRELEASECOMSTR'] = '[LRELEASE] $SOURCE'
build.env['QT5_QRCCOMSTR'] = '[QRC] $SOURCE'
build.env['QT5_UICCOMSTR'] = '[UIC5] $SOURCE'
build.env['QT5_MOCCOMSTR'] = '[MOC] $SOURCE'
class MSVSHacks(Feature):
"""Visual Studio 2005 hacks (MSVS Express Edition users shouldn't enable
this)"""
def description(self):
return "MSVS 2005 hacks"
def enabled(self, build):
build.flags['msvshacks'] = util.get_flags(build.env, 'msvshacks', 0)
if int(build.flags['msvshacks']):
return True
return False
def add_options(self, build, vars):
if build.toolchain_is_msvs:
vars.Add(
'msvshacks', 'Set to 1 to build properly with MS Visual Studio 2005 (Express users should leave this off)', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
build.env.Append(CPPDEFINES='__MSVS2005__')
class Profiling(Feature):
def description(self):
return "gprof/Saturn profiling support"
def enabled(self, build):
build.flags['profiling'] = util.get_flags(build.env, 'profiling', 0)
if int(build.flags['profiling']):
if build.platform_is_linux or build.platform_is_osx or build.platform_is_bsd:
return True
return False
def add_options(self, build, vars):
if not build.platform_is_windows:
vars.Add('profiling',
'(DEVELOPER) Set to 1 to enable profiling using gprof (Linux) or Saturn (OS X)', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
if build.platform_is_linux or build.platform_is_bsd:
build.env.Append(CCFLAGS='-pg')
build.env.Append(LINKFLAGS='-pg')
elif build.platform_is_osx:
build.env.Append(CCFLAGS='-finstrument-functions')
build.env.Append(LINKFLAGS='-lSaturn')
class TestSuite(Feature):
def description(self):
return "Mixxx Test Suite"
def enabled(self, build):
build.flags['test'] = util.get_flags(build.env, 'test', 0) or \
'test' in SCons.BUILD_TARGETS
if int(build.flags['test']):
return True
return False
def add_options(self, build, vars):
vars.Add('test', 'Set to 1 to build Mixxx test fixtures.', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
def sources(self, build):
# Build the gtest library, but don't return any sources.
# Clone our main environment so we don't change any settings in the
# Mixxx environment
test_env = build.env.Clone()
# -pthread tells GCC to do the right thing regardless of system
test_env.Append(CCFLAGS='-pthread')
test_env.Append(LINKFLAGS='-pthread')
test_env.Append(CPPPATH="#lib/gtest-1.7.0/include")
gtest_dir = test_env.Dir("#lib/gtest-1.7.0")
# gtest_dir.addRepository(build.env.Dir('#lib/gtest-1.5.0'))
# build.env['EXE_OUTPUT'] = '#/lib/gtest-1.3.0/bin' # example,
# optional
test_env['LIB_OUTPUT'] = '#/lib/gtest-1.7.0/lib'
env = test_env
SCons.Export('env')
env.SConscript(env.File('SConscript', gtest_dir))
# build and configure gmock
test_env.Append(CPPPATH="#lib/gmock-1.7.0/include")
gmock_dir = test_env.Dir("#lib/gmock-1.7.0")
# gmock_dir.addRepository(build.env.Dir('#lib/gmock-1.5.0'))
test_env['LIB_OUTPUT'] = '#/lib/gmock-1.7.0/lib'
env.SConscript(env.File('SConscript', gmock_dir))
return []
class Shoutcast(Feature):
def description(self):
return "Shoutcast Broadcasting (OGG/MP3)"
def enabled(self, build):
build.flags['shoutcast'] = util.get_flags(build.env, 'shoutcast', 1)
if int(build.flags['shoutcast']):
return True
return False
def add_options(self, build, vars):
vars.Add('shoutcast', 'Set to 1 to enable shoutcast support', 1)
def configure(self, build, conf):
if not self.enabled(build):
return
libshout_found = conf.CheckLib(['libshout', 'shout'])
build.env.Append(CPPDEFINES='__SHOUTCAST__')
if not libshout_found:
raise Exception('Could not find libshout or its development headers. Please install it or compile Mixxx without Shoutcast support using the shoutcast=0 flag.')
if build.platform_is_windows and build.static_dependencies:
conf.CheckLib('winmm')
conf.CheckLib('ws2_32')
def sources(self, build):
depends.Qt.uic(build)('dlgprefshoutcastdlg.ui')
return ['dlgprefshoutcast.cpp',
'shoutcast/shoutcastmanager.cpp',
'engine/sidechain/engineshoutcast.cpp']
class Opus(Feature):
def description(self):
return "Opus (RFC 6716) support"
def enabled(self, build):
build.flags['opus'] = util.get_flags(build.env, 'opus', 0)
if int(build.flags['opus']):
return True
return False
def add_options(self, build, vars):
vars.Add('opus', 'Set to 1 to enable Opus (RFC 6716) support \
(supported are Opus 1.0 and above and Opusfile 0.2 and above)', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
# Supported for Opus (RFC 6716)
# More info http://http://www.opus-codec.org/
if build.platform_is_linux or build.platform_is_osx \
or build.platform_is_bsd:
# Check for libopusfile
# I just randomly picked version numbers lower than mine for this
if not conf.CheckForPKG('opusfile', '0.2'):
raise Exception('Missing libopusfile (needs at least 0.2)')
build.env.Append(CPPDEFINES='__OPUS__')
build.env.ParseConfig('pkg-config opusfile opus --silence-errors \
--cflags --libs')
def sources(self, build):
return ['soundsourceopus.cpp']
class FFMPEG(Feature):
def description(self):
return "FFMPEG/LibAV support"
def enabled(self, build):
build.flags['ffmpeg'] = util.get_flags(build.env, 'ffmpeg', 0)
if int(build.flags['ffmpeg']):
return True
return False
def add_options(self, build, vars):
vars.Add('ffmpeg', 'Set to 1 to enable FFMPEG/Libav support \
(supported FFMPEG 0.11-2.0 and Libav 0.8.x-9.x)', 0)
def configure(self, build, conf):
if not self.enabled(build):
return
# Supported version are FFMPEG 0.11-2.0 and Libav 0.8.x-9.x
# FFMPEG is multimedia library that can be found http://ffmpeg.org/
# Libav is fork of FFMPEG that is used mainly in Debian and Ubuntu
# that can be found http://libav.org
if build.platform_is_linux or build.platform_is_osx \
or build.platform_is_bsd:
# Check for libavcodec, libavformat
# I just randomly picked version numbers lower than mine for this
if not conf.CheckForPKG('libavcodec', '53.35.0'):
raise Exception('Missing libavcodec or it\'s too old! It can'
'be separated from main package so check your'
'operating system packages.')
if not conf.CheckForPKG('libavformat', '53.21.0'):
raise Exception('Missing libavformat or it\'s too old!'
'It can be separated from main package so'
'check your operating system packages.')
# Needed to build new FFMPEG
build.env.Append(CCFLAGS='-D__STDC_CONSTANT_MACROS')
build.env.Append(CCFLAGS='-D__STDC_LIMIT_MACROS')
build.env.Append(CCFLAGS='-D__STDC_FORMAT_MACROS')
# Grabs the libs and cflags for ffmpeg
build.env.ParseConfig('pkg-config libavcodec --silence-errors \
--cflags --libs')
build.env.ParseConfig('pkg-config libavformat --silence-errors \
--cflags --libs')
build.env.ParseConfig('pkg-config libavutil --silence-errors \
--cflags --libs')
# What are libavresample and libswresample??
# Libav forked from FFMPEG in version 0.10 and there wasn't any
# separated library for resampling audio. There we resample API
# (actually two and they are both a big mess). API is now marked as
# depricated but both are still available in current version
# FFMPEG up to version 1.2 or Libav up to version 9
# In some point developers FFMPEG decided to make libswresample
# (Software Resample). Libav people also noticed API problem and
# created libavresample. After that libavresample were imported in
# FFMPEG and it's API/ABI compatible with LibAV.
# If you have FFMPEG version 0.10 or Libav version 0.8.x your
# resampling is done through inner API
# FFMPEG 0.11 Have libswresample but ain't libavresample
# FFMPEG 1.0 and above have libswresample and libavresample
# Libav after 0.8.x and between 9 have some libavresample
# Libav 9 have libavresample have libavresample
# Most Linux systems have separated packages for libswresample/
# libavresample so you can have them installed or not in you
# system most use libavresample.
# Ubuntu/Debian only have Libav 0.8.x available (There is PPA for
# libav 9)
# Fedora uses newest FFMPEG 1.x/2.x (With compability libs)
# openSUSE uses newest FFMPEG 1.x/2.x (With compability libs)
# Mac OS X does have FFMPEG available (with libswresample) from
# macports or homebrew
# Microsoft Windows can download FFMPEG or Libav resample libraries
if conf.CheckForPKG('libavresample', '0.0.3'):
build.env.ParseConfig('pkg-config libavresample \
--silence-errors --cflags --libs')
build.env.Append(CPPDEFINES='__FFMPEGFILE__')
build.env.Append(CPPDEFINES='__LIBAVRESAMPLE__')
self.status = "Enabled -- with libavresample"
elif conf.CheckForPKG('libswresample', '0.0.1'):
build.env.ParseConfig('pkg-config libswresample \
--silence-errors --cflags --libs')
build.env.Append(CPPDEFINES='__FFMPEGFILE__')
build.env.Append(CPPDEFINES='__LIBSWRESAMPLE__')
self.status = "Enabled -- with libswresample"
else:
build.env.Append(CPPDEFINES='__FFMPEGFILE__')
build.env.Append(CPPDEFINES='__FFMPEGOLDAPI__')
self.status = "Enabled -- with old resample API"
else:
# aptitude install libavcodec-dev libavformat-dev liba52-0.7.4-dev
# libdts-dev
# Append some stuff to CFLAGS in Windows also
build.env.Append(CCFLAGS='-D__STDC_CONSTANT_MACROS')
build.env.Append(CCFLAGS='-D__STDC_LIMIT_MACROS')
build.env.Append(CCFLAGS='-D__STDC_FORMAT_MACROS')