summaryrefslogtreecommitdiff
path: root/gio/giomm/meson.build
blob: faaeb9b51596f8e08323bfb0e2e164c7e9d4f3fa (plain)
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# gio/giomm

# Input: giomm_build_dep, giomm_pcname, maintainer_mode, project_source_root,
#        generate_binding_py, handle_built_files_py, m4_files, pm_files,
#        glibmm_libversion, install_includedir, python3, giomm_rc, gmmproc_dir,
#        is_host_windows, gmmproc, generate_wrap_init_pl, giomm_libname,
#        macos_darwin_versions, can_add_dist_script
# Output: giomm_hg_ccg_basenames, giomm_extra_h_files, built_files_root,
#         giomm_built_h_file_targets, giomm_own_dep

giomm_defs_basefiles = [
  'gio.defs',
  'gio_enums.defs',
  'gio_methods.defs',
  'gio_signals.defs',
  'gio_extra_objects.defs',
  'gio_vfuncs.defs',
  'gio_docs.xml',
  'gio_docs_override.xml',
]

giomm_defs_files = []
foreach file : giomm_defs_basefiles
  giomm_defs_files += '..' / 'src' / file
endforeach

# Generated from pairs of .hg and .ccg files.
giomm_any_hg_ccg_basenames = [
  'action',
  'actiongroup',
  'actionmap',
  'appinfo',
  'appinfomonitor',
  'applaunchcontext',
  'application',
  'applicationcommandline',
  'asyncinitable',
  'asyncresult',
  'bufferedinputstream',
  'bufferedoutputstream',
  'cancellable',
  'charsetconverter',
  'converter',
  'converterinputstream',
  'converteroutputstream',
  'credentials',
  'datainputstream',
  'dataoutputstream',
  'dbusactiongroup',
  'dbusaddress',
  'dbusauthobserver',
  'dbusconnection',
  'dbuserror',
  'dbuserrorutils',
  'dbusinterface',
  'dbusinterfaceskeleton',
  'dbusinterfacevtable',
  'dbusintrospection',
  'dbusmenumodel',
  'dbusmessage',
  'dbusmethodinvocation',
  'dbusobject',
  'dbusobjectmanager',
  'dbusobjectmanagerclient',
  'dbusobjectmanagerserver',
  'dbusobjectproxy',
  'dbusobjectskeleton',
  'dbusownname',
  'dbusproxy',
  'dbusserver',
  'dbussubtreevtable',
  'dbusutils',
  'dbuswatchname',
  'drive',
  'emblem',
  'emblemedicon',
  'enums',
  'error',
  'file',
  'fileattributeinfo',
  'fileattributeinfolist',
  'fileenumerator',
  'fileicon',
  'fileinfo',
  'fileinputstream',
  'fileiostream',
  'filemonitor',
  'filenamecompleter',
  'fileoutputstream',
  'filterinputstream',
  'filteroutputstream',
  'icon',
  'inetaddress',
  'inetsocketaddress',
  'initable',
  'inputstream',
  'iostream',
  'listmodel',
  'liststore',
  'loadableicon',
  'memoryinputstream',
  'memoryoutputstream',
  'menuattributeiter',
  'menulinkiter',
  'menu',
  'menuitem',
  'menumodel',
  'mount',
  'mountoperation',
  'networkaddress',
  'networkmonitor',
  'networkservice',
  'notification',
  'outputstream',
  'permission',
  'pollableinputstream',
  'pollableoutputstream',
  'propertyaction',
  'proxy',
  'proxyaddress',
  'proxyresolver',
  'remoteactiongroup',
  'resolver',
  'resource',
  'seekable',
  'settings',
  'settingsschema',
  'settingsschemakey',
  'settingsschemasource',
  'simpleaction',
  'simpleactiongroup',
  'simpleiostream',
  'simplepermission',
  'socket',
  'socketaddress',
  'socketaddressenumerator',
  'socketclient',
  'socketconnectable',
  'socketconnection',
  'socketcontrolmessage',
  'socketlistener',
  'socketservice',
  'srvtarget',
  'tcpconnection',
  'tcpwrapperconnection',
  'threadedsocketservice',
  'themedicon',
  'tlscertificate',
  'tlsclientconnection',
  'tlsconnection',
  'tlsdatabase',
  'tlsinteraction',
  'tlspassword',
  'tlsserverconnection',
  'volume',
  'volumemonitor',
  'zlibdecompressor',
  'zlibcompressor',
]

