forked from roc-streaming/roc-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
1376 lines (1123 loc) · 43.2 KB
/
SConstruct
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
import re
import os
import os.path
import platform
import SCons.Script
# supported platform names
supported_platforms = [
'linux',
'darwin',
'android',
]
# supported compiler names (without version)
supported_compilers = [
'gcc',
'clang',
]
# supported sanitizers
supported_sanitizers = [
'undefined',
'address',
]
# 3rdparty library default versions
thirdparty_versions = {
'libuv': '1.35.0',
'libunwind': '1.2.1',
'openfec': '1.4.2.4',
'sox': '14.4.2',
'alsa': '1.0.29',
'pulseaudio': '5.0',
'json-c': '0.12-20140410',
'ltdl': '2.4.6',
'sndfile': '1.0.28',
'ragel': '6.10',
'gengetopt': '2.22.6',
'cpputest': '3.6',
}
SCons.SConf.dryrun = 0 # configure even in dry run mode
if platform.system() == 'Linux':
# it would be better to use /usr/local on Linux too, but PulseAudio
# is usually installed in /usr and does no search /usr/local for
# dynamic libraries; so by default we also use /usr for consistency
default_prefix = '/usr'
else:
default_prefix = '/usr/local'
AddOption('--prefix',
dest='prefix',
action='store',
type='string',
default=default_prefix,
help="installation prefix, '%s' by default" % default_prefix)
AddOption('--bindir',
dest='bindir',
action='store',
type='string',
default=os.path.join(GetOption('prefix'), 'bin'),
help=("path to the binary installation directory (where to "+
"install Roc command-line tools), '<prefix>/bin' by default"))
AddOption('--libdir',
dest='libdir',
action='store',
type='string',
help=("path to the library installation directory (where to "+
"install Roc library), auto-detect if empty"))
AddOption('--incdir',
dest='incdir',
action='store',
type='string',
default=os.path.join(GetOption('prefix'), 'include'),
help=("path to the headers installation directory (where to "+
"install Roc headers), '<prefix>/include' by default"))
AddOption('--mandir',
dest='mandir',
action='store',
type='string',
default=os.path.join(GetOption('prefix'), 'share/man/man1'),
help=("path to the manuals installation directory (where to "+
"install Roc manual pages), '<prefix>/share/man/man1' by default"))
AddOption('--pulseaudio-module-dir',
dest='pulseaudio_module_dir',
action='store',
type='string',
help=("path to the PulseAudio modules installation directory (where "+
"to install Roc PulseAudio modules), auto-detect if empty"))
AddOption('--build',
dest='build',
action='store',
type='string',
help=("system name where Roc is being compiled, "+
"e.g. 'x86_64-pc-linux-gnu', "+
"auto-detect if empty"))
AddOption('--host',
dest='host',
action='store',
type='string',
help=("system name where Roc will run, "+
"e.g. 'arm-linux-gnueabihf', "+
"auto-detect if empty"))
AddOption('--platform',
dest='platform',
action='store',
choices=([''] + supported_platforms),
help=("platform name where Roc will run, "+
"supported values: empty (detect from host), %s" % (
', '.join(["'%s'" % s for s in supported_platforms]))))
AddOption('--compiler',
dest='compiler',
action='store',
type='string',
help=("compiler name and optional version, e.g. 'gcc-4.9', "+
"supported names: empty (detect what available), %s" % (
', '.join(["'%s'" % s for s in supported_compilers]))))
AddOption('--sanitizers',
dest='sanitizers',
action='store',
type='string',
help="list of gcc/clang sanitizers, "+
"supported names: empty (no sanitizers), 'all', "+
', '.join(["'%s'" % s for s in supported_sanitizers]))
AddOption('--enable-debug',
dest='enable_debug',
action='store_true',
help='enable debug build for Roc')
AddOption('--enable-debug-3rdparty',
dest='enable_debug_3rdparty',
action='store_true',
help='enable debug build for 3rdparty libraries')
AddOption('--enable-werror',
dest='enable_werror',
action='store_true',
help='treat warnings as errors')
AddOption('--enable-pulseaudio-modules',
dest='enable_pulseaudio_modules',
action='store_true',
help='enable building of pulseaudio modules')
AddOption('--disable-lib',
dest='disable_lib',
action='store_true',
help='disable libroc building')
AddOption('--disable-tools',
dest='disable_tools',
action='store_true',
help='disable tools building')
AddOption('--disable-tests',
dest='disable_tests',
action='store_true',
help='disable tests building')
AddOption('--disable-examples',
dest='disable_examples',
action='store_true',
help='disable examples building')
AddOption('--disable-doc',
dest='disable_doc',
action='store_true',
help='disable Doxygen and Sphinx documentation generation')
AddOption('--disable-soversion',
dest='disable_soversion',
action='store_true',
help="don't write version into the shared library"+
" and don't create version symlinks")
AddOption('--disable-openfec',
dest='disable_openfec',
action='store_true',
help='disable OpenFEC support required for FEC codes')
AddOption('--disable-sox',
dest='disable_sox',
action='store_true',
help='disable SoX support in tools')
AddOption('--disable-libunwind',
dest='disable_libunwind',
action='store_true',
help='disable libunwind support required for printing backtrace')
AddOption('--disable-pulseaudio',
dest='disable_pulseaudio',
action='store_true',
help='disable PulseAudio support in tools')
AddOption('--with-pulseaudio',
dest='with_pulseaudio',
action='store',
type='string',
help=("path to the PulseAudio source directory used when "+
"building PulseAudio modules"))
AddOption('--with-pulseaudio-build-dir',
dest='with_pulseaudio_build_dir',
action='store',
type='string',
help=("path to the PulseAudio build directory used when "+
"building PulseAudio modules (needed in case you build "+
"PulseAudio out of source; if empty, the build directory is "+
"assumed to be the same as the source directory)"))
AddOption('--with-openfec-includes',
dest='with_openfec_includes',
action='store',
type='string',
help=("path to the directory with OpenFEC headers (it should contain "+
"lib_common and lib_stable subdirectories)"))
AddOption('--with-includes',
dest='with_includes',
action='append',
type='string',
help=("additional include directory, may be used multiple times"))
AddOption('--with-libraries',
dest='with_libraries',
action='append',
type='string',
help=("additional library directory, may be used multiple times"))
AddOption('--build-3rdparty',
dest='build_3rdparty',
action='store',
type='string',
help=("download and build specified 3rdparty libraries, "+
"pass a comma-separated list of library names and optional versions, "+
"e.g. 'uv:1.4.2,openfec'"))
AddOption('--override-targets',
dest='override_targets',
action='store',
type='string',
help=("override targets to use, "+
"pass a comma-separated list of target names, "+
"e.g. 'glibc,stdio,posix,libuv,openfec,...'"))
# when we cross-compile on macOS to Android using clang, we should use
# GNU-like clang options, but SCons incorrectly sets up Apple-like
# clang options; here we prevent this behavior by forcing 'posix' platform
scons_platform = Environment(ENV=os.environ)['PLATFORM']
for opt in ['host', 'platform']:
if 'android' in (GetOption(opt) or ''):
scons_platform = 'posix'
env = Environment(
ENV=os.environ,
platform=scons_platform,
tools=[
'default',
'roc',
])
# performance tuning
env.Decider('MD5-timestamp')
env.SetOption('implicit_cache', 1)
# provide absolute path to force single sconsign file
# per-directory sconsign files seems to be buggy with generated sources
env.SConsignFile(os.path.join(env.Dir('#').abspath, '.sconsign.dblite'))
# we always use -fPIC, so object files built for static and shared
# libraries are no different
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
if GetOption('help'):
Return()
cleanbuild = [
env.DeleteDir('#bin'),
env.DeleteDir('#build'),
env.DeleteFile('#compile_commands.json'),
]
cleandocs = [
env.DeleteDir('#html'),
env.DeleteDir('#man'),
env.DeleteDir('#build/docs'),
]
cleanall = cleanbuild + cleandocs + [
env.DeleteDir('#3rdparty'),
env.DeleteFile('#config.log'),
env.DeleteDir('#.sconf_temp'),
env.DeleteFile('#.sconsign.dblite'),
]
env.AlwaysBuild(env.Alias('clean', [], cleanall))
env.AlwaysBuild(env.Alias('cleanbuild', [], cleanbuild))
env.AlwaysBuild(env.Alias('cleandocs', [], cleandocs))
if set(COMMAND_LINE_TARGETS).intersection(['clean', 'cleanbuild', 'cleandocs']) or \
env.GetOption('clean'):
if set(COMMAND_LINE_TARGETS) - set(['clean', 'cleanbuild', 'cleandocs']):
env.Die("combining 'clean*' targets with other targets is not allowed")
if env.GetOption('clean'):
env.Execute(cleanall)
Return()
for var in ['CXX', 'CC', 'AR', 'RANLIB', 'RAGEL', 'GENGETOPT', 'PKG_CONFIG', 'CONFIG_GUESS']:
env.OverrideFromArg(var)
env.OverrideFromArg('CXXLD', names=['CXXLD', 'CXX'])
env.OverrideFromArg('CCLD', names=['CCLD', 'LD', 'CC'])
env.OverrideFromArg('STRIP', default='strip')
env.OverrideFromArg('DOXYGEN', default='doxygen')
env.OverrideFromArg('SPHINX_BUILD', default='sphinx-build')
env.OverrideFromArg('BREATHE_APIDOC', default='breathe-apidoc')
if set(COMMAND_LINE_TARGETS).intersection(['doxygen', 'docs']):
enable_doxygen = True
elif GetOption('disable_doc') or set(COMMAND_LINE_TARGETS).intersection(['tidy', 'fmt']):
enable_doxygen = False
else:
doxygen_version = env.ParseCompilerVersion(env['DOXYGEN'])
enable_doxygen = doxygen_version and doxygen_version[:2] >= (1, 6)
if enable_doxygen:
doxygen_targets = [
env.Doxygen(
html_dir='html/doxygen',
build_dir='build/docs/modules',
config='src/modules/Doxyfile',
sources=(env.GlobRecursive('#src/modules', ['*.h', '*.dox']) +
env.GlobRecursive('#docs/images', ['*'])),
werror=GetOption('enable_werror')),
env.Doxygen(
build_dir='build/docs/lib',
config='src/lib/Doxyfile',
sources=env.GlobRecursive('#src/lib/include', ['*.h', '*.dox']),
werror=GetOption('enable_werror')),
]
env.AlwaysBuild(env.Alias('doxygen', doxygen_targets))
if set(COMMAND_LINE_TARGETS).intersection(['sphinx', 'docs']):
enable_sphinx = True
elif GetOption('disable_doc') or set(COMMAND_LINE_TARGETS).intersection(['tidy', 'fmt']):
enable_sphinx = False
elif env.HasArg('SPHINX_BUILD') and env.HasArg('BREATHE_APIDOC'):
enable_sphinx = True
else:
enable_sphinx = env.Which(env['SPHINX_BUILD']) and env.Which(env['BREATHE_APIDOC'])
if enable_doxygen and enable_sphinx:
sphinx_targets = [
env.Sphinx(
build_dir='build',
output_type='html',
output_dir='html/docs',
source_dir='docs/sphinx',
sources=(env.GlobRecursive('docs/sphinx', ['*']) +
env.GlobRecursive('docs/images', ['*']) +
env.GlobRecursive('#src/lib/include', ['*.h', '*.dox']) +
doxygen_targets),
werror=GetOption('enable_werror')),
env.Sphinx(
build_dir='build',
output_type='man',
output_dir='man',
source_dir='docs/sphinx',
sources=env.GlobRecursive('docs/sphinx', ['*']),
werror=GetOption('enable_werror')),
]
env.AlwaysBuild(env.Alias('sphinx', sphinx_targets))
for man in ['roc-send', 'roc-recv', 'roc-conv']:
env.AddDistFile(GetOption('mandir'), '#man/%s.1' % man)
if (enable_doxygen and enable_sphinx) or 'docs' in COMMAND_LINE_TARGETS:
env.AlwaysBuild(env.Alias('docs', ['doxygen', 'sphinx']))
fmt = []
clang_format_tools = ['clang-format']
for n in range(6, 10):
clang_format_tools += ['clang-format-3.%s' % n]
clang_format = None
for tool in clang_format_tools:
if env.Which(tool):
clang_format = tool
break
if clang_format and env.ParseCompilerVersion(clang_format) >= (3, 6):
fmt += [
env.Action(
'%s -i %s' % (clang_format, ' '.join(map(str,
env.GlobRecursive(
'#src', ['*.h', '*.cpp'],
exclude=open(env.File('#.fmtignore').path).read().split())
))),
env.PrettyCommand('FMT', 'src', 'yellow')
),
]
elif 'fmt' in COMMAND_LINE_TARGETS:
print("warning: clang-format >= 3.6 not found")
fmt += [
env.Action(
'%s scripts/format.py src/modules' % env.PythonExecutable(),
env.PrettyCommand('FMT', 'src/modules', 'yellow')
),
env.Action(
'%s scripts/format.py src/tests' % env.PythonExecutable(),
env.PrettyCommand('FMT', 'src/tests', 'yellow')
),
env.Action(
'%s scripts/format.py src/tools' % env.PythonExecutable(),
env.PrettyCommand('FMT', 'src/tools', 'yellow')
),
env.Action(
'%s scripts/format.py src/lib/src' % env.PythonExecutable(),
env.PrettyCommand('FMT', 'src/lib/src', 'yellow')
),
]
env.AlwaysBuild(
env.Alias('fmt', [], fmt))
non_build_targets = ['clean', 'cleandocs', 'fmt', 'docs', 'shpinx', 'doxygen']
if set(COMMAND_LINE_TARGETS) \
and set(COMMAND_LINE_TARGETS).intersection(non_build_targets) == set(COMMAND_LINE_TARGETS):
Return()
build = GetOption('build') or ''
host = GetOption('host') or ''
platform = GetOption('platform') or ''
compiler = GetOption('compiler') or ''
if GetOption('enable_debug'):
variant = 'debug'
else:
variant = 'release'
if GetOption('enable_debug_3rdparty'):
thirdparty_variant = 'debug'
else:
thirdparty_variant = 'release'
# toolchain prefix for compiler, linker, etc
toolchain = host
if not compiler:
if env.HasArg('CXX'):
if 'gcc' in env['CXX'] or 'g++' in env['CXX']:
compiler = 'gcc'
elif 'clang' in env['CXX']:
compiler = 'clang'
else:
if not toolchain and env.Which('clang'):
compiler = 'clang'
else:
compiler = 'gcc'
if '-' in compiler:
compiler, compiler_ver = compiler.split('-')
compiler_ver = tuple(map(int, compiler_ver.split('.')))
else:
if toolchain:
compiler_ver = env.ParseCompilerVersion('%s-%s' % (toolchain, compiler))
else:
compiler_ver = env.ParseCompilerVersion(compiler)
if not compiler in supported_compilers:
env.Die("unknown compiler '%s', expected one of: %s",
compiler, ', '.join(supported_compilers))
if not compiler_ver:
env.Die("can't detect compiler version for compiler '%s'",
'-'.join([s for s in [toolchain, compiler] if s]))
conf = Configure(env, custom_tests=env.CustomTests)
if compiler == 'clang':
conf.FindLLVMDir(compiler_ver)
if compiler == 'clang':
conf.FindTool('CXX', toolchain, compiler_ver, ['clang++'])
elif compiler == 'gcc':
conf.FindTool('CXX', toolchain, compiler_ver, ['g++'])
full_compiler_ver = env.ParseCompilerVersion(conf.env['CXX'])
if full_compiler_ver:
compiler_ver = full_compiler_ver
if not build:
if conf.FindConfigGuess():
build = env.ParseConfigGuess(conf.env['CONFIG_GUESS'])
if not build and not host:
if conf.CheckCanRunProgs():
build = env.ParseCompilerTarget(conf.env['CXX'])
if not build:
for c in ['/usr/bin/gcc', '/usr/bin/clang']:
build = env.ParseCompilerTarget(c)
if build:
break
if not build:
env.Die(("can't detect system type, please specify '--build={type}' manually, "+
"e.g. '--build=x86_64-pc-linux-gnu'"))
if not host:
host = env.ParseCompilerTarget(conf.env['CXX'])
if not host:
host = build
crosscompile = (host != build)
if not platform:
if 'android' in host:
platform = 'android'
elif 'linux' in host:
platform = 'linux'
elif 'darwin' in host:
platform = 'darwin'
if not platform:
env.Die(("can't detect platform for host '%s', looked for one of: %s\nyou should "+
"provide either known '--platform' or '--override-targets' option"),
host, ', '.join(supported_platforms))
if compiler == 'clang':
conf.FindTool('CC', toolchain, compiler_ver, ['clang'])
conf.FindTool('CXXLD', toolchain, compiler_ver, ['clang++'])
conf.FindTool('CCLD', toolchain, compiler_ver, ['clang'])
install_dir = env.ParseCompilerDirectory(conf.env['CXX'])
if install_dir:
prepend_path = [install_dir]
else:
prepend_path = []
conf.FindTool('AR', toolchain, None, ['llvm-ar', 'ar'],
prepend_path=prepend_path)
conf.FindTool('RANLIB', toolchain, None, ['llvm-ranlib', 'ranlib'],
prepend_path=prepend_path)
conf.FindTool('STRIP', toolchain, None, ['llvm-strip', 'strip'],
prepend_path=prepend_path)
elif compiler == 'gcc':
conf.FindTool('CC', toolchain, compiler_ver, ['gcc'])
conf.FindTool('CXXLD', toolchain, compiler_ver, ['g++'])
conf.FindTool('CCLD', toolchain, compiler_ver, ['gcc'])
conf.FindTool('AR', toolchain, None, ['ar'])
conf.FindTool('RANLIB', toolchain, None, ['ranlib'])
conf.FindTool('STRIP', toolchain, None, ['strip'])
env['LINK'] = env['CXXLD']
env['SHLINK'] = env['CXXLD']
env.PrependFromArg('CPPFLAGS')
env.PrependFromArg('CXXFLAGS')
env.PrependFromArg('CFLAGS')
env.PrependFromArg('LINKFLAGS', names=['LINKFLAGS', 'LDFLAGS'])
env.PrependFromArg('STRIPFLAGS')
env = conf.Finish()
compiler_spec = '-'.join(
[s for s in [compiler, '.'.join(map(str, compiler_ver)), variant] if s])
thirdparty_compiler_spec = '-'.join(
[s for s in [compiler, '.'.join(map(str, compiler_ver)), thirdparty_variant] if s])
build_dir = 'build/%s/%s' % (
host,
compiler_spec)
env['ROC_BINDIR'] = '#bin/%s' % host
env['ROC_VERSION'] = env.ParseProjectVersion()
env['ROC_SHA'] = env.ParseGitHead()
if env['ROC_SHA']:
env['ROC_VERSION_STR'] = '%s (%s)' % (env['ROC_VERSION'], env['ROC_SHA'])
else:
env['ROC_VERSION_STR'] = env['ROC_VERSION']
abi_version = '.'.join(env['ROC_VERSION'].split('.')[:2])
env['ROC_MODULES'] = [
'roc_core',
'roc_address',
'roc_packet',
'roc_audio',
'roc_rtp',
'roc_fec',
'roc_netio',
'roc_sndio',
'roc_pipeline',
]
env['ROC_TARGETS'] = []
if GetOption('override_targets'):
for t in GetOption('override_targets').split(','):
env['ROC_TARGETS'] += ['target_%s' % t]
else:
if platform in ['linux', 'android', 'darwin']:
env.Append(ROC_TARGETS=[
'target_posix',
'target_stdio',
'target_gcc',
'target_libuv',
])
if platform in ['linux', 'android']:
env.Append(ROC_TARGETS=[
'target_posixtime',
])
if platform in ['linux']:
if not GetOption('disable_libunwind'):
env.Append(ROC_TARGETS=[
'target_libunwind',
])
else:
env.Append(ROC_TARGETS=[
'target_nobacktrace',
])
if platform in ['android']:
env.Append(ROC_TARGETS=[
'target_bionic',
])
if platform in ['darwin']:
env.Append(ROC_TARGETS=[
'target_darwin',
'target_libunwind',
])
is_glibc = not 'musl' in host
if is_glibc:
env.Append(ROC_TARGETS=[
'target_glibc',
])
else:
env.Append(ROC_TARGETS=[
'target_nodemangle',
])
if not GetOption('disable_openfec'):
env.Append(ROC_TARGETS=[
'target_openfec',
])
if not GetOption('disable_tools') or not GetOption('disable_examples'):
if not GetOption('disable_sox'):
env.Append(ROC_TARGETS=[
'target_sox',
])
if platform in ['linux'] and not GetOption('disable_pulseaudio'):
env.Append(ROC_TARGETS=[
'target_pulseaudio',
])
env.Append(CXXFLAGS=[])
env.Append(CPPDEFINES=[])
env.Append(CPPPATH=[])
env.Append(LIBPATH=[])
env.Append(LIBS=[])
env.Append(STRIPFLAGS=[])
if GetOption('with_includes'):
env.Append(CPPPATH=GetOption('with_includes'))
if GetOption('with_libraries'):
env.Append(LIBPATH=GetOption('with_libraries'))
lib_env = env.Clone()
gen_env = env.Clone()
tool_env = env.Clone()
test_env = env.Clone()
pulse_env = env.Clone()
# all possible dependencies on this platform
all_dependencies = set([t.replace('target_', '') for t in env['ROC_TARGETS']])
# on macos libunwind is provided by the OS
if platform in ['darwin']:
all_dependencies.discard('libunwind')
all_dependencies.add('ragel')
if not GetOption('disable_tools'):
all_dependencies.add('gengetopt')
if not GetOption('disable_tests'):
all_dependencies.add('cpputest')
if ((not GetOption('disable_tools') \
or not GetOption('disable_examples')) \
and not GetOption('disable_pulseaudio')) \
or GetOption('enable_pulseaudio_modules'):
if platform in ['linux', 'android']:
all_dependencies.add('alsa')
all_dependencies.add('pulseaudio')
# dependencies that we should download and build manually
download_dependencies = set()
# dependencies that have explicitly provided version
explicit_version = set()
for name, version in env.ParseThirdParties(GetOption('build_3rdparty')):
if name != 'all' and not name in thirdparty_versions:
env.Die("unknown thirdparty name '%s' in '--build-3rdparty', expected any of: %s",
name, ', '.join(['all'] + list(sorted(thirdparty_versions.keys()))))
download_dependencies.add(name)
if version:
thirdparty_versions[name] = version
explicit_version.add(name)
if 'all' in download_dependencies:
download_dependencies = all_dependencies
# dependencies that should be pre-installed on system
system_dependencies = all_dependencies - download_dependencies
if 'libuv' in system_dependencies:
conf = Configure(env, custom_tests=env.CustomTests)
env.ParsePkgConfig('--cflags --libs libuv')
if not crosscompile:
if not conf.CheckLibWithHeaderExt(
'uv', 'uv.h', 'C', expr='UV_VERSION_MAJOR >= 1 && UV_VERSION_MINOR >= 4'):
env.Die("libuv >= 1.4 not found (see 'config.log' for details)")
else:
if not conf.CheckLibWithHeaderExt('uv', 'uv.h', 'C', run=False):
env.Die("libuv not found (see 'config.log' for details)")
env = conf.Finish()
if 'libunwind' in system_dependencies:
conf = Configure(env, custom_tests=env.CustomTests)
env.ParsePkgConfig('--cflags --libs libunwind')
if not conf.CheckLibWithHeaderExt('unwind', 'libunwind.h', 'C', run=not crosscompile):
env.Die("libunwind not found (see 'config.log' for details)")
env = conf.Finish()
if 'openfec' in system_dependencies:
conf = Configure(env, custom_tests=env.CustomTests)
if env.ParsePkgConfig('--silence-errors --cflags --libs openfec'):
pass
elif GetOption('with_openfec_includes'):
openfec_includes = GetOption('with_openfec_includes')
env.Append(CPPPATH=[
openfec_includes,
'%s/lib_common' % openfec_includes,
'%s/lib_stable' % openfec_includes,
])
elif not crosscompile:
for prefix in ['/usr/local', '/usr']:
if os.path.exists('%s/include/openfec' % prefix):
env.Append(CPPPATH=[
'%s/include/openfec' % prefix,
'%s/include/openfec/lib_common' % prefix,
'%s/include/openfec/lib_stable' % prefix,
])
env.Append(LIBPATH=[
'%s/lib' % prefix,
])
break
if not conf.CheckLibWithHeaderExt(
'openfec', 'of_openfec_api.h', 'C', run=not crosscompile):
env.Die("openfec not found (see 'config.log' for details)")
if not conf.CheckDeclaration('OF_USE_ENCODER', '#include <of_openfec_api.h>', 'c'):
env.Die("openfec has no encoder support (OF_USE_ENCODER)")
if not conf.CheckDeclaration('OF_USE_DECODER', '#include <of_openfec_api.h>', 'c'):
env.Die("openfec has no encoder support (OF_USE_DECODER)")
if not conf.CheckDeclaration('OF_USE_LDPC_STAIRCASE_CODEC',
'#include <of_openfec_api.h>', 'c'):
env.Die(
"openfec has no LDPC-Staircase codec support (OF_USE_LDPC_STAIRCASE_CODEC)")
env = conf.Finish()
if 'pulseaudio' in system_dependencies:
conf = Configure(tool_env, custom_tests=env.CustomTests)
tool_env.ParsePkgConfig('--cflags --libs libpulse')
if not conf.CheckLibWithHeaderExt(
'pulse', 'pulse/pulseaudio.h', 'C', run=not crosscompile):
env.Die("libpulse not found (see 'config.log' for details)")
tool_env = conf.Finish()
if GetOption('enable_pulseaudio_modules'):
conf = Configure(pulse_env, custom_tests=env.CustomTests)
if not conf.CheckLibWithHeaderExt('ltdl', 'ltdl.h', 'C', run=not crosscompile):
env.Die("ltdl not found (see 'config.log' for details)")
pulse_env = conf.Finish()
pa_src_dir = GetOption('with_pulseaudio')
if not pa_src_dir:
env.Die('--enable-pulseaudio-modules requires either --with-pulseaudio'+
' or --build-3rdparty=pulseaudio')
pa_build_dir = GetOption('with_pulseaudio_build_dir')
if not pa_build_dir:
pa_build_dir = pa_src_dir
pulse_env.Append(CPPPATH=[
pa_build_dir,
pa_src_dir + '/src',
])
for lib in ['libpulsecore-*.so', 'libpulsecommon-*.so']:
path = '%s/src/.libs/%s' % (pa_build_dir, lib)
libs = env.Glob(path)
if not libs:
env.Die("can't find %s" % path)
pulse_env.Append(LIBS=libs)
m = re.search('-([0-9.]+).so$', libs[0].path)
if m:
pa_ver = m.group(1)
if not pa_ver:
env.Die("can't determine pulseaudio version")
env['ROC_PULSE_VERSION'] = pa_ver
if 'sox' in system_dependencies:
conf = Configure(tool_env, custom_tests=env.CustomTests)
tool_env.ParsePkgConfig('--cflags --libs sox')
if not crosscompile:
if not conf.CheckLibWithHeaderExt(
'sox', 'sox.h', 'C',
expr='SOX_LIB_VERSION_CODE >= SOX_LIB_VERSION(14, 4, 0)'):
env.Die("libsox >= 14.4.0 not found (see 'config.log' for details)")
else:
if not conf.CheckLibWithHeaderExt('sox', 'sox.h', 'C', run=False):
env.Die("libsox not found (see 'config.log' for details)")
tool_env = conf.Finish()
if 'ragel' in system_dependencies:
conf = Configure(env, custom_tests=env.CustomTests)
if 'RAGEL' in env.Dictionary():
ragel = env['RAGEL']
else:
ragel = 'ragel'
if not conf.CheckProg(ragel):
env.Die("ragel not found in PATH (looked for '%s')" % ragel)
env = conf.Finish()
if 'gengetopt' in system_dependencies:
conf = Configure(env, custom_tests=env.CustomTests)
if 'GENGETOPT' in env.Dictionary():
gengetopt = env['GENGETOPT']
else:
gengetopt = 'gengetopt'
if not conf.CheckProg(gengetopt):
env.Die("gengetopt not found in PATH (looked for '%s')" % gengetopt)
env = conf.Finish()
if 'cpputest' in system_dependencies:
conf = Configure(test_env, custom_tests=env.CustomTests)
test_env.ParsePkgConfig('--cflags --libs cpputest')
if not conf.CheckLibWithHeaderExt(
'CppUTest', 'CppUTest/TestHarness.h', 'CXX', run=not crosscompile):
test_env.Die("CppUTest not found (see 'config.log' for details)")
test_env = conf.Finish()
if 'libuv' in download_dependencies:
env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions, 'libuv')
if 'libunwind' in download_dependencies:
env.ThirdParty(host, thirdparty_compiler_spec,
toolchain, thirdparty_variant,
thirdparty_versions, 'libunwind')
if 'openfec' in download_dependencies:
env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions,
'openfec', includes=[
'lib_common',
'lib_stable',
])
if 'alsa' in download_dependencies:
tool_env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions, 'alsa')
if 'pulseaudio' in download_dependencies:
if not 'pulseaudio' in explicit_version and not crosscompile:
pa_ver = env.ParseToolVersion('pulseaudio --version')
if pa_ver:
thirdparty_versions['pulseaudio'] = pa_ver
pa_deps = [
'ltdl',
'json-c',
'sndfile',
]
if 'alsa' in download_dependencies:
pa_deps += ['alsa']
env['ROC_PULSE_VERSION'] = thirdparty_versions['pulseaudio']
tool_env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions, 'ltdl')
tool_env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions, 'json-c')
tool_env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions, 'sndfile')
tool_env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions,
'pulseaudio', deps=pa_deps, libs=['pulse', 'pulse-simple'])
pa_ver_short = '.'.join(thirdparty_versions['pulseaudio'].split('.')[:2])
pulse_env.ImportThridParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_versions, 'ltdl')
pulse_env.ImportThridParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_versions, 'pulseaudio',
libs=[
'pulsecore-%s' % pa_ver_short,
'pulsecommon-%s' % pa_ver_short
])
if 'sox' in download_dependencies:
sox_deps = []
if 'alsa' in download_dependencies:
sox_deps += ['alsa']
if 'pulseaudio' in download_dependencies:
sox_deps += ['pulseaudio']
tool_env.ThirdParty(host, thirdparty_compiler_spec, toolchain,
thirdparty_variant, thirdparty_versions, 'sox', sox_deps)
conf = Configure(tool_env, custom_tests=env.CustomTests)
for lib in [
'z', 'magic',
'gsm', 'FLAC',
'vorbis', 'vorbisenc', 'vorbisfile', 'ogg',
'mad', 'mp3lame']:
conf.CheckLib(lib)
if not 'alsa' in download_dependencies: