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.3KB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.7'
  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('--no-coverage', action='store_true', dest='no_coverage',
  23. help='Do not use gcov for code coverage')
  24. opt.add_option('--static', action='store_true', dest='static',
  25. help="Build static library")
  26. opt.add_option('--no-shared', action='store_true', dest='no_shared',
  27. help='Do not build shared library')
  28. def configure(conf):
  29. conf.load('compiler_c')
  30. autowaf.configure(conf)
  31. autowaf.set_c99_mode(conf)
  32. autowaf.display_header('Sratom Configuration')
  33. conf.env.BUILD_TESTS = Options.options.build_tests
  34. conf.env.BUILD_SHARED = not Options.options.no_shared
  35. conf.env.BUILD_STATIC = Options.options.static
  36. if not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC:
  37. conf.fatal('Neither a shared nor a static build requested')
  38. if conf.env.BUILD_TESTS and not Options.options.no_coverage:
  39. conf.check_cc(lib='gcov', define_name='HAVE_GCOV', mandatory=False)
  40. autowaf.check_pkg(conf, 'lv2', uselib_store='LV2',
  41. atleast_version='1.8.1', mandatory=True)
  42. autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD',
  43. atleast_version='0.14.0', mandatory=True)
  44. autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',
  45. atleast_version='0.12.0', mandatory=True)
  46. autowaf.define(conf, 'SRATOM_VERSION', SRATOM_VERSION)
  47. autowaf.set_lib_env(conf, 'sratom', SRATOM_VERSION)
  48. conf.write_config_header('sratom_config.h', remove=False)
  49. autowaf.display_msg(conf, "Unit tests", bool(conf.env.BUILD_TESTS))
  50. print('')
  51. lib_source = ['src/sratom.c']
  52. def build(bld):
  53. # C Headers
  54. includedir = '${INCLUDEDIR}/sratom-%s/sratom' % SRATOM_MAJOR_VERSION
  55. bld.install_files(includedir, bld.path.ant_glob('sratom/*.h'))
  56. # Pkgconfig file
  57. autowaf.build_pc(bld, 'SRATOM', SRATOM_VERSION, SRATOM_MAJOR_VERSION,
  58. ['SERD', 'SORD', 'LV2'],
  59. {'SRATOM_MAJOR_VERSION' : SRATOM_MAJOR_VERSION})
  60. libflags = ['-fvisibility=hidden']
  61. libs = ['m']
  62. defines = []
  63. if bld.env.MSVC_COMPILER:
  64. libflags = []
  65. libs = []
  66. defines = ['snprintf=_snprintf']
  67. # Shared Library
  68. if bld.env.BUILD_SHARED:
  69. obj = bld(features = 'c cshlib',
  70. export_includes = ['.'],
  71. source = lib_source,
  72. includes = ['.', './src'],
  73. lib = libs,
  74. name = 'libsratom',
  75. target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
  76. vnum = SRATOM_VERSION,
  77. install_path = '${LIBDIR}',
  78. defines = defines + ['SRATOM_SHARED', 'SRATOM_INTERNAL'],
  79. cflags = libflags)
  80. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  81. # Static library
  82. if bld.env.BUILD_STATIC:
  83. obj = bld(features = 'c cstlib',
  84. export_includes = ['.'],
  85. source = lib_source,
  86. includes = ['.', './src'],
  87. lib = libs,
  88. name = 'libsratom_static',
  89. target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
  90. vnum = SRATOM_VERSION,
  91. install_path = '${LIBDIR}',
  92. defines = defines + ['SRATOM_INTERNAL'])
  93. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  94. if bld.env.BUILD_TESTS:
  95. test_libs = libs
  96. test_cflags = ['']
  97. if bld.is_defined('HAVE_GCOV'):
  98. test_libs += ['gcov']
  99. test_cflags += ['-fprofile-arcs', '-ftest-coverage']
  100. # Static library (for unit test code coverage)
  101. obj = bld(features = 'c cstlib',
  102. source = lib_source,
  103. includes = ['.', './src'],
  104. lib = test_libs,
  105. name = 'libsratom_profiled',
  106. target = 'sratom_profiled',
  107. install_path = '',
  108. defines = defines + ['SRATOM_INTERNAL'],
  109. cflags = test_cflags)
  110. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  111. # Unit test program
  112. obj = bld(features = 'c cprogram',
  113. source = 'tests/sratom_test.c',
  114. includes = ['.', './src'],
  115. use = 'libsratom_profiled',
  116. lib = test_libs,
  117. target = 'sratom_test',
  118. install_path = '',
  119. defines = defines,
  120. cflags = test_cflags)
  121. autowaf.use_lib(bld, obj, 'SERD SORD LV2')
  122. # Documentation
  123. autowaf.build_dox(bld, 'SRATOM', SRATOM_VERSION, top, out)
  124. bld.add_post_fun(autowaf.run_ldconfig)
  125. if bld.env.DOCS:
  126. bld.add_post_fun(fix_docs)
  127. def test(ctx):
  128. autowaf.pre_test(ctx, APPNAME)
  129. os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH')
  130. autowaf.run_tests(ctx, APPNAME, ['sratom_test'], dirs=['./src','./tests'])
  131. autowaf.post_test(ctx, APPNAME)
  132. def lint(ctx):
  133. 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)
  134. def fix_docs(ctx):
  135. if ctx.cmd == 'build':
  136. autowaf.make_simple_dox(APPNAME)
  137. def upload_docs(ctx):
  138. os.system("rsync -ravz --delete -e ssh build/doc/html/ drobilla@drobilla.net:~/drobilla.net/docs/sratom/")