File: meson.build

package info (click to toggle)
goodvibes 0.8.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,784 kB
  • sloc: ansic: 16,310; sh: 978; python: 21; makefile: 19
file content (219 lines) | stat: -rw-r--r-- 7,348 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# SPDX-License-Identifier: GPL-3.0-only

# My understanding of meson (a beginner guide)
#
#     'configure step' and 'build step'
#
# *Configure files* are generated early when creating the build directory with
# 'meson 'builddir', and afterward Meson automatically update these files if
# the source changes. Therefore, my understanding is that there's no need to
# declare a dependency to ensure configure files are up-to-date: they're always
# up-to-date.
#
# However, custom_target() has a 'depend_files:' keyword for declaring
# dependencies on files. It's unclear if we need to use it for configure files.
# I'd say no need.
#
# *Build targets* are, on the other hand, part of a dependency chain, and the
# 'depends:' keyword must be used to indicate a dependency. This is mandatory.
#
#     'source dir' and 'build dir'
#
# Meson has a clear concept of 'source dir' and 'build dir'.
#
# When you give a relative path to 'input:', meson assumes it's relative to
# 'source dir'. Beware when you need to use configure files as inputs, as they
# live in 'build dir'.
#
#     References
#
# <http://mesonbuild.com/Overview.html>
#
# Credit for this file goes to <https://github.com/pithos/pithos>.

# ----------------------------------------------------- #
#         D-Bus Service File                            #
# ----------------------------------------------------- #
# <https://dbus.freedesktop.org/doc/system-activation.txt>

services_dir = datadir / 'dbus-1/services'

service_conf = configuration_data()
service_conf.set('bindir', bindir)
service_conf.set('binary', gv_binary)
service_conf.set('dbus_name', gv_application_id)

configure_file(
  input: gv_application_id + '.service.in',
  output: gv_application_id + '.service',
  configuration: service_conf,
  install_dir: services_dir,
)

# XXX It would be nice to have a tool to validate the service file.

# ----------------------------------------------------- #
#         Desktop File                                  #
# ----------------------------------------------------- #
# <https://specifications.freedesktop.org/desktop-entry-spec/latest/>

# XXX It would be nice to have desktop.in created with configure_file(),
# so that we can do some variable substitution, like for the other data
# files here. However, it means that the POTFILES should list the built
# file, which lives in the build dir. Right now it doesn't work.
# https://github.com/mesonbuild/meson/issues/1733

applications_dir = datadir / 'applications'

desktop_file = i18n.merge_file(
  input: gv_application_id + '.desktop.in',
  output: gv_application_id + '.desktop',
  po_dir: '../po',
  type: 'desktop',
  install: true,
  install_dir: applications_dir,
)

desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
  test('Validate desktop file', desktop_utils,
    args: [ desktop_file ],
  )
endif

# ----------------------------------------------------- #
#         Appstream File                                #
# ----------------------------------------------------- #
# <https://www.freedesktop.org/software/appstream/docs/>

appstream_dir = datadir / 'metainfo'

appstream_file = i18n.merge_file(
  input: gv_application_id + '.appdata.xml.in',
  output: gv_application_id + '.appdata.xml',
  po_dir: '../po',
  type: 'xml',
  install: true,
  install_dir: appstream_dir,
)

appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
  # Relaxed validation, our screenshots don't meet the expectations
  # (16:9 without padding is definitely not suitable).
  test('Validate appstream file', appstream_util,
    args: [ '--nonet', 'validate-relax', appstream_file ]
  )
endif

# ----------------------------------------------------- #
#         GSettings Schemas                             #
# ----------------------------------------------------- #
# <https://developer.gnome.org/gio/stable/GSettings.html>

schemas_dir = datadir / 'glib-2.0/schemas'

schema_conf = configuration_data()
schema_conf.set('id', gv_application_id)
schema_conf.set('path', gv_application_path)

schema_file = configure_file(
  input: gv_application_id + '.gschema.xml.in',
  output: gv_application_id + '.gschema.xml',
  configuration: schema_conf,
  install_dir: schemas_dir,
)

#gv_settings = gnome.compile_schemas(
#  depend_files: schema_file
#)

# Generate enums.xml file.
# XXX gnome.compile_schemas() can't generate the enum.xml file automatically,
# like it was done with the autotools. We need to do it explicitly.
# https://github.com/mesonbuild/meson/issues/1687
# XXX It's unfortunate that we have to list the headers here,
# maybe that would be better done in src/ ?
enum_headers = [
  '../src/ui/gv-main-window.h',
  '../src/ui/gv-main-window-standalone.h',
  '../src/ui/gv-status-icon.h',
]

generate_enums = gnome.mkenums(gv_application_id + '.enums.xml',
  sources: enum_headers,
  comments: '<!-- @comment@ -->',
  fhead: '<schemalist>',
  vhead: '  <@type@ id="' + gv_application_id + '.@EnumName@">',
  vprod: '    <value nick="@valuenick@" value="@valuenum@"/>',
  vtail: '  </@type@>',
  ftail: '</schemalist>',
  install_header: true,
  install_dir: schemas_dir
)

# Compile schemas for running the application in-tree
# XXX We use a custom target, because gnome.compile_schemas()
# would run in the source dir rather than the build dir, hence
# missing the generated 'enums.xml' file.
# https://github.com/mesonbuild/meson/issues/2219
compile_schemas = custom_target('glib-compile-schemas',
  output: 'gschemas.compiled',
  build_by_default: true,
  install: false,
  command: [
    find_program('glib-compile-schemas'),
    meson.current_build_dir(),
  ],
  depends: [ generate_enums ],
)

compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
  test('Validate schema file', compile_schemas,
     args: [ '--strict', '--dry-run', meson.current_build_dir() ],
# Requires meson >= 0.46, commenting for now
#    depends: [ generate_enums ],
  )
endif

# ----------------------------------------------------- #
#         Manual Pages                                  #
# ----------------------------------------------------- #

# XXX That would be nice to use install_man(), however right now
# it's not possible to use it with generated files. So we have
# to use a custom target and zip the files manually.
# https://github.com/mesonbuild/meson/issues/1550

manuals_dir = mandir / 'man1'

manual_conf = configuration_data()
manual_conf.set('package', gv_name_lowercase)
manual_conf.set('Package', gv_name_camelcase)
manual_conf.set('PACKAGE', gv_name_uppercase)
manual_conf.set('version', gv_version)
manual_conf.set('homepage', gv_homepage)
manual_conf.set('author', gv_author_name)

gzip = find_program('gzip', required: true)

foreach exe: [ 'goodvibes', 'goodvibes-client' ]
  tmp_man_file = configure_file(
    input: exe + '.1.in',
    output: exe + '.1',
    configuration: manual_conf,
  )
  custom_target('man-' + exe,
    command: [ gzip, '--keep', '--force', tmp_man_file ],
    output: exe + '.1.gz',
    install: true,
    install_dir: manuals_dir,
  )
endforeach

# ------------------------------------------------------- #
#         Subdirectories                                  #
# ------------------------------------------------------- #

subdir('icons')