giomm_posix_hg_ccg_basenames = [
  'filedescriptorbased',
  'unixconnection',
  'unixcredentialsmessage',
  'unixfdlist',
  'unixfdmessage',
  'unixinputstream',
  'unixoutputstream',
  'unixsocketaddress',
]

giomm_not_mac_hg_ccg_basenames = [
  'desktopappinfo',
]

# All .hg/.ccg files, regardless of type of host.
giomm_hg_ccg_basenames = \
  giomm_any_hg_ccg_basenames + \
  giomm_posix_hg_ccg_basenames + \
  giomm_not_mac_hg_ccg_basenames

# Used .hg/.ccg files in present type of host.
giomm_used_hg_ccg_basenames = giomm_any_hg_ccg_basenames
if not is_host_windows
  giomm_used_hg_ccg_basenames += giomm_posix_hg_ccg_basenames
  if not is_os_cocoa
    giomm_used_hg_ccg_basenames += giomm_not_mac_hg_ccg_basenames
  endif
endif

# Pairs of hand-coded .h and .cc files.
giomm_extra_h_cc_basenames = [
  'contenttype',
  'init',
  'slot_async',
  'socketsource',
  'tlsclientconnectionimpl',
  'tlsserverconnectionimpl',
]

giomm_extra_h_files = [
  'wrap_init.h',
]

giomm_extra_cc_files = []

foreach file : giomm_extra_h_cc_basenames
  giomm_extra_h_files += file + '.h'
  giomm_extra_cc_files += file + '.cc'
endforeach

install_headers('..' / 'giomm.h', subdir: giomm_pcname)
install_headers(giomm_extra_h_files, subdir: giomm_pcname / 'giomm')

untracked_giomm = 'untracked' / 'gio' / 'giomm'
rel_untracked_giomm = '..' / '..' / untracked_giomm
src_untracked_giomm = project_source_root / untracked_giomm

extra_giomm_objects = []
giomm_cpp_flags = [ '-DGIOMM_BUILD=1' ]

# Build the .rc file for Windows builds and link to it
if is_host_windows
  windows = import('windows')
  giomm_res = windows.compile_resources(giomm_rc)
  extra_giomm_objects += giomm_res
endif

if maintainer_mode

  # Maintainer mode. Generate .h and .cc files from .hg and .ccg files in ../src.

  # docs/reference/meson.build needs these.
  built_files_root = project_build_root
  giomm_built_h_file_targets = []

  # Force meson+ninja to generate source files before anything is compiled.
  # Compilation must depend on these targets.
  giomm_used_built_cc_file_targets = []
  giomm_used_built_h_file_targets = []

  hg_files = []
  foreach file : giomm_hg_ccg_basenames
    hg_files += '..' / 'src' / file + '.hg'
  endforeach

  # Create wrap_init.cc in project_build_root/gio/giomm.
  giomm_used_built_cc_file_targets += custom_target('giomm-wrap_init.cc',
    input: hg_files,
    output: 'wrap_init.cc',
    command: [
      python3, generate_binding_py, 'generate_wrap_init',
      gmmproc_dir,
      '@OUTPUT@',
      'Gio', # namespace
      '@INPUT@',
    ],
    depend_files: generate_wrap_init_pl,
    build_by_default: maintainer_mode,
    install: false,
  )

  # Create .h/_p.h/.cc files in project_build_root/gio/giomm
  # from .hg/.ccg files in project_source_root/gio/src.
  foreach file : giomm_hg_ccg_basenames
    hg_file = '..' / 'src' / file + '.hg'
    ccg_file = '..' / 'src' / file + '.ccg'
    built_file_target = custom_target('giomm-' + file + '.cc',
      input: [hg_file, ccg_file],
      output: [file + '.stamp', file + '.cc', file + '.h'],
      command: [
        python3, handle_built_files_py, 'gmmproc',
        gmmproc_dir,
        project_source_root / 'tools' / 'pm',
        '@OUTPUT0@',
        file,
        meson.current_source_dir() / '..' / 'src',
        project_source_root / 'tools' / 'm4',
      ],
      depend_files: giomm_defs_files + m4_files + [gmmproc] + pm_files,
      build_by_default: maintainer_mode,
      install: false,
    )
    giomm_built_h_file_targets += built_file_target[2]
    if giomm_used_hg_ccg_basenames.contains(file)
      giomm_used_built_cc_file_targets += built_file_target[1]
      giomm_used_built_h_file_targets += built_file_target[2]
    endif
  endforeach

  # Create dummy_header.h, depending on all generated headers.
  # It's created if it does not exist, but it's never updated.
  # It guarantees that all generated headers are built before giomm_library
  # is built, at the same time avoiding unnecessary recompilations.
  # If giomm_used_built_h_file_targets would be listed as sources to giomm_library,
  # all generated .cc files could be recompiled if one generated .h file has
  # been changed.
  built_dummy_h_file_target = custom_target('giomm-dummy_header.h',
    input: giomm_used_built_h_file_targets,
    output: 'dummy_header.h',
    command: [
      python3, dummy_header_py,
      '@OUTPUT@',
    ],
    build_by_default: maintainer_mode,
    install: false,
  )

  extra_include_dirs = ['..', '..' / '..' / 'glib']

  giomm_library = library(giomm_libname, extra_giomm_objects,
    giomm_used_built_cc_file_targets, giomm_extra_cc_files, built_dummy_h_file_target,
    version: glibmm_libversion,
    darwin_versions: macos_darwin_versions,
    implicit_include_directories: false,
    include_directories: extra_include_dirs,
    cpp_args: giomm_cpp_flags,
    dependencies: giomm_build_dep,
    link_with: glibmm_library,
    install: true,
  )

  built_h_cc_dir = meson.current_build_dir()

