Browse Source

WIP: Switch to Meson

zrythm_meson
David Robillard 1 year ago
parent
commit
147f463a14
  1. 3
      .gitmodules
  2. 3
      NEWS
  3. 7
      doc/c/Doxyfile.in
  4. 5
      doc/c/api/meson.build
  5. 9
      doc/c/index.rst
  6. 38
      doc/c/meson.build
  7. 39
      doc/c/wscript
  8. 19
      doc/c/xml/meson.build
  9. 6
      doc/conf.py.in
  10. 16
      doc/meson.build
  11. 4
      doc/summary.rst
  12. 162
      meson.build
  13. 196
      meson/meson.build
  14. 8
      meson_options.txt
  15. 11
      sratom.pc.in
  16. 19
      test/meson.build
  17. 27
      waf
  18. 1
      waflib
  19. 237
      wscript

3
.gitmodules vendored

@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
[submodule "waflib"]
path = waflib
url = ../../drobilla/autowaf.git

3
NEWS

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
sratom (0.6.9) unstable;
* Fix potential blank node ID truncation
* Switch to meson build system
-- David Robillard <d@drobilla.net> Sun, 10 Jan 2021 22:10:23 +0000
-- David Robillard <d@drobilla.net> Sun, 10 Jan 2021 22:12:54 +0000
sratom (0.6.8) stable;

7
doc/c/Doxyfile → doc/c/Doxyfile.in

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
PROJECT_NAME = Sratom
PROJECT_BRIEF = "A small library for serialising LV2 atoms to and from RDF"
PROJECT_BRIEF = "A library for serializing LV2 atoms"
QUIET = YES
WARN_AS_ERROR = NO
@ -21,6 +21,7 @@ SHOW_FILES = NO @@ -21,6 +21,7 @@ SHOW_FILES = NO
MACRO_EXPANSION = YES
PREDEFINED = SRATOM_API
INPUT = ../../include/sratom/sratom.h
STRIP_FROM_PATH = @SRATOM_SRCDIR@
INPUT = @SRATOM_HEADERS@
OUTPUT_DIRECTORY = .
OUTPUT_DIRECTORY = doc/c

5
doc/c/api/meson.build

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
c_sratom_rst = custom_target(
'C API ReST Documentation',
command: [dox_to_sphinx, '-f', '@INPUT0@', 'doc/c/api'],
input: [c_index_xml] + c_rst_files,
output: 'sratom.rst')

9
doc/c/index.rst

@ -1,5 +1,10 @@ @@ -1,5 +1,10 @@
######
Sratom
######
.. include:: summary.rst
.. toctree::
sratom
overview
reference
api/sratom

38
doc/c/meson.build

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
config = configuration_data()
config.set('SRATOM_VERSION', meson.project_version())
conf_py = configure_file(configuration: config,
input: '../conf.py.in',
output: 'conf.py')
configure_file(copy: true, input: '../summary.rst', output: 'summary.rst')
c_rst_files = files(
'index.rst',
'overview.rst',
)
foreach f : c_rst_files
configure_file(copy: true, input: f, output: '@PLAINNAME@')
endforeach
subdir('xml')
subdir('api')
docs = custom_target(
'C API Documentation (singlehtml)',
command: [sphinx_build, '-M', 'singlehtml', 'doc/c/', 'doc/c/', '-E', '-q', '-t', 'singlehtml'],
input: [c_rst_files, c_sratom_rst, c_index_xml],
output: 'singlehtml',
build_by_default: true,
install: true,
install_dir: docdir / 'sratom-0')
docs = custom_target(
'C API Documentation (html)',
command: [sphinx_build, '-M', 'html', 'doc/c/', 'doc/c/', '-E', '-q', '-t', 'html'],
input: [c_rst_files, c_sratom_rst, c_index_xml],
output: 'html',
build_by_default: true,
install: true,
install_dir: docdir / 'sratom-0')

39
doc/c/wscript

