summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--meson.build262
-rw-r--r--meson/meson.build196
-rw-r--r--meson_options.txt5
-rw-r--r--suil.pc.in11
-rwxr-xr-xwaf27
m---------waflib0
-rw-r--r--wscript468
9 files changed, 463 insertions, 511 deletions
diff --git a/.gitignore b/.gitignore
index 204c242..467d5b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,2 @@
build/**
-.waf-*
-.lock-waf*
__pycache__
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index cc8b569..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "waflib"]
- path = waflib
- url = ../../drobilla/autowaf.git
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..7a413ff
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,262 @@
+project('suil', ['c', 'cpp'],
+ version: '0.24.13',
+ license: 'ISC',
+ meson_version: '>= 0.49.2',
+ default_options: [
+ 'b_ndebug=if-release',
+ 'buildtype=release',
+ 'c_std=c99',
+ 'default_library=both',
+ 'warning_level=2',
+ ])
+
+suil_src_root = meson.current_source_dir()
+major_version = meson.project_version().split('.')[0]
+version_suffix = '-@0@'.format(major_version)
+versioned_name = 'suil' + version_suffix
+
+# Load build tools
+pkg = import('pkgconfig')
+cc = meson.get_compiler('c')
+cpp = meson.get_compiler('cpp')
+
+# Enable Objective C support if we're building for MacOS
+if host_machine.system() == 'darwin'
+ add_languages(['objc'])
+ objcc = meson.get_compiler('objc')
+endif
+
+# 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-atomic-implicit-seq-cst',
+ '-Wno-cast-qual',
+ '-Wno-disabled-macro-expansion',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-variadic-macros',
+ ]
+ elif cc.get_id() == 'gcc'
+ c_warnings += [
+ '-Wno-padded',
+ '-Wno-suggest-attribute=const',
+ '-Wno-suggest-attribute=pure',
+ '-Wno-extra-semi', # Qt headers
+ ]
+ elif cc.get_id() == 'msvc'
+ c_warnings += [
+ '/wd4514', # unreferenced inline function has been removed
+ '/wd4820', # padding added after construct
+ '/wd4191', # unsafe function conversion
+ '/wd5045', # will insert Spectre mitigation for memory load
+ ]
+ endif
+
+ add_project_arguments(cc.get_supported_arguments(c_warnings),
+ language: ['c'])
+
+ cpp_warnings = all_cpp_warnings
+ if cpp.get_id() == 'clang'
+ cpp_warnings += [
+ '-Wno-atomic-implicit-seq-cst',
+ '-Wno-cast-qual',
+ '-Wno-disabled-macro-expansion',
+ '-Wno-old-style-cast',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-variadic-macros',
+ '-Wno-zero-as-null-pointer-constant',
+ ]
+ elif cpp.get_id() == 'gcc'
+ cpp_warnings += [
+ '-Wno-cast-qual',
+ '-Wno-padded',
+ '-Wno-suggest-attribute=const',
+ '-Wno-suggest-attribute=pure',
+ '-Wno-useless-cast',
+ '-Wno-volatile',
+ ]
+ endif
+
+ add_project_arguments(cpp.get_supported_arguments(cpp_warnings),
+ language: ['cpp'])
+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/suil/suil.h']
+c_header_files = files(c_headers)
+
+sources = [
+ 'src/host.c',
+ 'src/instance.c',
+]
+
+# System libraries
+dl_dep = cc.find_library('dl', required: false)
+
+# Dependencies
+
+lv2_dep = dependency('lv2',
+ version: '>= 1.18.3',
+ fallback: ['lv2', 'lv2_dep'])
+
+x11_dep = dependency('x11', required: false)
+gtk2_dep = dependency('gtk+-2.0', version: '>=2.18.0', required: false)#, include_type: 'system')
+gtk2_x11_dep = dependency('gtk+-x11-2.0', required: false)#, include_type: 'system')
+gtk2_quartz_dep = dependency('gtk+-quartz-2.0', required: false)#, include_type: 'system')
+gtk3_dep = dependency('gtk+-3.0', version: '>=3.14.0', required: false)#, include_type: 'system')
+gtk3_x11_dep = dependency('gtk+-x11-3.0', version: '>=3.14.0', required: false)#, include_type: 'system')
+qt5_dep = dependency('Qt5Widgets', version: '>=5.1.0', required: false)#, include_type: 'system')
+qt5_x11_dep = dependency('Qt5X11Extras', version: '>=5.1.0', required: false)#, include_type: 'system')
+# qt5_cocoa_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 = ['-DSUIL_INTERNAL']
+ prog_args = []
+elif get_option('default_library') == 'shared'
+ library_type = 'shared_library'
+ library_args = ['-DSUIL_INTERNAL']
+ prog_args = []
+else
+ library_type = 'static_library'
+ library_args = ['-DSUIL_INTERNAL', '-DSUIL_STATIC']
+ prog_args = ['-DSUIL_STATIC']
+endif
+
+# Build main shared and/or static library/libraries
+libsuil = build_target(
+ versioned_name,
+ sources,
+ version: meson.project_version(),
+ include_directories: include_directories(['include']),
+ c_args: library_args,
+ dependencies: [dl_dep, lv2_dep],
+ gnu_symbol_visibility: 'hidden',
+ install: true,
+ target_type: library_type)
+
+suil_dep = declare_dependency(
+ include_directories: include_directories(['include']),
+ dependencies: [dl_dep],
+ link_with: libsuil)
+
+pkg.generate(
+ libsuil,
+ name: 'Suil',
+ filebase: versioned_name,
+ subdirs: [versioned_name],
+ version: meson.project_version(),
+ description: 'A library for hosting LV2 plugin UIs')
+
+# Install header to a versioned include directory
+install_headers(c_headers, subdir: versioned_name / 'suil')
+
+# # if not get_option('docs').disabled()
+# # subdir('doc')
+# # endif
+
+# if get_option('tests')
+# subdir('test')
+# endif
+
+if gtk2_dep.found() and qt5_dep.found()
+ shared_module('suil_gtk2_in_qt5',
+ 'src/gtk2_in_qt5.cpp',
+ dependencies: [gtk2_dep, lv2_dep, qt5_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+
+ shared_module('suil_qt5_in_gtk2',
+ 'src/qt5_in_gtk.cpp',
+ dependencies: [gtk3_dep, lv2_dep, qt5_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+endif
+
+if gtk2_dep.found() and gtk2_x11_dep.found() and x11_dep.found()
+ shared_module('suil_x11_in_gtk2',
+ 'src/x11_in_gtk2.c',
+ dependencies: [gtk2_dep, gtk2_x11_dep, lv2_dep, x11_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+endif
+
+if gtk3_dep.found() and gtk3_x11_dep.found() and x11_dep.found()
+ shared_module('suil_x11_in_gtk3',
+ 'src/x11_in_gtk3.c',
+ dependencies: [gtk3_dep, gtk3_x11_dep, lv2_dep, x11_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+endif
+
+if gtk3_dep.found() and qt5_dep.found()
+ shared_module('suil_qt5_in_gtk3',
+ 'src/qt5_in_gtk.cpp',
+ dependencies: [gtk3_dep, lv2_dep, qt5_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+endif
+
+if gtk2_dep.found() and gtk2_quartz_dep.found()
+ shared_module('suil_cocoa_in_gtk2',
+ 'src/cocoa_in_gtk2.mm',
+ dependencies: [gtk3_dep, lv2_dep, qt5_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+endif
+
+if gtk2_dep.found() and host_machine.system() == 'windows'
+ shared_module('suil_win_in_gtk2',
+ 'src/win_in_gtk2.cpp',
+ dependencies: [gtk2_dep, lv2_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+endif
+
+if qt5_dep.found() and qt5_x11_dep.found()
+ shared_module('suil_x11_in_qt5',
+ 'src/x11_in_qt5.cpp',
+ dependencies: [lv2_dep, qt5_dep, qt5_x11_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_directories(['include']),
+ install: true)
+
+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
diff --git a/meson/meson.build b/meson/meson.build
new file mode 100644
index 0000000..20e0522
--- /dev/null
+++ b/meson/meson.build
@@ -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
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..6e03098
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('docs', type: 'feature', value: 'auto', yield: true,
+ description: 'Build documentation')
+
+option('strict', type: 'boolean', value: false, yield: true,
+ description: 'Enable ultra-strict warnings')
diff --git a/suil.pc.in b/suil.pc.in
deleted file mode 100644
index 66810a6..0000000
--- a/suil.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: Suil
-Version: @SUIL_VERSION@
-Description: LV2 plugin UI hosting library
-Requires: @SUIL_PKG_DEPS@
-Libs: -L${libdir} -l@LIB_SUIL@
-Cflags: -I${includedir}/suil-@SUIL_MAJOR_VERSION@
diff --git a/waf b/waf
deleted file mode 100755
index 887215c..0000000
--- a/waf
+++ /dev/null
@@ -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()
diff --git a/waflib b/waflib
deleted file mode 160000
-Subproject b600c928b221a001faeab7bd92786d0b25714bc
diff --git a/wscript b/wscript
deleted file mode 100644
index e95b2dc..0000000
--- a/wscript
+++ /dev/null
@@ -1,468 +0,0 @@
-#!/usr/bin/env python
-
-from waflib import Build, Logs, Options, TaskGen
-from waflib.extras import autowaf
-
-# Semver package/library version
-SUIL_VERSION = '0.10.11'
-SUIL_MAJOR_VERSION = SUIL_VERSION[0:SUIL_VERSION.find('.')]
-
-# Mandatory waf variables
-APPNAME = 'suil' # Package name for waf dist
-VERSION = SUIL_VERSION # Package version for waf dist
-top = '.' # Source directory
-out = 'build' # Build directory
-
-# Release variables
-uri = 'http://drobilla.net/sw/suil'
-dist_pattern = 'http://download.drobilla.net/suil-%d.%d.%d.tar.bz2'
-post_tags = ['Hacking', 'LAD', 'LV2', 'Suil']
-
-
-def options(ctx):
- ctx.load('compiler_c')
- ctx.load('compiler_cxx')
- opt = ctx.configuration_options()
-
- opt.add_option('--gtk2-lib-name', type='string', dest='gtk2_lib_name',
- default="libgtk-x11-2.0.so.0",
- help="Gtk2 library name [Default: libgtk-x11-2.0.so.0]")
- opt.add_option('--gtk3-lib-name', type='string', dest='gtk3_lib_name',
- default="libgtk-x11-3.0.so.0",
- help="Gtk3 library name [Default: libgtk-x11-3.0.so.0]")
-
- ctx.add_flags(
- opt,
- {'static': 'build static library',
- 'no-shared': 'do not build shared library',
- 'no-cocoa': 'do not build support for Cocoa/Quartz',
- 'no-gtk': 'do not build support for Gtk',
- 'no-qt': 'do not build support for Qt (any version)',
- 'no-qt5': 'do not build support for Qt5',
- 'no-x11': 'do not build support for X11'})
-
-
-def configure(conf):
- conf.load('compiler_c', cache=True)
- conf.load('compiler_cxx', cache=True)
- conf.load('autowaf', cache=True)
- autowaf.set_c_lang(conf, 'c99')
-
- conf.env.BUILD_SHARED = not conf.options.no_shared
- conf.env.BUILD_STATIC = conf.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, '*', {
- 'gcc': [
- '-Wno-padded',
- '-Wno-suggest-attribute=const',
- '-Wno-suggest-attribute=pure',
- ],
- 'clang': [
- '-Wno-cast-qual',
- '-Wno-disabled-macro-expansion',
- '-Wno-padded',
- ]
- })
-
- autowaf.add_compiler_flags(conf.env, 'c', {
- 'msvc': [
- '/wd4514', # unreferenced inline function has been removed
- '/wd4820', # padding added after construct
- '/wd4191', # unsafe function conversion
- '/wd5045', # will insert Spectre mitigation for memory load
- ],
- })
-
- conf.env.NODELETE_FLAGS = []
- if (not conf.env.MSVC_COMPILER and
- conf.check(linkflags = ['-Wl,-z,nodelete'],
- msg = 'Checking for link flags -Wl,-z,-nodelete',
- mandatory = False)):
- conf.env.NODELETE_FLAGS = ['-Wl,-z,nodelete']
-
- conf.check_pkg('lv2 >= 1.16.0', uselib_store='LV2')
-
- if not conf.options.no_x11:
- conf.check_pkg('x11', uselib_store='X11', system=True, mandatory=False)
-
- def enable_module(var_name):
- conf.env[var_name] = 1
-
- if not conf.options.no_gtk:
- conf.check_pkg('gtk+-2.0 >= 2.18.0',
- uselib_store='GTK2',
- system=True,
- mandatory=False)
- if not conf.env.HAVE_GTK2:
- conf.check_pkg('gtk+-2.0',
- uselib_store='GTK2',
- system=True,
- mandatory=False)
- if conf.env.HAVE_GTK2:
- conf.define('SUIL_OLD_GTK', 1)
-
- if not conf.options.no_x11:
- conf.check_pkg('gtk+-x11-2.0',
- uselib_store='GTK2_X11',
- system=True,
- mandatory=False)
-
- if not conf.options.no_cocoa:
- conf.check_pkg('gtk+-quartz-2.0',
- uselib_store='GTK2_QUARTZ',
- system=True,
- mandatory=False)
-
- conf.check_pkg('gtk+-3.0 >= 3.14.0',
- uselib_store='GTK3',
- system=True,
- mandatory=False)
-
- if not conf.options.no_x11:
- conf.check_pkg('gtk+-x11-3.0 >= 3.14.0',
- uselib_store='GTK3_X11',
- system=True,
- mandatory=False)
-
- if not conf.options.no_qt:
- if not conf.options.no_qt5:
- conf.check_pkg('Qt5Widgets >= 5.1.0',
- uselib_store='QT5',
- system=True,
- mandatory=False)
-
- if not conf.options.no_x11:
- conf.check_pkg('Qt5X11Extras >= 5.1.0',
- uselib_store='QT5_X11',
- system=True,
- mandatory=False)
-
- if not conf.options.no_cocoa:
- if conf.check_cxx(header_name = 'QMacCocoaViewContainer',
- uselib = 'QT5_COCOA',
- system=True,
- mandatory = False):
- enable_module('SUIL_WITH_COCOA_IN_QT5')
-
- conf.check_cc(define_name = 'HAVE_LIBDL',
- lib = 'dl',
- mandatory = False)
-
- conf.define('SUIL_MODULE_DIR',
- conf.env.LIBDIR + '/suil-' + SUIL_MAJOR_VERSION)
-
- conf.define('SUIL_GTK2_LIB_NAME', conf.options.gtk2_lib_name)
- conf.define('SUIL_GTK3_LIB_NAME', conf.options.gtk3_lib_name)
-
- if conf.env.HAVE_GTK2 and conf.env.HAVE_QT5:
- enable_module('SUIL_WITH_GTK2_IN_QT5')
- enable_module('SUIL_WITH_QT5_IN_GTK2')
-
- if conf.env.HAVE_GTK2 and conf.env.HAVE_GTK2_X11:
- enable_module('SUIL_WITH_X11_IN_GTK2')
-
- if conf.env.HAVE_GTK3 and conf.env.HAVE_GTK3_X11:
- enable_module('SUIL_WITH_X11_IN_GTK3')
-
- if conf.env.HAVE_GTK3 and conf.env.HAVE_QT5:
- enable_module('SUIL_WITH_QT5_IN_GTK3')
-
- if conf.env.HAVE_GTK2 and conf.env.HAVE_GTK2_QUARTZ:
- enable_module('SUIL_WITH_COCOA_IN_GTK2')
-
- if conf.env.HAVE_GTK2 and conf.env.DEST_OS == 'win32':
- enable_module('SUIL_WITH_WIN_IN_GTK2')
-
- if conf.env.HAVE_QT5 and conf.env.HAVE_QT5_X11:
- enable_module('SUIL_WITH_X11_IN_QT5')
-
- if conf.env.HAVE_X11:
- enable_module('SUIL_WITH_X11')
-
- conf.run_env.append_unique('SUIL_MODULE_DIR', [conf.build_path()])
-
- # Set up environment for building/using as a subproject
- autowaf.set_lib_env(conf, 'suil', SUIL_VERSION,
- include_path=str(conf.path.find_node('include')))
-
- conf.define('SUIL_NO_DEFAULT_CONFIG', 1)
-
- autowaf.display_summary(
- conf,
- {'Static library': bool(conf.env.BUILD_STATIC),
- 'Shared library': bool(conf.env.BUILD_SHARED)})
-
- if conf.env.HAVE_GTK2:
- autowaf.display_msg(conf, "Gtk2 Library Name",
- conf.get_define('SUIL_GTK2_LIB_NAME'))
- if conf.env.HAVE_GTK3:
- autowaf.display_msg(conf, "Gtk3 Library Name",
- conf.get_define('SUIL_GTK3_LIB_NAME'))
-
- # Print summary message for every potentially supported wrapper
- wrappers = [('cocoa', 'gtk2'),
- ('gtk2', 'qt5'),
- ('qt5', 'gtk2'),
- ('win', 'gtk2'),
- ('x11', 'gtk2'),
- ('x11', 'gtk3'),
- ('qt5', 'gtk3'),
- ('x11', 'qt5'),
- ('cocoa', 'qt5')]
- for w in wrappers:
- var = 'SUIL_WITH_%s_IN_%s' % (w[0].upper(), w[1].upper())
- autowaf.display_msg(conf, 'Support for %s in %s' % (w[0], w[1]),
- bool(conf.env[var]))
-
-
-def build(bld):
- # C Headers
- includedir = '${INCLUDEDIR}/suil-%s/suil' % SUIL_MAJOR_VERSION
- bld.install_files(includedir, bld.path.ant_glob('include/suil/*.h'))
- TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
-
- # Pkgconfig file
- autowaf.build_pc(bld, 'SUIL', SUIL_VERSION, SUIL_MAJOR_VERSION, [],
- {'SUIL_MAJOR_VERSION': SUIL_MAJOR_VERSION,
- 'SUIL_PKG_DEPS': 'lv2'})
-
- cflags = []
- lib = []
- modlib = []
- if bld.env.DEST_OS == 'win32':
- modlib += ['user32']
- else:
- cflags += ['-fvisibility=hidden']
- if bld.is_defined('HAVE_LIBDL'):
- lib += ['dl']
- modlib += ['dl']
-
- module_dir = '${LIBDIR}/suil-' + SUIL_MAJOR_VERSION
-
- # Shared Library
- if bld.env.BUILD_SHARED:
- bld(features = 'c cshlib',
- export_includes = ['include'],
- source = 'src/host.c src/instance.c',
- target = 'suil-%s' % SUIL_MAJOR_VERSION,
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- name = 'libsuil',
- vnum = SUIL_VERSION,
- install_path = '${LIBDIR}',
- cflags = cflags,
- lib = lib,
- uselib = 'LV2')
-
- # Static library
- if bld.env.BUILD_STATIC:
- bld(features = 'c cstlib',
- export_includes = ['include'],
- source = 'src/host.c src/instance.c',
- target = 'suil-%s' % SUIL_MAJOR_VERSION,
- includes = ['.', 'include'],
- defines = ['SUIL_STATIC', 'SUIL_INTERNAL'],
- name = 'libsuil_static',
- vnum = SUIL_VERSION,
- install_path = '${LIBDIR}',
- cflags = cflags,
- lib = lib,
- uselib = 'LV2')
-
- if bld.env.SUIL_WITH_GTK2_IN_QT5:
- bld(features = 'cxx cxxshlib',
- source = 'src/gtk2_in_qt5.cpp',
- target = 'suil_gtk2_in_qt5',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cxxflags = cflags,
- lib = modlib,
- uselib = 'GTK2 QT5 LV2')
-
- if bld.env.SUIL_WITH_QT5_IN_GTK2:
- bld(features = 'cxx cxxshlib',
- source = 'src/qt5_in_gtk.cpp',
- target = 'suil_qt5_in_gtk2',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cxxflags = cflags,
- lib = modlib,
- uselib = 'GTK2 QT5 LV2',
- linkflags = bld.env.NODELETE_FLAGS)
-
- if bld.env.SUIL_WITH_X11_IN_GTK2:
- bld(features = 'c cshlib',
- source = 'src/x11_in_gtk2.c',
- target = 'suil_x11_in_gtk2',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib + ['X11'],
- uselib = 'GTK2 GTK2_X11 LV2',
- linkflags = bld.env.NODELETE_FLAGS)
-
- if bld.env.SUIL_WITH_X11_IN_GTK3:
- bld(features = 'c cshlib',
- source = 'src/x11_in_gtk3.c',
- target = 'suil_x11_in_gtk3',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib + ['X11'],
- uselib = 'GTK3 GTK3_X11 LV2',
- linkflags = bld.env.NODELETE_FLAGS)
-
- if bld.env.SUIL_WITH_QT5_IN_GTK3:
- bld(features = 'cxx cxxshlib',
- source = 'src/qt5_in_gtk.cpp',
- target = 'suil_qt5_in_gtk3',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib,
- uselib = 'GTK3 QT5 LV2',
- linkflags = bld.env.NODELETE_FLAGS)
-
- if bld.env.SUIL_WITH_COCOA_IN_GTK2:
- bld(features = 'cxx cshlib',
- source = 'src/cocoa_in_gtk2.mm',
- target = 'suil_cocoa_in_gtk2',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib,
- uselib = 'GTK2 LV2',
- linkflags = ['-framework', 'Cocoa'])
-
- if bld.env.SUIL_WITH_WIN_IN_GTK2:
- bld(features = 'cxx cxxshlib',
- source = 'src/win_in_gtk2.cpp',
- target = 'suil_win_in_gtk2',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib,
- uselib = 'GTK2 LV2',
- linkflags = bld.env.NODELETE_FLAGS)
-
- if bld.env.SUIL_WITH_X11_IN_QT5:
- bld(features = 'cxx cxxshlib',
- source = 'src/x11_in_qt5.cpp',
- target = 'suil_x11_in_qt5',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib,
- uselib = 'QT5 QT5_X11 LV2 X11')
-
- if bld.env.SUIL_WITH_COCOA_IN_QT5:
- bld(features = 'cxx cxxshlib',
- source = 'src/cocoa_in_qt5.mm',
- target = 'suil_cocoa_in_qt5',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib,
- uselib = 'QT5 QT5_COCOA LV2',
- linkflags = ['-framework', 'Cocoa'])
-
- if bld.env.SUIL_WITH_X11:
- bld(features = 'c cshlib',
- source = 'src/x11.c',
- target = 'suil_x11',
- includes = ['.', 'include'],
- defines = ['SUIL_INTERNAL'],
- install_path = module_dir,
- cflags = cflags,
- lib = modlib,
- uselib = 'X11 LV2')
-
- # Documentation
- if bld.env.DOCS:
- bld.recurse('doc/c')
-
- bld.add_post_fun(autowaf.run_ldconfig)
-
-
-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")
-
- qt_mapping_file = "/usr/share/include-what-you-use/qt5_11.imp"
- extra_args = []
- if os.path.exists(qt_mapping_file):
- extra_args += ["--", "-Xiwyu", "--mapping_file=" + qt_mapping_file]
-
- cmd = [ctx.env.IWYU_TOOL[0], "-o", "clang", "-p", "build"] + extra_args
- 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('tests/*.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)
-
-
-def dist(ctx):
- ctx.base_path = ctx.path
- ctx.excl = ctx.get_excl() + ' .gitmodules'