else # not maintainer_mode

  # Not maintainer mode. Compile built source code files in
  # project_source_root/untracked/gio/giomm.

  giomm_used_built_h_file_targets = []

  # docs/reference/meson.build needs these.
  built_files_root = project_source_root / 'untracked'
  giomm_built_h_file_targets = []

  # Two cases:
  # 1. The source code comes from a tarball, where the built files
  #    are stored in project_source_root/untracked.
  #    There are no built files in the build tree.
  # 2. Files have been built in the build tree. Then maintainer_mode has
  #    been changed from true to false. Files that are missing or not up to date
  #    in project_source_root/untracked are copied from the build tree.

  # Try to copy built source code files to the source tree.
  run_command(
    python3, generate_binding_py, 'copy_built_files',
    meson.current_build_dir(),
    src_untracked_giomm,
    giomm_hg_ccg_basenames,
    check: true,
  )

  built_cc_files = [ rel_untracked_giomm / 'wrap_init.cc' ]
  foreach file : giomm_used_hg_ccg_basenames
    built_cc_files += rel_untracked_giomm / file + '.cc'
  endforeach

  extra_include_dirs = [ '..', '..' / '..' / 'untracked' / 'gio',
         '..' / '..' / 'glib', '..' / '..' / 'untracked' / 'glib',
  ]

  giomm_library = library(giomm_libname, extra_giomm_objects,
    built_cc_files, giomm_extra_cc_files,
    version: glibmm_libversion,
    darwin_versions: macos_darwin_versions,
    implicit_include_directories: false,
    include_directories: extra_include_dirs,
    cpp_args: giomm_cpp_flags,
    dependencies: giomm_build_dep,
    link_with: glibmm_library,
    install: true,
  )

  built_h_cc_dir = src_untracked_giomm

endif

# Install built .h and _p.h files.
meson.add_install_script(
  python3, generate_binding_py, 'install_built_h_files',
  built_h_cc_dir,
  install_includedir / giomm_pcname / 'giomm', # subdir below {prefix}
  giomm_used_hg_ccg_basenames
)

if can_add_dist_script
  # Distribute built files.
  meson.add_dist_script(
    python3, generate_binding_py, 'dist_built_files',
    built_h_cc_dir,
    untracked_giomm,
    giomm_hg_ccg_basenames,
  )
endif

# This is used when building example programs and test programs.
# It's also a part of giomm_dep, when glibmm is a subproject.
giomm_own_dep = declare_dependency(
  sources: glibmm_built_h_file_targets + giomm_used_built_h_file_targets,
  link_with: [glibmm_library, giomm_library],
  include_directories: extra_include_dirs,
  dependencies: giomm_build_dep,
)