@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
#!/usr/bin/env python
def build(bld):
dox_to_sphinx = bld.path.find_node("../../scripts/dox_to_sphinx.py")
index_xml = bld.path.get_bld().make_node("xml/index.xml")
files = [
("../sratom.rst", "sphinx/sratom.rst"),
("index.rst", "sphinx/index.rst"),
("overview.rst", "sphinx/overview.rst"),
("reference.rst", "sphinx/reference.rst"),
]
# Run Doxygen to generate XML documentation
bld(features="doxygen", doxyfile="Doxyfile")
# Substitute variables to make Sphinx configuration file
bld(features="subst",
source="../conf.py.in",
target="sphinx/conf.py",
SERD_VERSION=bld.env.SERD_VERSION)
# Copy static documentation files to Sphinx build directory
for f in files:
bld(features="subst", is_copy=True, source=f[0], target=f[1])
# Generate Sphinx markup from Doxygen XML
bld.add_group()
bld(rule="${PYTHON} " + dox_to_sphinx.abspath() + " -f ${SRC} ${TGT}",
source=index_xml,
target="sphinx/api/")
# Run Sphinx to generate HTML documentation
doc_dir = bld.env.DOCDIR + "/sratom-%s/" % bld.env.SRATOM_MAJOR_VERSION
bld(features="sphinx",
sphinx_source=bld.path.get_bld().make_node("sphinx"),
sphinx_output_format="singlehtml",
sphinx_options=["-E", "-q", "-t", "singlehtml"],
install_path=doc_dir + "c/singlehtml/")

19
doc/c/xml/meson.build

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
doxygen = find_program('doxygen')
c_doxygen_input = []
foreach h : c_headers
c_doxygen_input += ['..' / h]
endforeach
config = configuration_data()
config.set('SRATOM_HEADERS', ' '.join(c_doxygen_input))
config.set('SRATOM_SRCDIR', sratom_src_root)
c_doxyfile = configure_file(configuration: config,
input: '../Doxyfile.in',
output: 'Doxyfile')
c_index_xml = custom_target('c-index.xml',
command: [doxygen, '@INPUT0@'],
input: [c_doxyfile] + c_header_files,
output: 'index.xml')

6
doc/conf.py.in

