diff --git a/appveyor_build.sh b/appveyor_build.sh index e8612f2a..fc282651 100644 --- a/appveyor_build.sh +++ b/appveyor_build.sh @@ -35,7 +35,6 @@ export PWD="$APPVEYOR_BULD_FOLDER" # Meson build, we need a way to parallel this with Autotools meson setup _build --buildtype=release -Dgegl=false -Ddocs=false meson dist -C _build -popd rm -rf _build ./autogen.sh diff --git a/doc/meson.build b/doc/meson.build index b4a82ca8..0f006cce 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -1,7 +1,7 @@ doc_conf = configuration_data() doc_conf.merge_from(conf) -doc_conf.set('SOURCE_ROOT', meson.source_root()) +doc_conf.set('SOURCE_ROOT', meson.project_source_root()) doc_conf.set('BUILD_PATH', meson.current_build_dir()) doxyfile = configure_file( @@ -10,17 +10,20 @@ doxyfile = configure_file( configuration: doc_conf, ) -doxygen_index = custom_target('doxygen', - input : doxyfile, - output: 'index.xml' +doxygen_index = custom_target( + 'doxygen', + input: doxyfile, + output: 'index.xml', command: [ - doxygen, '@INPUT@', + doxygen, + '@INPUT@', ], ) subdir('source') -run_target('sphinx', +run_target( + 'sphinx', depends: doxygen_index, command: [ sphinx_build, diff --git a/doc/source/meson.build b/doc/source/meson.build index d7fba6db..d21b005c 100644 --- a/doc/source/meson.build +++ b/doc/source/meson.build @@ -1,5 +1,5 @@ sphinx_conf_file = configure_file( - input : 'conf.py.in', + input: 'conf.py.in', output: 'conf.py', - configuration : doc_conf, + configuration: doc_conf, ) diff --git a/gegl/meson.build b/gegl/meson.build index 183861f4..5b8c640f 100644 --- a/gegl/meson.build +++ b/gegl/meson.build @@ -10,7 +10,8 @@ libmypaint_gegl_headers = [ 'mypaint-gegl-surface.h', ] -libmypaint_gegl = library('mypaint-gegl-@0@'.format(api_platform_version), +libmypaint_gegl = library( + 'mypaint-gegl-@0@'.format(api_platform_version), libmypaint_gegl_sources, include_directories: toplevel_inc, link_with: libmypaint, @@ -22,15 +23,17 @@ libmypaint_gegl = library('mypaint-gegl-@0@'.format(api_platform_version), install: true, ) -install_headers(libmypaint_gegl_headers, - subdir: 'libmypaint-gegl' +install_headers( + libmypaint_gegl_headers, + subdir: 'libmypaint-gegl', ) if get_option('introspection') gnome = import('gnome') - libmypaint_gegl_gir = gnome.generate_gir(libmypaint_gegl, + libmypaint_gegl_gir = gnome.generate_gir( + libmypaint_gegl, namespace: 'MyPaintGegl', nsversion: api_platform_version, @@ -48,7 +51,8 @@ if get_option('introspection') endif -pkgconfig.generate(libmypaint_gegl, +pkgconfig.generate( + libmypaint_gegl, name: meson.project_name() + '-gegl-' + api_platform_version, version: version_full, description: 'MyPaint brush engine library, with GEGL integration', diff --git a/generate.py b/generate.py index 81632c5a..e4018775 100644 --- a/generate.py +++ b/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # libmypaint - The MyPaint Brush Library # Copyright (C) 2007-2012 Martin Renold # Copyright (C) 2012-2020 by the MyPaint Development Team. diff --git a/meson.build b/meson.build index 64e13511..603b70bf 100644 --- a/meson.build +++ b/meson.build @@ -1,11 +1,12 @@ -project('libmypaint', +project( + 'libmypaint', 'c', # API version: see https://github.com/mypaint/libmypaint/wiki/Versioning # See http://semver.org/ for what this means. version: '2.0.0-beta', - meson_version: '>=0.49.0', + meson_version: '>=0.60.0', default_options: [ - 'c_std=c99' + 'c_std=c99', ], ) @@ -20,10 +21,10 @@ pkgconfig = import('pkgconfig') version_full = meson.project_version() version_dash_split = version_full.split('-') -version = version_dash_split[0] +version_stable = version_dash_split[0] version_prerelease = version_dash_split.get(1, '') # may be blank -version_array = version.split('.') +version_array = version_stable.split('.') version_major = version_array[0] version_minor = version_array[1] version_micro = version_array[2] @@ -43,24 +44,26 @@ project_url = 'https://github.com/mypaint/libmypaint' conf.set('PACKAGE_NAME', meson.project_name()) conf.set('PACKAGE_URL', project_url) conf.set('LIBMYPAINT_API_PLATFORM_VERSION', api_platform_version) -conf.set('LIBMYPAINT_VERSION', version) +conf.set('LIBMYPAINT_VERSION', version_stable) conf.set('LIBMYPAINT_VERSION_FULL', version_full) gettext_package = api_name -conf.set_quoted('GETTEXT_PACKAGE', gettext_package, - description: 'The prefix for our gettext translation domains.' +conf.set_quoted( + 'GETTEXT_PACKAGE', + gettext_package, + description: 'The prefix for our gettext translation domains.', ) ############################################################################### -# Libtool versionning +# Libtool versioning # ABI version see: https://autotools.io/libtool/version.html # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -abi_revision = 0 # increment on every release -abi_current = 0 # inc when add/remove/change interfaces -abi_age = 0 # inc only if changes backward compat +abi_revision = 0 # increment on every release +abi_current = 0 # inc when add/remove/change interfaces +abi_age = 0 # inc only if changes backward compat # FIXME: Not correct. -abi_version_info = '@0@.@1@.@2@'.format(abi_current, abi_revision, abi_age) +abi_version_info = f'@abi_current@.@abi_revision@.@abi_age@' ############################################################################### # System detection, compiler options @@ -79,44 +82,25 @@ libmath = cc.find_library('m', required: false) json = dependency('json-c') # glib -use_glib = get_option('glib') or get_option('introspection') -if use_glib - glib = dependency('gobject-2.0') -endif +glib = dependency('gobject-2.0', required: get_option('glib')) +use_glib = glib.found() conf.set10('MYPAINT_CONFIG_USE_GLIB', use_glib) # GEGL -if get_option('gegl') - gegl = dependency('gegl-0.4', version: '>=0.4', required: false) - gegl_gir = 'Gegl-0.4' - if not gegl.found() - gegl = dependency('gegl-0.3', version: '>=0.3') - gegl_gir = 'Gegl-0.3' - endif -else - gegl = dependency('', required: false) +gegl = dependency('gegl-0.4', 'gegl-0.3', required: get_option('gegl')) +use_gegl = gegl.found() +if use_gegl + gegl_gir = gegl.version().version_compare('>=0.4') ? 'Gegl-0.4' : 'Gegl-0.3' endif introspection_required_version = '1.32.0' # OpenMP -if get_option('openmp') - # OpenMP requires meson >= 0.46. - if meson.version().version_compare('<0.46.0') - error('Meson 0.46.0 is required for OpenMP support.') - endif - openmp = dependency('openmp') -else - openmp = declare_dependency() -endif +openmp = dependency('openmp', required: get_option('openmp')) ## gperftools ## -if get_option('gperftools') - libprofiler = dependency('libprofiler') -else - libprofiler = declare_dependency() -endif +libprofiler = dependency('libprofiler', required: get_option('gperftools')) # Profiling if get_option('profiling') @@ -143,8 +127,12 @@ conf.set10('HAVE_GETTEXT', have_i18n) enable_docs = get_option('docs') if enable_docs doxygen = find_program('doxygen') - sphinx_build = find_program('sphinx-build3', 'sphinx-build-3', - 'sphinx-build2', 'sphinx-build-2', 'sphinx-build' + sphinx_build = find_program( + 'sphinx-build3', + 'sphinx-build-3', + 'sphinx-build2', + 'sphinx-build-2', + 'sphinx-build', ) # todo: the python 'breathe' extension is also a dependency to doc building. # the configure script should check for its existence. @@ -158,24 +146,25 @@ toplevel_inc = include_directories('.') configure_file( output: 'config.h', - configuration: conf + configuration: conf, ) # TODO change generate.py -configure_file( - input : 'brushsettings.json', - output: 'brushsettings.json', - copy: true, -) -brush_settings_headers = custom_target('brush_settings_headers', +brush_settings_headers = custom_target( + 'brush_settings_headers', input: 'brushsettings.json', - output: [ 'mypaint-brush-settings-gen.h', 'brushsettings-gen.h' ], + output: [ + 'mypaint-brush-settings-gen.h', + 'brushsettings-gen.h', + ], command: [ - find_program('generate.py'), '@OUTPUT@' + find_program('python3'), + meson.current_source_dir() / 'generate.py', + '@OUTPUT@', ], install: true, - install_dir: [ get_option('includedir') / api_name, false ], + install_dir: [get_option('includedir') / api_name, false], ) @@ -217,13 +206,15 @@ libmypaint_public_headers = [ libmypaint_introspectable_headers, ] -install_headers(libmypaint_public_headers, +install_headers( + libmypaint_public_headers, subdir: api_name, ) # Install in subdirectory if use_glib - install_headers('glib/mypaint-brush.h', + install_headers( + 'glib/mypaint-brush.h', subdir: api_name / 'glib', ) libmypaint_introspectable_headers += 'glib/mypaint-brush.h' @@ -234,8 +225,10 @@ endif libmypaint_introspectable_headers += brush_settings_headers[0] -libmypaint = library('mypaint-@0@'.format(api_platform_version), - libmypaint_sources, brush_settings_headers, +libmypaint = library( + 'mypaint-@0@'.format(api_platform_version), + libmypaint_sources, + brush_settings_headers, dependencies: [ glib, json, @@ -249,9 +242,13 @@ libmypaint = library('mypaint-@0@'.format(api_platform_version), if get_option('introspection') + if not use_glib + error('Generating GObject introspection requires building with GLib support') + endif gnome = import('gnome') - libmypaint_gir = gnome.generate_gir(libmypaint, + libmypaint_gir = gnome.generate_gir( + libmypaint, nsversion: api_platform_version, namespace: 'MyPaint', @@ -268,7 +265,8 @@ if get_option('introspection') endif -pkgconfig.generate(libmypaint, +pkgconfig.generate( + libmypaint, name: meson.project_name() + '-' + api_platform_version, version: version_full, description: 'MyPaint\'s brushstroke rendering library', @@ -277,7 +275,7 @@ pkgconfig.generate(libmypaint, ) -if gegl.found() +if use_gegl subdir('gegl') endif diff --git a/meson_options.txt b/meson_options.txt index 01c1baa5..b6121244 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,10 +1,50 @@ -option('glib', type: 'boolean', value: true, description: 'Use GLib (forced on by introspection)') -option('gegl', type: 'boolean', value: false, description: 'Enable GEGL based code') -option('openmp', type: 'boolean', value: false, description: 'Compile with OpenMP') -option('gperftools', type: 'boolean', value: false, description: 'Enable gperftools in build, for profiling') +option( + 'glib', + type: 'feature', + value: 'auto', + description: 'Use GLib', +) +option( + 'gegl', + type: 'feature', + value: 'auto', + description: 'Enable GEGL based code', +) +option( + 'openmp', + type: 'feature', + value: 'auto', + description: 'Compile with OpenMP', +) +option( + 'gperftools', + type: 'boolean', + value: false, + description: 'Enable gperftools in build, for profiling', +) -option('profiling', type: 'boolean', value: false, description: 'Turn on profiling') +option( + 'profiling', + type: 'boolean', + value: false, + description: 'Turn on profiling', +) -option('docs', type: 'boolean', value: false, description: 'Enable documentation build') -option('i18n', type: 'boolean', value: true, description: 'Enable internationalization') -option('introspection', type: 'boolean', value: true, description: 'Enable GObject Instrospection') +option( + 'docs', + type: 'boolean', + value: false, + description: 'Enable documentation build', +) +option( + 'i18n', + type: 'boolean', + value: true, + description: 'Enable internationalization', +) +option( + 'introspection', + type: 'boolean', + value: true, + description: 'Enable GObject Instrospection', +) diff --git a/tests/meson.build b/tests/meson.build index a10f4aa6..072c38ea 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,30 +1,46 @@ tests = [ - { 'name': 'test-brush-load', - },{ 'name': 'test-brush-persistence', - },{ 'name': 'test-details', - },{ 'name': 'test-fixed-tiled-surface', - },{ 'name': 'test-rng', - } + { + 'name': 'test-brush-load', + }, + { + 'name': 'test-brush-persistence', + }, + { + 'name': 'test-details', + }, + { + 'name': 'test-fixed-tiled-surface', + }, + { + 'name': 'test-rng', + }, ] -if gegl.found() +if use_gegl tests += { - 'name': 'test-gegl-surface', - 'srcs': 'gegl/test-gegl-surface.c', - 'deps': [ gegl, ], - 'incs': [ libmypaint_gegl_inc, ], - 'link': [ libmypaint_gegl ], + 'name': 'test-gegl-surface', + 'srcs': 'gegl/test-gegl-surface.c', + 'deps': [ + gegl, + ], + 'incs': [ + libmypaint_gegl_inc, + ], + 'link': [ + libmypaint_gegl, + ], } endif -libmypaint_tests_lib = static_library('mypaint-tests', +libmypaint_tests_lib = static_library( + 'mypaint-tests', 'mypaint-benchmark.c', 'mypaint-test-surface.c', 'mypaint-utils-stroke-player.c', 'testutils.c', brush_settings_headers, c_args: [ - '-DLIBMYPAINT_TESTING_ABS_TOP_SRCDIR="@0@"'.format(meson.source_root()), + '-DLIBMYPAINT_TESTING_ABS_TOP_SRCDIR="@0@"'.format(meson.project_source_root()), ], include_directories: toplevel_inc, dependencies: [ @@ -32,17 +48,22 @@ libmypaint_tests_lib = static_library('mypaint-tests', ], ) -foreach test: tests +foreach test : tests test_name = test.get('name') test_srcs = test.get('srcs', test_name + '.c') test_deps = test.get('deps', []) test_incs = test.get('incs', []) test_link = test.get('link', []) - test_exe = executable(test_name, - test_srcs, brush_settings_headers, - c_args: '-DLIBMYPAINT_TESTING_ABS_TOP_SRCDIR="@0@"'.format(meson.source_root()), - include_directories: [ toplevel_inc, test_incs ], + test_exe = executable( + test_name, + test_srcs, + brush_settings_headers, + c_args: '-DLIBMYPAINT_TESTING_ABS_TOP_SRCDIR="@0@"'.format(meson.project_source_root()), + include_directories: [ + toplevel_inc, + test_incs, + ], link_with: [ libmypaint, libmypaint_tests_lib,