Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wscript 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/usr/bin/env python
  2. import os
  3. import subprocess
  4. import waflib.Options as Options
  5. import waflib.extras.autowaf as autowaf
  6. # Library and package version (UNIX style major, minor, micro)
  7. # major increment <=> incompatible changes
  8. # minor increment <=> compatible changes (additions)
  9. # micro increment <=> no interface changes
  10. SRATOM_VERSION = '0.4.6'
  11. SRATOM_MAJOR_VERSION = '0'
  12. # Mandatory waf variables
  13. APPNAME = 'sratom' # Package name for waf dist
  14. VERSION = SRATOM_VERSION # Package version for waf dist
  15. top = '.' # Source directory
  16. out = 'build' # Build directory
  17. def options(opt):
  18. opt.load('compiler_c')
  19. autowaf.set_options(opt)
  20. opt.add_option('--test', action='store_true', dest='build_tests',
  21. help="Build unit tests")
  22. opt.add_option('--static', action='store_true', dest='static',
  23. help="Build static library")
  24. opt.add_option('--no-shared', action='store_true', dest='no_shared',
  25. help='Do not build shared library')
  26. def configure(conf):
  27. conf.load('compiler_c')
  28. autowaf.configure(conf)
  29. autowaf.set_c99_mode(conf)
  30. autowaf.display_header('Sratom Configuration')
  31. conf.env.BUILD_TESTS = Options.options.build_tests
  32. conf.env.BUILD_SHARED = not Options.options.no_shared
  33. conf.env.BUILD_STATIC = Options.options.static
  34. if not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC:
  35. conf.fatal('Neither a shared nor a static build requested')
  36. # Check for gcov library (for test coverage)
  37. if conf.env.BUILD_TESTS:
  38. conf.check_cc(lib='gcov',
  39. define_name='HAVE_GCOV',
  40. mandatory=False)
  41. autowaf.check_pkg(conf, 'lv2', uselib_store='LV2',
  42. atleast_version='1.8.1', mandatory=True)
  43. autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD',
  44. atleast_version='0.14.0', mandatory=True)
  45. autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',
  46. atleast_version='0.12.0', mandatory=True)
  47. autowaf.define(conf, 'SRATOM_VERSION', SRATOM_VERSION)
  48. autowaf.set_lib_env(conf, 'sratom', SRATOM_VERSION)
  49. conf.write_config_header('sratom_config.h', remove=False)
  50. autowaf.display_msg(conf, "Unit tests", str(conf.env.BUILD_TESTS))
  51. print('')
  52. lib_source = ['src/sratom.c']
  53. def build(bld):
  54. # C Headers
  55. includedir = '${INCLUDEDIR}/sratom-%s/sratom' % SRATOM_MAJOR_VERSION
  56. bld.install_files(includedir, bld.path.ant_glob('sratom/*.h'))
  57. # Pkgconfig file
  58. autowaf.build_pc(bld, 'SRATOM', SRATOM_VERSION, SRATOM_MAJOR_VERSION,
  59. ['SERD', 'SORD', 'LV2'],
  60. {'SRATOM_MAJOR_VERSION' : SRATOM_MAJOR_VERSION})
  61. libflags = ['-fvisibility=hidden']
  62. libs = ['m']
  63. defines = []
  64. if bld.env.MSVC_COMPILER:
  65. libflags = []
  66. libs = []
  67. defines = ['snprintf=_snprintf']
  68. # Shared Library
  69. if bld.env.BUILD_SHARED:
  70. obj = bld(features = 'c cshlib',
  71. export_includes = ['.'],
  72. source = lib_source,
  73. includes = ['.', './src'],
  74. lib = libs,
  75. name = 'libsratom',
  76. target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
  77. vnum = SRATOM_VERSION,
  78. install_path = '${LIBDIR}',
  79. defines = defines + ['SRATOM_SHARED', 'SRATOM_INTERNAL'],
  80. cflags = libflags)
  81. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  82. # Static library
  83. if bld.env.BUILD_STATIC:
  84. obj = bld(features = 'c cstlib',
  85. export_includes = ['.'],
  86. source = lib_source,
  87. includes = ['.', './src'],
  88. lib = libs,
  89. name = 'libsratom_static',
  90. target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
  91. vnum = SRATOM_VERSION,
  92. install_path = '${LIBDIR}',
  93. defines = defines + ['SRATOM_INTERNAL'])
  94. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  95. if bld.env.BUILD_TESTS:
  96. test_libs = libs
  97. test_cflags = ['']
  98. if bld.is_defined('HAVE_GCOV'):
  99. test_libs += ['gcov']
  100. test_cflags += ['-fprofile-arcs', '-ftest-coverage']
  101. # Static library (for unit test code coverage)
  102. obj = bld(features = 'c cstlib',
  103. source = lib_source,
  104. includes = ['.', './src'],
  105. lib = test_libs,
  106. name = 'libsratom_profiled',
  107. target = 'sratom_profiled',
  108. install_path = '',
  109. defines = defines + ['SRATOM_INTERNAL'],
  110. cflags = test_cflags)
  111. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  112. # Unit test program
  113. obj = bld(features = 'c cprogram',
  114. source = 'tests/sratom_test.c',
  115. includes = ['.', './src'],
  116. use = 'libsratom_profiled',
  117. lib = test_libs,
  118. target = 'sratom_test',
  119. install_path = '',
  120. defines = defines,
  121. cflags = test_cflags)
  122. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  123. # Documentation
  124. autowaf.build_dox(bld, 'SRATOM', SRATOM_VERSION, top, out)
  125. bld.add_post_fun(autowaf.run_ldconfig)
  126. if bld.env.DOCS:
  127. bld.add_post_fun(fix_docs)
  128. def test(ctx):
  129. autowaf.pre_test(ctx, APPNAME)
  130. os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH')
  131. autowaf.run_tests(ctx, APPNAME, ['sratom_test'], dirs=['./src','./tests'])
  132. autowaf.post_test(ctx, APPNAME)
  133. def lint(ctx):
  134. subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/include src/* sratom/*', shell=True)
  135. def fix_docs(ctx):
  136. if ctx.cmd == 'build':
  137. autowaf.make_simple_dox(APPNAME)
  138. def upload_docs(ctx):
  139. os.system("rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/sratom/")