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.

173 lines
6.5KB

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