@ -35,9 +35,9 @@ nitpick_ignore = list(map(lambda x: ("c:identifier", x), _opaque)) @@ -35,9 +35,9 @@ nitpick_ignore = list(map(lambda x: ("c:identifier", x), _opaque))
# HTML output
html_theme = "sphinx_lv2_theme"
html_copy_source = False
html_short_title = "Sratom"
html_theme = "sphinx_lv2_theme"
if tags.has("singlehtml"):
html_sidebars = {
@ -49,7 +49,7 @@ if tags.has("singlehtml"): @@ -49,7 +49,7 @@ if tags.has("singlehtml"):
html_theme_options = {
"body_max_width": "48em",
"body_min_width": "48em",
"description": "A small library for serialising LV2 atoms to and from RDF",
"description": "A library for serializing LV2 atoms",
"globaltoc_collapse": False,
"globaltoc_maxdepth": 3,
"logo_name": True,
@ -64,7 +64,7 @@ else: @@ -64,7 +64,7 @@ else:
html_theme_options = {
"body_max_width": "60em",
"body_min_width": "40em",
"description": "A small library for serialising LV2 atoms to and from RDF",
"description": "A library for serializing LV2 atoms",
"globaltoc_collapse": True,
"globaltoc_maxdepth": 1,
"logo_name": True,

16
doc/meson.build

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
docdir = get_option('datadir') / 'doc'
doxygen = find_program('doxygen', required: get_option('docs'))
dox_to_sphinx = find_program('../scripts/dox_to_sphinx.py')
sphinx_build = find_program('sphinx-build', required: get_option('docs'))
build_docs = doxygen.found() and sphinx_build.found()
if build_docs
subdir('c')
endif
if meson.version().version_compare('>=0.53.0')
summary('Documentation', build_docs, bool_yn: true)
endif

4
doc/sratom.rst → doc/summary.rst

@ -1,7 +1,3 @@ @@ -1,7 +1,3 @@
######
Sratom
######
Sratom is a small library for serialising `LV2 atoms`_ to and from RDF,
for converting between binary and text or storing in a model.

162
meson.build

@ -0,0 +1,162 @@ @@ -0,0 +1,162 @@
project('sratom', ['c'],
version: '0.6.9',
license: 'ISC',
meson_version: '>= 0.49.2',
default_options: [
'b_ndebug=if-release',
'buildtype=release',
'c_std=c99',
'default_library=shared',
'warning_level=2',
])
sratom_src_root = meson.current_source_dir()
major_version = meson.project_version().split('.')[0]
version_suffix = '-@0@'.format(major_version)
versioned_name = 'sratom' + version_suffix
# Load build tools
pkg = import('pkgconfig')
cc = meson.get_compiler('c')
# Set ultra strict warnings for developers, if requested
if get_option('strict')
subdir('meson')
c_warnings = all_c_warnings
if cc.get_id() == 'clang'
c_warnings += [
'-Wno-cast-align',
'-Wno-cast-qual',
'-Wno-double-promotion',
'-Wno-float-conversion',
'-Wno-implicit-float-conversion',
'-Wno-implicit-int-conversion',
'-Wno-nullability-extension',
'-Wno-nullable-to-nonnull-conversion',
'-Wno-padded',
'-Wno-shorten-64-to-32',
'-Wno-sign-conversion',
]
elif cc.get_id() == 'gcc'
c_warnings += [
'-Wno-cast-align',
'-Wno-cast-qual',
'-Wno-conversion',
'-Wno-padded',
'-Wno-suggest-attribute=pure',
'-Wno-unsuffixed-float-constants',
'-Wno-unused-const-variable',
]
elif cc.get_id() == 'msvc'
c_warnings += [
'/wd4242' # conversion with possible loss of data
]
endif
add_project_arguments(cc.get_supported_arguments(c_warnings),
language: ['c'])
endif
# Add special arguments for MSVC
if cc.get_id() == 'msvc'
msvc_args = [
'/D_CRT_SECURE_NO_WARNINGS',
'/TP',
'/experimental:external',
'/external:W0',
'/external:anglebrackets',
]
add_project_arguments(msvc_args, language: ['c'])
endif
c_headers = ['include/sratom/sratom.h']
c_header_files = files(c_headers)
sources = [
'src/sratom.c',
]
# System libraries
m_dep = cc.find_library('m', required: false)
# Dependencies
lv2_dep = dependency('lv2',
version: '>= 1.18.3',
fallback: ['lv2', 'lv2_dep'])
serd_dep = dependency('serd-0',
version: '>= 0.30.9',
fallback: ['serd', 'serd_dep'])
sord_dep = dependency('sord-0',
version: '>= 0.16.9',
fallback: ['sord', 'sord_dep'])
# Determine library type and the flags needed to build it
if get_option('default_library') == 'both'
if host_machine.system() == 'windows'
error('default_library=both is not supported on Windows')
endif
library_type = 'both_libraries'
library_args = ['-DSRATOM_INTERNAL']
prog_args = []
elif get_option('default_library') == 'shared'
library_type = 'shared_library'
library_args = ['-DSRATOM_INTERNAL']
prog_args = []
else
library_type = 'static_library'
library_args = ['-DSRATOM_INTERNAL', '-DSRATOM_STATIC']
prog_args = ['-DSRATOM_STATIC']
endif
# Build shared and/or static library/libraries
libsratom = build_target(
versioned_name,
sources,
version: meson.project_version(),
include_directories: include_directories(['include']),
c_args: library_args,
dependencies: [m_dep, lv2_dep, serd_dep, sord_dep],
gnu_symbol_visibility: 'hidden',
install: true,
target_type: library_type)
sratom_dep = declare_dependency(
include_directories: include_directories(['include']),
dependencies: [m_dep, lv2_dep, serd_dep, sord_dep],
link_with: libsratom)
pkg.generate(
libsratom,
name: 'Sratom',
filebase: versioned_name,
subdirs: [versioned_name],
version: meson.project_version(),
description: 'A library for serializing LV2 atoms')
# Install header to a versioned include directory
install_headers(c_headers, subdir: versioned_name / 'sratom')
if not get_option('docs').disabled()
subdir('doc')
endif
if get_option('tests')
subdir('test')
endif
if meson.version().version_compare('>=0.53.0')
summary('Tests', get_option('tests'), bool_yn: true)
summary('Install prefix', get_option('prefix'))
summary('Headers', get_option('prefix') / get_option('includedir'))
summary('Libraries', get_option('prefix') / get_option('libdir'))
endif
# meson.override_dependency(versioned_name, sratom_dep)

196
meson/meson.build

@ -0,0 +1,196 @@ @@ -0,0 +1,196 @@
# General code to enable approximately all warnings.
#
# This is trivial for clang and MSVC, but GCC does not have such an option, and
# has several esoteric warnings, so we need to enable everything we want
# explicitly. We enable everything that does not require a value argument,
# except for warnings that are only relevant for very old languages (earlier
# than C99 or C++11) or non-standard extensions.
#
# Omitted common warnings:
#
# Wabi=
# Waggregate-return
# Walloc-size-larger-than=BYTES
# Walloca-larger-than=BYTES
# Wframe-larger-than=BYTES
# Wlarger-than=BYTES
# Wstack-usage=BYTES
# Wsystem-headers
# Wtraditional
# Wtraditional-conversion
# Wtrampolines
# Wvla-larger-than=BYTES
#
# Omitted C warnings:
#
# Wc90-c99-compat
# Wdeclaration-after-statement
# Wtraditional
# Wtraditional-conversion
#
# Omitted C++ warnings:
#
# Wnamespaces
# Wtemplates
gcc_common_warnings = [
'-Walloc-zero',
'-Walloca',
'-Wanalyzer-too-complex',
'-Warith-conversion',
'-Warray-bounds=2',
'-Wattribute-alias=2',
'-Wcast-align=strict',
'-Wcast-qual',
'-Wconversion',
'-Wdate-time',
'-Wdisabled-optimization',
'-Wdouble-promotion',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wfloat-equal',
'-Wformat-overflow=2',
'-Wformat-signedness',
'-Wformat-truncation=2',
'-Wformat=2',
'-Wimplicit-fallthrough=2',
'-Winit-self',
'-Winline',
'-Winvalid-pch',
'-Wlogical-op',
'-Wmissing-declarations',
'-Wmissing-include-dirs',
'-Wmultichar',
'-Wnormalized=nfc',
'-Wnull-dereference',
'-Wpacked',
'-Wpadded',
'-Wredundant-decls',
'-Wscalar-storage-order',
'-Wshadow',
'-Wshift-overflow=2',
'-Wsizeof-array-argument',
'-Wstack-protector',
'-Wstrict-aliasing=3',
'-Wstrict-overflow=5',
'-Wstringop-overflow=3',
'-Wsuggest-attribute=cold',
'-Wsuggest-attribute=const',
'-Wsuggest-attribute=format',
'-Wsuggest-attribute=malloc',
'-Wsuggest-attribute=noreturn',
'-Wsuggest-attribute=pure',
'-Wswitch-default',
'-Wswitch-enum',
'-Wsync-nand',
'-Wundef',
'-Wunused-const-variable=2',
'-Wunused-macros',
'-Wvarargs',
'-Wvector-operation-performance',
'-Wvla',
'-Wwrite-strings',
]
gcc_c_warnings = [
'-Wbad-function-cast',
'-Wc++-compat',
'-Wc99-c11-compat',
'-Wdesignated-init',
'-Wdiscarded-array-qualifiers',
'-Wdiscarded-qualifiers',
'-Wincompatible-pointer-types',
'-Wjump-misses-init',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wstrict-prototypes',
'-Wunsuffixed-float-constants',
]
# Set all_c_warnings for the current C compiler
if is_variable('cc')
if cc.get_id() == 'clang'
all_c_warnings = ['-Weverything']
elif cc.get_id() == 'gcc'
all_c_warnings = gcc_common_warnings + [
'-Wbad-function-cast',
'-Wc++-compat',
'-Wc99-c11-compat',
'-Wdesignated-init',
'-Wdiscarded-array-qualifiers',
'-Wdiscarded-qualifiers',
'-Wincompatible-pointer-types',
'-Wjump-misses-init',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wstrict-prototypes',
'-Wunsuffixed-float-constants',
]
elif cc.get_id() == 'msvc'
all_c_warnings = ['/Wall']
else
all_c_warnings = []
endif
endif
# Set all_cpp_warnings for the current C++ compiler
if is_variable('cpp')
if cpp.get_id() == 'clang'
all_cpp_warnings = [
'-Weverything',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic'
]
elif cpp.get_id() == 'gcc'
all_cpp_warnings = gcc_common_warnings + [
'-Wabi-tag',
'-Waligned-new=all',
'-Wcatch-value=3',
'-Wcomma-subscript',
'-Wconditionally-supported',
'-Wctor-dtor-privacy',
'-Wdeprecated-copy-dtor',
'-Weffc++',
'-Wextra-semi',
'-Wmismatched-tags',
'-Wmultiple-inheritance',
'-Wnoexcept',
'-Wnoexcept-type',
'-Wnon-virtual-dtor',
'-Wold-style-cast',
'-Woverloaded-virtual',
'-Wplacement-new=2',
'-Wredundant-tags',
'-Wregister',
'-Wsign-promo',
'-Wstrict-null-sentinel',
'-Wsuggest-final-methods',
'-Wsuggest-final-types',
'-Wsuggest-override',
'-Wuseless-cast',
'-Wvirtual-inheritance',
'-Wvolatile',
'-Wzero-as-null-pointer-constant',
]
elif cpp.get_id() == 'msvc'
all_cpp_warnings = ['/Wall']
else
all_cpp_warnings = []
endif
endif
# Set all_objc_warnings for the current Objective C compiler
if is_variable('objcc')
all_objc_warnings = []
if objcc.get_id() == 'clang'
all_objc_warnings = ['-Weverything']
elif objc.get_id() == 'gcc'
all_objc_warnings = gcc_common_warnings + [
'-Wno-direct-ivar-access',
]
else
all_objc_warnings = []
endif
endif

8
meson_options.txt

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
option('docs', type: 'feature', value: 'auto', yield: true,
description: 'Build documentation')
option('strict', type: 'boolean', value: false, yield: true,
description: 'Enable ultra-strict warnings')
option('tests', type: 'boolean', value: true, yield: true,
description: 'Build tests')

11
sratom.pc.in

@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
prefix=@PREFIX@
exec_prefix=@EXEC_PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
Name: Sratom
Version: @SRATOM_VERSION@
Description: LV2 Atom RDF serialisation library
Requires: @SRATOM_PKG_DEPS@
Libs: -L${libdir} -l@LIB_SRATOM@
Cflags: -I${includedir}/sratom-@SRATOM_MAJOR_VERSION@

19
test/meson.build

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
autoship = find_program('autoship', required: false)
unit_tests = [
'sratom',
]
foreach unit : unit_tests
test(unit,
executable('test_@0@'.format(unit),
'test_@0@.c'.format(unit),
c_args: prog_args,
include_directories: include_directories(['../src']),
dependencies: [sratom_dep, serd_dep, sord_dep]),
suite: 'unit')
endforeach
if autoship.found()
test('autoship', autoship, args: ['test', sratom_src_root], suite: 'data')
endif

27
waf vendored

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
#!/usr/bin/env python
# Minimal waf script for projects that include waflib directly
import sys
import inspect
import os
try:
from waflib import Context, Scripting
except Exception as e:
sys.stderr.write('error: Failed to import waf (%s)\n' % e)
if os.path.exists('.git'):
sys.stderr.write("Are submodules up to date? "
"Try 'git submodule update --init --recursive'\n")
sys.exit(1)
def main():
script_path = os.path.abspath(inspect.getfile(inspect.getmodule(main)))
project_path = os.path.dirname(script_path)
Scripting.waf_entry_point(os.getcwd(), Context.WAFVERSION, project_path)
if __name__ == '__main__':
main()

1
waflib

@ -1 +0,0 @@ @@ -1 +0,0 @@
Subproject commit b600c928b221a001faeab7bd92786d0b25714bc8

237
wscript

@ -1,237 +0,0 @@ @@ -1,237 +0,0 @@
#!/usr/bin/env python
from waflib import Build, Logs, Options
from waflib.extras import autowaf
# Library and package version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
SRATOM_VERSION = '0.6.8'
SRATOM_MAJOR_VERSION = '0'
# Mandatory waf variables
APPNAME = 'sratom' # Package name for waf dist
VERSION = SRATOM_VERSION # Package version for waf dist
top = '.' # Source directory
out = 'build' # Build directory
# Release variables
uri = 'http://drobilla.net/sw/sratom'
dist_pattern = 'http://download.drobilla.net/sratom-%d.%d.%d.tar.bz2'
post_tags = ['Hacking', 'LAD', 'LV2', 'RDF', 'Sratom']
def options(ctx):
ctx.load('compiler_c')
ctx.add_flags(
ctx.configuration_options(),
{'static': 'build static library',
'no-shared': 'do not build shared library'})
def configure(conf):
conf.load('compiler_c', cache=True)
conf.load('autowaf', cache=True)
autowaf.set_c_lang(conf, 'c99')
conf.env.BUILD_SHARED = not Options.options.no_shared
conf.env.BUILD_STATIC = Options.options.static
if not conf.env.BUILD_SHARED and not conf.env.BUILD_STATIC:
conf.fatal('Neither a shared nor a static build requested')
if conf.env.DOCS:
conf.load('sphinx')
if Options.options.strict:
# Check for programs used by lint target
conf.find_program("flake8", var="FLAKE8", mandatory=False)
conf.find_program("clang-tidy", var="CLANG_TIDY", mandatory=False)
conf.find_program("iwyu_tool", var="IWYU_TOOL", mandatory=False)
if Options.options.ultra_strict:
autowaf.add_compiler_flags(conf.env, 'c', {
'gcc': [
'-Wno-cast-align',
'-Wno-cast-qual',
'-Wno-conversion',
'-Wno-padded',
'-Wno-suggest-attribute=pure',
],
'clang': [
'-Wno-cast-align',
'-Wno-cast-qual',
'-Wno-double-promotion',
'-Wno-float-conversion',
'-Wno-implicit-float-conversion',
'-Wno-implicit-int-conversion',
'-Wno-nullability-extension',
'-Wno-nullable-to-nonnull-conversion',
'-Wno-padded',
'-Wno-shorten-64-to-32',
'-Wno-sign-conversion',
],
'msvc': [
'/wd4242' # conversion with possible loss of data
]
})
conf.check_pkg('lv2 >= 1.16.0', uselib_store='LV2')
conf.check_pkg('serd-0 >= 0.30.0', uselib_store='SERD')
conf.check_pkg('sord-0 >= 0.14.0', uselib_store='SORD')
# Set up environment for building/using as a subproject
autowaf.set_lib_env(conf, 'sratom', SRATOM_VERSION,
include_path=str(conf.path.find_node('include')))
autowaf.display_summary(conf, {'Unit tests': bool(conf.env.BUILD_TESTS)})
lib_source = ['src/sratom.c']
def build(bld):
# C Headers
includedir = '${INCLUDEDIR}/sratom-%s/sratom' % SRATOM_MAJOR_VERSION
bld.install_files(includedir, bld.path.ant_glob('include/sratom/*.h'))
# Pkgconfig file
autowaf.build_pc(bld, 'SRATOM', SRATOM_VERSION, SRATOM_MAJOR_VERSION, [],
{'SRATOM_MAJOR_VERSION': SRATOM_MAJOR_VERSION,
'SRATOM_PKG_DEPS': 'lv2 serd-0 sord-0'})
libflags = ['-fvisibility=hidden']
libs = ['m']
defines = []
if bld.env.MSVC_COMPILER:
libflags = []
libs = []
defines = []
# Shared Library
if bld.env.BUILD_SHARED:
bld(features = 'c cshlib',
export_includes = ['include'],
source = lib_source,
includes = ['include'],
lib = libs,
uselib = 'SERD SORD LV2',
name = 'libsratom',
target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
vnum = SRATOM_VERSION,
install_path = '${LIBDIR}',
defines = defines + ['SRATOM_INTERNAL'],
cflags = libflags)
# Static library
if bld.env.BUILD_STATIC:
bld(features = 'c cstlib',
export_includes = ['include'],
source = lib_source,
includes = ['include'],
lib = libs,
uselib = 'SERD SORD LV2',
name = 'libsratom_static',
target = 'sratom-%s' % SRATOM_MAJOR_VERSION,
vnum = SRATOM_VERSION,
install_path = '${LIBDIR}',
defines = defines + ['SRATOM_STATIC', 'SRATOM_INTERNAL'])
if bld.env.BUILD_TESTS:
test_libs = libs
test_cflags = ['']
test_linkflags = ['']
if not bld.env.NO_COVERAGE:
test_cflags += ['--coverage']
test_linkflags += ['--coverage']
# Static library (for unit test code coverage)
bld(features = 'c cstlib',
source = lib_source,
includes = ['include'],
lib = test_libs,
uselib = 'SERD SORD LV2',
name = 'libsratom_profiled',
target = 'sratom_profiled',
install_path = '',
defines = defines + ['SRATOM_STATIC', 'SRATOM_INTERNAL'],
cflags = test_cflags,
linkflags = test_linkflags)
# Unit test program
bld(features = 'c cprogram',
source = 'test/test_sratom.c',
includes = ['include'],
use = 'libsratom_profiled',
lib = test_libs,
uselib = 'SERD SORD LV2',
target = 'test_sratom',
install_path = '',
defines = defines + ['SRATOM_STATIC'],
cflags = test_cflags,
linkflags = test_linkflags)
# Documentation
if bld.env.DOCS:
bld.recurse('doc/c')
bld.add_post_fun(autowaf.run_ldconfig)
def test(tst):
import sys
with tst.group('Integration') as check:
check(['./test_sratom'])
class LintContext(Build.BuildContext):
fun = cmd = 'lint'
def lint(ctx):
"checks code for style issues"
import glob
import os
import subprocess
import sys
st = 0
if "FLAKE8" in ctx.env:
Logs.info("Running flake8")
st = subprocess.call([ctx.env.FLAKE8[0],
"wscript",
"--ignore",
"E101,E129,W191,E221,W504,E251,E241,E741"])
else:
Logs.warn("Not running flake8")
if "IWYU_TOOL" in ctx.env:
Logs.info("Running include-what-you-use")
cmd = [ctx.env.IWYU_TOOL[0], "-o", "clang", "-p", "build"]
output = subprocess.check_output(cmd).decode('utf-8')
if 'error: ' in output:
sys.stdout.write(output)
st += 1
else:
Logs.warn("Not running include-what-you-use")
if "CLANG_TIDY" in ctx.env and "clang" in ctx.env.CC[0]:
Logs.info("Running clang-tidy")
sources = glob.glob('src/*.c') + glob.glob('test/*.c')
sources = list(map(os.path.abspath, sources))
procs = []
for source in sources:
cmd = [ctx.env.CLANG_TIDY[0], "--quiet", "-p=.", source]
procs += [subprocess.Popen(cmd, cwd="build")]
for proc in procs:
stdout, stderr = proc.communicate()
st += proc.returncode
else:
Logs.warn("Not running clang-tidy")
if st != 0:
sys.exit(st)
Loading…
Cancel
Save