Skip to content

Commit 7cdb140

Browse files
committed
fixup! Refactor Meson build.
Format with muon fmt. Cleanups.
1 parent 41212f1 commit 7cdb140

File tree

7 files changed

+155
-96
lines changed

7 files changed

+155
-96
lines changed

doc/meson.build

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
doc_conf = configuration_data()
22
doc_conf.merge_from(conf)
33

4-
doc_conf.set('SOURCE_ROOT', meson.source_root())
4+
doc_conf.set('SOURCE_ROOT', meson.project_source_root())
55
doc_conf.set('BUILD_PATH', meson.current_build_dir())
66

77
doxyfile = configure_file(
@@ -10,17 +10,20 @@ doxyfile = configure_file(
1010
configuration: doc_conf,
1111
)
1212

13-
doxygen_index = custom_target('doxygen',
14-
input : doxyfile,
15-
output: 'index.xml'
13+
doxygen_index = custom_target(
14+
'doxygen',
15+
input: doxyfile,
16+
output: 'index.xml',
1617
command: [
17-
doxygen, '@INPUT@',
18+
doxygen,
19+
'@INPUT@',
1820
],
1921
)
2022

2123
subdir('source')
2224

23-
run_target('sphinx',
25+
run_target(
26+
'sphinx',
2427
depends: doxygen_index,
2528
command: [
2629
sphinx_build,

doc/source/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sphinx_conf_file = configure_file(
2-
input : 'conf.py.in',
2+
input: 'conf.py.in',
33
output: 'conf.py',
4-
configuration : doc_conf,
4+
configuration: doc_conf,
55
)

gegl/meson.build

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ libmypaint_gegl_headers = [
1010
'mypaint-gegl-surface.h',
1111
]
1212

13-
libmypaint_gegl = library('mypaint-gegl-@0@'.format(api_platform_version),
13+
libmypaint_gegl = library(
14+
'mypaint-gegl-@0@'.format(api_platform_version),
1415
libmypaint_gegl_sources,
1516
include_directories: toplevel_inc,
1617
link_with: libmypaint,
@@ -22,15 +23,17 @@ libmypaint_gegl = library('mypaint-gegl-@0@'.format(api_platform_version),
2223
install: true,
2324
)
2425

25-
install_headers(libmypaint_gegl_headers,
26-
subdir: 'libmypaint-gegl'
26+
install_headers(
27+
libmypaint_gegl_headers,
28+
subdir: 'libmypaint-gegl',
2729
)
2830

2931

3032
if get_option('introspection')
3133
gnome = import('gnome')
3234

33-
libmypaint_gegl_gir = gnome.generate_gir(libmypaint_gegl,
35+
libmypaint_gegl_gir = gnome.generate_gir(
36+
libmypaint_gegl,
3437
namespace: 'MyPaintGegl',
3538
nsversion: api_platform_version,
3639

@@ -48,7 +51,8 @@ if get_option('introspection')
4851
endif
4952

5053

51-
pkgconfig.generate(libmypaint_gegl,
54+
pkgconfig.generate(
55+
libmypaint_gegl,
5256
name: meson.project_name() + '-gegl-' + api_platform_version,
5357
version: version_full,
5458
description: 'MyPaint brush engine library, with GEGL integration',

generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
22
# libmypaint - The MyPaint Brush Library
33
# Copyright (C) 2007-2012 Martin Renold <[email protected]>
44
# Copyright (C) 2012-2020 by the MyPaint Development Team.

meson.build

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
project('libmypaint',
1+
project(
2+
'libmypaint',
23
'c',
34
# API version: see https://github.com/mypaint/libmypaint/wiki/Versioning
45
# See http://semver.org/ for what this means.
56
version: '2.0.0-beta',
6-
meson_version: '>=0.49.0',
7+
meson_version: '>=0.60.0',
78
default_options: [
8-
'c_std=c99'
9+
'c_std=c99',
910
],
1011
)
1112

@@ -20,10 +21,10 @@ pkgconfig = import('pkgconfig')
2021

2122
version_full = meson.project_version()
2223
version_dash_split = version_full.split('-')
23-
version = version_dash_split[0]
24+
version_stable = version_dash_split[0]
2425
version_prerelease = version_dash_split.get(1, '') # may be blank
2526

26-
version_array = version.split('.')
27+
version_array = version_stable.split('.')
2728
version_major = version_array[0]
2829
version_minor = version_array[1]
2930
version_micro = version_array[2]
@@ -43,22 +44,24 @@ project_url = 'https://github.com/mypaint/libmypaint'
4344
conf.set('PACKAGE_NAME', meson.project_name())
4445
conf.set('PACKAGE_URL', project_url)
4546
conf.set('LIBMYPAINT_API_PLATFORM_VERSION', api_platform_version)
46-
conf.set('LIBMYPAINT_VERSION', version)
47+
conf.set('LIBMYPAINT_VERSION', version_stable)
4748
conf.set('LIBMYPAINT_VERSION_FULL', version_full)
4849

4950
gettext_package = api_name
50-
conf.set_quoted('GETTEXT_PACKAGE', gettext_package,
51-
description: 'The prefix for our gettext translation domains.'
51+
conf.set_quoted(
52+
'GETTEXT_PACKAGE',
53+
gettext_package,
54+
description: 'The prefix for our gettext translation domains.',
5255
)
5356

5457
###############################################################################
5558
# Libtool versionning
5659

5760
# ABI version see: https://autotools.io/libtool/version.html
5861
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
59-
abi_revision = 0 # increment on every release
60-
abi_current = 0 # inc when add/remove/change interfaces
61-
abi_age = 0 # inc only if changes backward compat
62+
abi_revision = 0 # increment on every release
63+
abi_current = 0 # inc when add/remove/change interfaces
64+
abi_age = 0 # inc only if changes backward compat
6265
# FIXME: Not correct.
6366
abi_version_info = '@0@.@1@.@2@'.format(abi_current, abi_revision, abi_age)
6467

@@ -79,44 +82,24 @@ libmath = cc.find_library('m', required: false)
7982
json = dependency('json-c')
8083

8184
# glib
82-
use_glib = get_option('glib') or get_option('introspection')
83-
if use_glib
84-
glib = dependency('gobject-2.0')
85-
endif
85+
glib = dependency('gobject-2.0', required: get_option('glib'))
86+
use_glib = glib.found()
8687
conf.set10('MYPAINT_CONFIG_USE_GLIB', use_glib)
8788

8889
# GEGL
89-
if get_option('gegl')
90-
gegl = dependency('gegl-0.4', version: '>=0.4', required: false)
91-
gegl_gir = 'Gegl-0.4'
92-
if not gegl.found()
93-
gegl = dependency('gegl-0.3', version: '>=0.3')
94-
gegl_gir = 'Gegl-0.3'
95-
endif
96-
else
97-
gegl = dependency('', required: false)
90+
gegl = dependency('gegl-0.4', 'gegl-0.3', required: get_option('gegl'))
91+
if gegl.found()
92+
gegl_gir = gegl.version().version_compare('>=0.4') ? 'Gegl-0.4' : 'Gegl-0.3'
9893
endif
9994

10095
introspection_required_version = '1.32.0'
10196

10297

10398
# OpenMP
104-
if get_option('openmp')
105-
# OpenMP requires meson >= 0.46.
106-
if meson.version().version_compare('<0.46.0')
107-
error('Meson 0.46.0 is required for OpenMP support.')
108-
endif
109-
openmp = dependency('openmp')
110-
else
111-
openmp = declare_dependency()
112-
endif
99+
openmp = dependency('openmp', required: get_option('openmp'))
113100

114101
## gperftools ##
115-
if get_option('gperftools')
116-
libprofiler = dependency('libprofiler')
117-
else
118-
libprofiler = declare_dependency()
119-
endif
102+
libprofiler = dependency('libprofiler', required: get_option('gperftools'))
120103

121104
# Profiling
122105
if get_option('profiling')
@@ -143,8 +126,12 @@ conf.set10('HAVE_GETTEXT', have_i18n)
143126
enable_docs = get_option('docs')
144127
if enable_docs
145128
doxygen = find_program('doxygen')
146-
sphinx_build = find_program('sphinx-build3', 'sphinx-build-3',
147-
'sphinx-build2', 'sphinx-build-2', 'sphinx-build'
129+
sphinx_build = find_program(
130+
'sphinx-build3',
131+
'sphinx-build-3',
132+
'sphinx-build2',
133+
'sphinx-build-2',
134+
'sphinx-build',
148135
)
149136
# todo: the python 'breathe' extension is also a dependency to doc building.
150137
# the configure script should check for its existence.
@@ -158,24 +145,24 @@ toplevel_inc = include_directories('.')
158145

159146
configure_file(
160147
output: 'config.h',
161-
configuration: conf
148+
configuration: conf,
162149
)
163150

164151
# TODO change generate.py
165152

166-
configure_file(
167-
input : 'brushsettings.json',
168-
output: 'brushsettings.json',
169-
copy: true,
170-
)
171-
brush_settings_headers = custom_target('brush_settings_headers',
153+
brush_settings_headers = custom_target(
154+
'brush_settings_headers',
172155
input: 'brushsettings.json',
173-
output: [ 'mypaint-brush-settings-gen.h', 'brushsettings-gen.h' ],
156+
output: [
157+
'mypaint-brush-settings-gen.h',
158+
'brushsettings-gen.h',
159+
],
174160
command: [
175-
find_program('generate.py'), '@OUTPUT@'
161+
find_program('generate.py'),
162+
'@OUTPUT@',
176163
],
177164
install: true,
178-
install_dir: [ get_option('includedir') / api_name, false ],
165+
install_dir: [get_option('includedir') / api_name, false],
179166
)
180167

181168

@@ -217,13 +204,15 @@ libmypaint_public_headers = [
217204
libmypaint_introspectable_headers,
218205
]
219206

220-
install_headers(libmypaint_public_headers,
207+
install_headers(
208+
libmypaint_public_headers,
221209
subdir: api_name,
222210
)
223211

224212
# Install in subdirectory
225213
if use_glib
226-
install_headers('glib/mypaint-brush.h',
214+
install_headers(
215+
'glib/mypaint-brush.h',
227216
subdir: api_name / 'glib',
228217
)
229218
libmypaint_introspectable_headers += 'glib/mypaint-brush.h'
@@ -234,8 +223,10 @@ endif
234223
libmypaint_introspectable_headers += brush_settings_headers[0]
235224

236225

237-
libmypaint = library('mypaint-@0@'.format(api_platform_version),
238-
libmypaint_sources, brush_settings_headers,
226+
libmypaint = library(
227+
'mypaint-@0@'.format(api_platform_version),
228+
libmypaint_sources,
229+
brush_settings_headers,
239230
dependencies: [
240231
glib,
241232
json,
@@ -249,9 +240,13 @@ libmypaint = library('mypaint-@0@'.format(api_platform_version),
249240

250241

251242
if get_option('introspection')
243+
if not use_glib
244+
error('Generating GObject introspection requires building with GLib support')
245+
endif
252246
gnome = import('gnome')
253247

254-
libmypaint_gir = gnome.generate_gir(libmypaint,
248+
libmypaint_gir = gnome.generate_gir(
249+
libmypaint,
255250
nsversion: api_platform_version,
256251
namespace: 'MyPaint',
257252

@@ -268,7 +263,8 @@ if get_option('introspection')
268263
endif
269264

270265

271-
pkgconfig.generate(libmypaint,
266+
pkgconfig.generate(
267+
libmypaint,
272268
name: meson.project_name() + '-' + api_platform_version,
273269
version: version_full,
274270
description: 'MyPaint\'s brushstroke rendering library',

meson_options.txt

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
1-
option('glib', type: 'boolean', value: true, description: 'Use GLib (forced on by introspection)')
2-
option('gegl', type: 'boolean', value: false, description: 'Enable GEGL based code')
3-
option('openmp', type: 'boolean', value: false, description: 'Compile with OpenMP')
4-
option('gperftools', type: 'boolean', value: false, description: 'Enable gperftools in build, for profiling')
1+
option(
2+
'glib',
3+
type: 'feature',
4+
value: 'auto',
5+
description: 'Use GLib',
6+
)
7+
option(
8+
'gegl',
9+
type: 'feature',
10+
value: 'disabled',
11+
description: 'Enable GEGL based code',
12+
)
13+
option(
14+
'openmp',
15+
type: 'feature',
16+
value: 'auto',
17+
description: 'Compile with OpenMP',
18+
)
19+
option(
20+
'gperftools',
21+
type: 'boolean',
22+
value: false,
23+
description: 'Enable gperftools in build, for profiling',
24+
)
525

6-
option('profiling', type: 'boolean', value: false, description: 'Turn on profiling')
26+
option(
27+
'profiling',
28+
type: 'boolean',
29+
value: false,
30+
description: 'Turn on profiling',
31+
)
732

8-
option('docs', type: 'boolean', value: false, description: 'Enable documentation build')
9-
option('i18n', type: 'boolean', value: true, description: 'Enable internationalization')
10-
option('introspection', type: 'boolean', value: true, description: 'Enable GObject Instrospection')
33+
option(
34+
'docs',
35+
type: 'boolean',
36+
value: false,
37+
description: 'Enable documentation build',
38+
)
39+
option(
40+
'i18n',
41+
type: 'boolean',
42+
value: true,
43+
description: 'Enable internationalization',
44+
)
45+
option(
46+
'introspection',
47+
type: 'boolean',
48+
value: true,
49+
description: 'Enable GObject Instrospection',
50+
)

0 commit comments

Comments
 (0)