Skip to content

Commit

Permalink
fixup! Refactor Meson build.
Browse files Browse the repository at this point in the history
Format with muon fmt.
Cleanups.
  • Loading branch information
jtojnar committed Feb 4, 2024
1 parent 41212f1 commit 34fa03c
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 107 deletions.
1 change: 0 additions & 1 deletion appveyor_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions doc/source/meson.build
Original file line number Diff line number Diff line change
@@ -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,
)
16 changes: 10 additions & 6 deletions gegl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ 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,
dependencies: [
json,
glib,
gobject,
gegl,
],
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,

Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion generate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# libmypaint - The MyPaint Brush Library
# Copyright (C) 2007-2012 Martin Renold <martinxyz@gmx.ch>
# Copyright (C) 2012-2020 by the MyPaint Development Team.
Expand Down
118 changes: 58 additions & 60 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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',
],
)

Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
gobject = dependency('gobject-2.0', required: get_option('glib'))
use_glib = gobject.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')
Expand All @@ -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.
Expand All @@ -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],
)


Expand Down Expand Up @@ -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'
Expand All @@ -234,10 +225,12 @@ 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,
gobject,
json,
libintl,
libmath,
Expand All @@ -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',

Expand All @@ -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',
Expand All @@ -277,7 +275,7 @@ pkgconfig.generate(libmypaint,
)


if gegl.found()
if use_gegl
subdir('gegl')
endif

Expand Down
56 changes: 48 additions & 8 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -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',
)

0 comments on commit 34fa03c

Please sign in to comment.