Skip to content

Commit 3cbb6ad

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

8 files changed

+166
-101
lines changed

appveyor_build.sh

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export PWD="$APPVEYOR_BULD_FOLDER"
3535
# Meson build, we need a way to parallel this with Autotools
3636
meson setup _build --buildtype=release -Dgegl=false -Ddocs=false
3737
meson dist -C _build
38-
popd
3938
rm -rf _build
4039

4140
./autogen.sh

doc/meson.build

+9-6
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

+2-2
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

+9-5
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

+1-1
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

+57-59
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,24 +44,26 @@ 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
###############################################################################
55-
# Libtool versionning
58+
# Libtool versioning
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.
63-
abi_version_info = '@0@.@1@.@2@'.format(abi_current, abi_revision, abi_age)
66+
abi_version_info = f'@abi_current@.@abi_revision@.@abi_age@'
6467

6568
###############################################################################
6669
# System detection, compiler options
@@ -79,44 +82,25 @@ 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+
use_gegl = gegl.found()
92+
if use_gegl
93+
gegl_gir = gegl.version().version_compare('>=0.4') ? 'Gegl-0.4' : 'Gegl-0.3'
9894
endif
9995

10096
introspection_required_version = '1.32.0'
10197

10298

10399
# 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
100+
openmp = dependency('openmp', required: get_option('openmp'))
113101

114102
## gperftools ##
115-
if get_option('gperftools')
116-
libprofiler = dependency('libprofiler')
117-
else
118-
libprofiler = declare_dependency()
119-
endif
103+
libprofiler = dependency('libprofiler', required: get_option('gperftools'))
120104

121105
# Profiling
122106
if get_option('profiling')
@@ -143,8 +127,12 @@ conf.set10('HAVE_GETTEXT', have_i18n)
143127
enable_docs = get_option('docs')
144128
if enable_docs
145129
doxygen = find_program('doxygen')
146-
sphinx_build = find_program('sphinx-build3', 'sphinx-build-3',
147-
'sphinx-build2', 'sphinx-build-2', 'sphinx-build'
130+
sphinx_build = find_program(
131+
'sphinx-build3',
132+
'sphinx-build-3',
133+
'sphinx-build2',
134+
'sphinx-build-2',
135+
'sphinx-build',
148136
)
149137
# todo: the python 'breathe' extension is also a dependency to doc building.
150138
# the configure script should check for its existence.
@@ -158,24 +146,25 @@ toplevel_inc = include_directories('.')
158146

159147
configure_file(
160148
output: 'config.h',
161-
configuration: conf
149+
configuration: conf,
162150
)
163151

164152
# TODO change generate.py
165153

166-
configure_file(
167-
input : 'brushsettings.json',
168-
output: 'brushsettings.json',
169-
copy: true,
170-
)
171-
brush_settings_headers = custom_target('brush_settings_headers',
154+
brush_settings_headers = custom_target(
155+
'brush_settings_headers',
172156
input: 'brushsettings.json',
173-
output: [ 'mypaint-brush-settings-gen.h', 'brushsettings-gen.h' ],
157+
output: [
158+
'mypaint-brush-settings-gen.h',
159+
'brushsettings-gen.h',
160+
],
174161
command: [
175-
find_program('generate.py'), '@OUTPUT@'
162+
find_program('python3'),
163+
meson.current_source_dir() / 'generate.py',
164+
'@OUTPUT@',
176165
],
177166
install: true,
178-
install_dir: [ get_option('includedir') / api_name, false ],
167+
install_dir: [get_option('includedir') / api_name, false],
179168
)
180169

181170

@@ -217,13 +206,15 @@ libmypaint_public_headers = [
217206
libmypaint_introspectable_headers,
218207
]
219208

220-
install_headers(libmypaint_public_headers,
209+
install_headers(
210+
libmypaint_public_headers,
221211
subdir: api_name,
222212
)
223213

224214
# Install in subdirectory
225215
if use_glib
226-
install_headers('glib/mypaint-brush.h',
216+
install_headers(
217+
'glib/mypaint-brush.h',
227218
subdir: api_name / 'glib',
228219
)
229220
libmypaint_introspectable_headers += 'glib/mypaint-brush.h'
@@ -234,8 +225,10 @@ endif
234225
libmypaint_introspectable_headers += brush_settings_headers[0]
235226

236227

237-
libmypaint = library('mypaint-@0@'.format(api_platform_version),
238-
libmypaint_sources, brush_settings_headers,
228+
libmypaint = library(
229+
'mypaint-@0@'.format(api_platform_version),
230+
libmypaint_sources,
231+
brush_settings_headers,
239232
dependencies: [
240233
glib,
241234
json,
@@ -249,9 +242,13 @@ libmypaint = library('mypaint-@0@'.format(api_platform_version),
249242

250243

251244
if get_option('introspection')
245+
if not use_glib
246+
error('Generating GObject introspection requires building with GLib support')
247+
endif
252248
gnome = import('gnome')
253249

254-
libmypaint_gir = gnome.generate_gir(libmypaint,
250+
libmypaint_gir = gnome.generate_gir(
251+
libmypaint,
255252
nsversion: api_platform_version,
256253
namespace: 'MyPaint',
257254

@@ -268,7 +265,8 @@ if get_option('introspection')
268265
endif
269266

270267

271-
pkgconfig.generate(libmypaint,
268+
pkgconfig.generate(
269+
libmypaint,
272270
name: meson.project_name() + '-' + api_platform_version,
273271
version: version_full,
274272
description: 'MyPaint\'s brushstroke rendering library',
@@ -277,7 +275,7 @@ pkgconfig.generate(libmypaint,
277275
)
278276

279277

280-
if gegl.found()
278+
if use_gegl
281279
subdir('gegl')
282280
endif
283281

meson_options.txt

+48-8
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: 'auto',
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)