summaryrefslogtreecommitdiff
path: root/gir/meson.build
blob: 5229207d7b55bc47aba65838a04a583fa0ed5a1f (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
cairo_conf = configuration_data()
if get_option('cairo-libname') != ''
  cairo_library_name = get_option('cairo-libname')
elif host_machine.system() == 'win32'
  cairo_library_name = 'libcairo-gobject-2.dll'
elif host_machine.system() == 'darwin'
  cairo_library_name = 'libcairo-gobject.2.dylib'
else
  cairo_library_name = 'libcairo-gobject.so.2'
endif

cairo_conf.set('CAIRO_SHARED_LIBRARY', cairo_library_name)
cairo_conf.set('CAIRO_GIR_PACKAGE', 'cairo-gobject')

cairo_gir = configure_file(
  input: 'cairo-1.0.gir.in',
  output: 'cairo-1.0.gir',
  configuration: cairo_conf,
)

gir_files = [
  cairo_gir,
  'DBus-1.0.gir',
  'DBusGLib-1.0.gir',
  'fontconfig-2.0.gir',
  'freetype2-2.0.gir',
  'GL-1.0.gir',
  'libxml2-2.0.gir',
  'xft-2.0.gir',
  'xlib-2.0.gir',
  'xfixes-4.0.gir',
  'xrandr-1.3.gir',
  'win32-1.0.gir',
]

typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
girdir = join_paths(get_option('datadir'), 'gir-1.0')
install_data(gir_files, install_dir: girdir)

scanner_command = [
  find_program('env'),
  'UNINSTALLED_INTROSPECTION_SRCDIR=' + meson.source_root(),
  'UNINSTALLED_INTROSPECTION_BUILDDIR=' + meson.build_root(),
  girscanner,
  '--output=@OUTPUT@',
  '--warn-all',
  '--no-libtool',
  '--external-library',
  '--reparse-validate',
]

# GLib
glib_includedir = join_paths(gobject_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
glib_libincludedir = join_paths(gobject_dep.get_pkgconfig_variable('libdir'), 'glib-2.0/include')
glib_srcdir = get_option('glib-src-dir')

glib_glob = glib_includedir + '/glib/*.h'
if glib_srcdir != ''
  glib_glob += ',' + glib_srcdir + '/glib/*.c'
endif

glib_sources_file = custom_target('glib-sources-file',
  input: 'glib-2.0.c',
  output: 'glib-sources.list',
  command: [
    find_program('generate_source_list.py'),
    '@OUTPUT@',
    glib_glob,
    'glib-autocleanups.h',
    glib_libincludedir + '/glibconfig.h',
    glib_includedir + '/gobject/glib-types.h',
    '@INPUT@',
  ]
)

glib_gir = custom_target('gir-glib',
  input: glib_sources_file,
  output: 'GLib-2.0.gir',
  depends: giscanner_pymod,
  install: true,
  install_dir: girdir,
  command: scanner_command + [
    '--identifier-prefix=G',
    '--symbol-prefix=g',
    '--symbol-prefix=glib',
    '--c-include=glib.h',
    '--namespace=GLib',
    '--nsversion=2.0',
    '--pkg=glib-2.0',
    '--library=glib-2.0',
    '--library=gobject-2.0',
    '--cflags-begin',
    '-I' + glib_includedir,
    '-I' + glib_libincludedir,
    '-DGLIB_COMPILATION',
    '-D__G_I18N_LIB_H__',
    '-DGETTEXT_PACKAGE=Dummy',
    '--cflags-end',
    '--filelist=@INPUT@',
  ]
)

gir_files += glib_gir

# GObject
gobject_glob = glib_includedir + '/gobject/*.h'
if glib_srcdir != ''
  gobject_glob += ',' + glib_srcdir + '/gobject/*.c'
endif

gobject_sources_file = custom_target('gobject-sources-file',
  input: 'gobject-2.0.c',
  output: 'gobject-sources.list',
  command: [
    find_program('generate_source_list.py'),
    '@OUTPUT@',
    gobject_glob,
    'glib-types.h',
    '@INPUT@',
  ]
)

gobject_gir = custom_target('gir-gobject',
  input: gobject_sources_file,
  output: 'GObject-2.0.gir',
  depends: [glib_gir, giscanner_pymod],
  install: true,
  install_dir: girdir,
  command: scanner_command + [
    '--identifier-prefix=G',
    '--symbol-prefix=g',
    '--c-include=glib-object.h',
    '--namespace=GObject',
    '--nsversion=2.0',
    '--pkg=gobject-2.0',
    '--library=gobject-2.0',
    '--include-uninstalled=' + glib_gir.full_path(),
    '--cflags-begin',
    '-I' + glib_includedir,
    '-I' + glib_libincludedir,
    '-DGOBJECT_COMPILATION',
    '--cflags-end',
    '--filelist=@INPUT@',
  ]
)

gir_files += gobject_gir

# GModule
gir_files += custom_target('gir-gmodule',
  input: 'gmodule-2.0.c', # TODO: glib sources
  output: 'GModule-2.0.gir',
  depends: [glib_gir, giscanner_pymod],
  install: true,
  install_dir: girdir,
  command: scanner_command + [
    '--identifier-prefix=G',
    '--symbol-prefix=g',
    '--c-include=gmodule.h',
    '--namespace=GModule',
    '--nsversion=2.0',
    '--pkg=gmodule-2.0',
    '--library=gmodule-2.0',
    '--include-uninstalled=' + glib_gir.full_path(),
    '--cflags-begin',
    '-I' + glib_includedir,
    '-I' + glib_libincludedir,
    '--cflags-end',
    glib_includedir + '/gmodule.h',
    '@INPUT@',
  ]
)

# Gio
gio_command = scanner_command + [
  '--identifier-prefix=G',
  '--symbol-prefix=g',
  '--c-include=gio/gio.h',
  '--namespace=Gio',
  '--nsversion=2.0',
  '--pkg=gio-2.0',
  '--library=gio-2.0',
  '--include-uninstalled=' + gobject_gir.full_path(),
  '--cflags-begin',
  '-DGIO_COMPILATION',
  '-DG_SETTINGS_ENABLE_BACKEND',
  '-I' + glib_includedir,
  '--cflags-end',
  '--filelist=@INPUT@',
]

gio_glob = glib_includedir + '/gio/*.h'
if glib_srcdir != ''
  gio_glob += ',' + glib_srcdir + '/gio/*.c'
endif

if giounix_dep.found()
  giounix_includedir = giounix_dep.get_pkgconfig_variable('includedir') + '/gio-unix-2.0'
  gio_glob += ',' + giounix_includedir + '/gio/*.h'

  get_header_list = '''
from glob import glob
from os.path import basename

print(','.join(basename(f) for f in glob('@0@/gio/*.h')))
'''.format(giounix_includedir)

  ret = run_command(py3.find_python(), '-c', get_header_list)
  if ret.returncode() != 0
    error('Failed to get gio header list')
  endif
  gio_headers = ret.stdout().strip().split(',')
  foreach header : gio_headers
    gio_command += '--c-include=gio/' + header
  endforeach

  gio_command += '--pkg=gio-unix-2.0'
endif

gio_sources_file = custom_target('gio-sources-file',
  input: 'gio-2.0.c',
  output: 'gio-sources.list',
  command: [
    find_program('generate_source_list.py'),
    '@OUTPUT@',
    gio_glob,
    ' ',
    '@INPUT@',
  ]
)

gir_files += custom_target('gir-gio',
  input: gio_sources_file,
  output: 'Gio-2.0.gir',
  depends: [gobject_gir, giscanner_pymod],
  install: true,
  install_dir: girdir,
  command: gio_command,
)

# GIRepository
gir_files += custom_target('gir-girepository',
  input: girepo_gir_sources,
  output: 'GIRepository-2.0.gir',
  depends: [gobject_gir, giscanner_pymod],
  install: true,
  install_dir: girdir,
  command: scanner_command + [
    '--identifier-prefix=GI',
    '--symbol-prefix=g',
    '--c-include=girepository.h',
    '--namespace=GIRepository',
    '--nsversion=2.0',
    '--pkg=gobject-introspection-1.0',
    '--library=girepository-1.0',
    '--include-uninstalled=' + gobject_gir.full_path(),
    '--cflags-begin',
    '-DGI_COMPILATION',
    '-I' + meson.source_root() + '/girepository',
    '--cflags-end',
    '@INPUT@',
  ]
)

foreach gir : gir_files
  custom_target('generate-typelib-@0@'.format(gir).underscorify(),
    input: gir,
    output: '@BASENAME@.typelib',
    command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@'],
    install: true,
    install_dir: typelibdir,
  )
endforeach