summaryrefslogtreecommitdiff
path: root/gdk-pixbuf/meson.build
blob: 77c162bfc86c455c7d073a60dc64659e0d8fe71d (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
subdir('pixops')

# Loader libs
#  - name
#  - sources
#  - conditional, otherwise always built

# We need to disable the in-house loaders for BMP, GIF and ICO
# when enable_native_windows_loaders is true
loaders = [
  [ 'png', [ 'io-png.c' ], enabled_loaders.contains('png') ],
  [ 'bmp', [ 'io-bmp.c' ], not enable_native_windows_loaders ],
  [ 'gif', [ 'io-gif.c', 'io-gif-animation.c' ], not enable_native_windows_loaders ],
  [ 'ico', [ 'io-ico.c' ], not enable_native_windows_loaders ],
  [ 'ani', [ 'io-ani.c', 'io-ani-animation.c' ] ],
  [ 'jpeg', [ 'io-jpeg.c' ], enabled_loaders.contains('jpeg') ],
  [ 'pnm', [ 'io-pnm.c' ] ],
  [ 'tiff', [ 'io-tiff.c' ], enabled_loaders.contains('tiff') ],
  [ 'xpm', [ 'io-xpm.c' ] ],
  [ 'xbm', [ 'io-xbm.c' ] ],
  [ 'tga', [ 'io-tga.c', 'gdk-pixbuf-buffer-queue.c' ] ],
  [ 'icns', [ 'io-icns.c' ] ],
  [ 'jasper', [ 'io-jasper.c' ], enabled_loaders.contains('jasper'), jasper_extra_cflags ],
  [ 'qtif', [ 'io-qtif.c' ] ]
]

gdk_pixbuf_inc = include_directories('.')

gdk_pixbuf_cflags = [
  '-DG_LOG_STRUCTURED=1',
  '-DG_LOG_DOMAIN="GdkPixbuf"',
  '-DGDK_PIXBUF_COMPILATION',
  '-DGDK_PIXBUF_PREFIX="@0@"'.format(gdk_pixbuf_prefix),
  '-DGDK_PIXBUF_LOCALEDIR="@0@"'.format(gdk_pixbuf_localedir),
  '-DGDK_PIXBUF_LIBDIR="@0@"'.format(gdk_pixbuf_libdir),
  '-DGDK_PIXBUF_BINARY_VERSION="@0@"'.format(gdk_pixbuf_binary_version),
  '-DGDK_PIXBUF_ENABLE_BACKEND',
  '-DPIXBUF_LIBDIR="@0@"'.format(gdk_pixbuf_loaderdir),
  '-DBUILT_MODULES_DIR="@0@"'.format(meson.current_build_dir()),
]

gdk_pixbuf_api_path = join_paths(gdk_pixbuf_api_name, 'gdk-pixbuf')

gdkpixbuf_features_conf = configuration_data()
gdkpixbuf_features_conf.set('GDK_PIXBUF_MAJOR', gdk_pixbuf_version_major)
gdkpixbuf_features_conf.set('GDK_PIXBUF_MINOR', gdk_pixbuf_version_minor)
gdkpixbuf_features_conf.set('GDK_PIXBUF_MICRO', gdk_pixbuf_version_micro)
gdkpixbuf_features_conf.set('GDK_PIXBUF_VERSION', meson.project_version())
gdkpixbuf_features_conf.set('GDK_PIXBUF_API_VERSION', gdk_pixbuf_api_version)
gdkpixbuf_features_conf.set('LT_CURRENT_MINUS_AGE', current_minus_age)

gdk_pixbuf_features_h = configure_file(input: 'gdk-pixbuf-features.h.in',
                                       output: 'gdk-pixbuf-features.h',
                                       configuration: gdkpixbuf_features_conf,
                                       install: true,
                                       install_dir: join_paths(gdk_pixbuf_includedir, gdk_pixbuf_api_path))

gdkpixbuf_headers = [
  'gdk-pixbuf.h',
  'gdk-pixbuf-animation.h',
  'gdk-pixbuf-autocleanups.h',
  'gdk-pixbuf-core.h',
  'gdk-pixbuf-io.h',
  'gdk-pixbuf-loader.h',
  'gdk-pixbuf-macros.h',
  'gdk-pixbuf-simple-anim.h',
  'gdk-pixbuf-transform.h',
]

install_headers(gdkpixbuf_headers + [ 'gdk-pixdata.h' ], subdir: gdk_pixbuf_api_path)

gdkpixbuf_sources = [
  'gdk-pixbuf.c',
  'gdk-pixbuf-animation.c',
  'gdk-pixbuf-data.c',
  'gdk-pixbuf-io.c',
  'gdk-pixbuf-loader.c',
  'gdk-pixbuf-scale.c',
  'gdk-pixbuf-simple-anim.c',
  'gdk-pixbuf-scaled-anim.c',
  'gdk-pixbuf-util.c',
  'gdk-pixdata.c',
]

gdkpixbuf_marshals = gnome.genmarshal('gdk-pixbuf-marshal',
                                      sources: 'gdk-pixbuf-marshal.list',
                                      prefix: '_gdk_pixbuf_marshal')

gdkpixbuf_enums = gnome.mkenums('gdk-pixbuf-enum-types',
                                sources: gdkpixbuf_headers,
                                c_template: 'gdk-pixbuf-enum-types.c.template',
                                h_template: 'gdk-pixbuf-enum-types.h.template',
                                install_header: true,
                                install_dir: join_paths(gdk_pixbuf_includedir, gdk_pixbuf_api_path))
gdkpixbuf_enum_h = gdkpixbuf_enums[1]

if host_system == 'windows'
  gdk_pixbuf_win_rc = configure_file(
    input: 'gdk_pixbuf.rc.in',
    output: 'gdk_pixbuf.rc',
    configuration: gdkpixbuf_features_conf,
  )
  gdk_pixbuf_win_res = import('windows').compile_resources(gdk_pixbuf_win_rc)
  gdkpixbuf_sources += gdk_pixbuf_win_res
endif

# Check if we need to build loaders as built-in functionality
included_loaders_cflags = []
included_loaders_deps = []

foreach l: loaders
  name = l[0]
  sources = l[1]
  cond = l.get(2, true)
  cflags = l.get(3, [])

  if cond and (builtin_loaders.contains(name) or builtin_all_loaders)
    cflag_for_included_loader = ['-DINCLUDE_@0@'.format(name)]
    included_loaders_cflags += cflag_for_included_loader

    mod = static_library('staticpixbufloader-@0@'.format(name),
                         sources,
                         dependencies: loaders_deps + gdk_pixbuf_deps,
                         include_directories: [ root_inc, gdk_pixbuf_inc ],
                         c_args: common_cflags + gdk_pixbuf_cflags + cflags + cflag_for_included_loader)

    included_loaders_deps += declare_dependency(link_with: mod)
  endif
endforeach

# List of formats supported by the native Windows components-based loader(s)
windows_native_loader_formats = [ 'bmp', 'emf', 'gif', 'ico', 'jpeg', 'tiff', 'wmf' ]
windows_base_loader_sources = [ 'io-gdip-utils.c', 'io-gdip-animation.c' ]

# Build the loaders using native Windows components as static modules, if requested
if enable_native_windows_loaders
  if builtin_loaders.contains('windows') or builtin_all_loaders
    cflag_for_included_loader = ['-DINCLUDE_gdiplus']
    included_loaders_cflags += cflag_for_included_loader
    win_loader_sources = windows_base_loader_sources
    foreach loader: windows_native_loader_formats
      win_loader_sources += 'io-gdip-@0@.c'.format(loader)
    endforeach

    mod = static_library('staticpixbufloader-gdiplus',
                         win_loader_sources,
                         dependencies: loaders_deps + gdk_pixbuf_deps,
                         include_directories: [ root_inc, gdk_pixbuf_inc ],
                         c_args: common_cflags + gdk_pixbuf_cflags + cflag_for_included_loader)

    included_loaders_deps += declare_dependency(link_with: mod)
  endif
endif

# The main gdk-pixbuf shared library
gdkpixbuf = library('gdk_pixbuf-2.0',
                    gdkpixbuf_sources + gdkpixbuf_enums + gdkpixbuf_marshals,
                    soversion: soversion,
                    version: libversion,
                    c_args: common_cflags + gdk_pixbuf_cflags + included_loaders_cflags,
                    link_args: common_ldflags,
                    include_directories: root_inc,
                    dependencies: gdk_pixbuf_deps + included_loaders_deps + [ pixops_dep ],
                    install: true)

gdkpixbuf_dep = declare_dependency(link_with: gdkpixbuf,
                                   include_directories: root_inc,
                                   dependencies: gdk_pixbuf_deps,
                                   sources: gdkpixbuf_enum_h)

# Now check if we are building loaders as installed shared modules
# We do this here because shared modules depend on libgdk-pixbuf
dynamic_loaders = []

foreach l: loaders
  name = l[0]
  sources = l[1]
  cond = l.get(2, true)
  cflags = l.get(3, [])

  if cond and not (builtin_loaders.contains(name) or builtin_all_loaders)
    mod = shared_module('pixbufloader-@0@'.format(name),
                        sources,
                        dependencies: loaders_deps + gdk_pixbuf_deps + [ gdkpixbuf_dep ],
                        include_directories: [ root_inc, gdk_pixbuf_inc ],
                        c_args: common_cflags + gdk_pixbuf_cflags + cflags,
                        install: true,
                        install_dir: gdk_pixbuf_loaderdir)

    # We need the path to build loaders.cache for tests
    dynamic_loaders += mod.full_path()
  endif
endforeach

# Build the loaders using native Windows components as dynamic modules, if requested
if enable_native_windows_loaders
  if not (builtin_loaders.contains('windows') or builtin_all_loaders)
    foreach loader: windows_native_loader_formats
      loader_sources = windows_base_loader_sources + [ 'io-gdip-@0@.c'.format(loader) ]

      mod = shared_module('pixbufloader-gdip-@0@'.format(loader),
                          loader_sources,
                          dependencies: loaders_deps + gdk_pixbuf_deps + [ gdkpixbuf_dep ],
                          include_directories: [ root_inc, gdk_pixbuf_inc ],
                          c_args: common_cflags + gdk_pixbuf_cflags + cflags,
                          install: true,
                          install_dir: gdk_pixbuf_loaderdir)
      dynamic_loaders += mod.full_path()
    endforeach
  endif
endif

gdkpixbuf_bin = [
  [ 'gdk-pixbuf-csource' ],
  [ 'gdk-pixbuf-pixdata' ],
  [ 'gdk-pixbuf-query-loaders', [ 'queryloaders.c' ] ],
]

foreach bin: gdkpixbuf_bin
  bin_name = bin[0]
  bin_source = bin.get(1, bin_name + '.c')

  bin = executable(bin_name, bin_source,
                   dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ],
                   include_directories: [ root_inc, gdk_pixbuf_inc ],
                   c_args: common_cflags + gdk_pixbuf_cflags,
                   install: true)

  # Used in tests
  set_variable(bin_name.underscorify(), bin)
endforeach

# The 'loaders.cache' used for testing, so we don't accidentally
# load the installed cache; we always build it by default
loaders_cache = custom_target('loaders.cache',
                              output: 'loaders.cache',
                              capture: true,
                              command: [
                                gdk_pixbuf_query_loaders,
                                dynamic_loaders,
                              ],
                              build_by_default: true)
loaders_dep = declare_dependency(sources: [ loaders_cache ])

build_gir = get_option('with_gir') and not meson.is_cross_build()
if build_gir
  gir_args = [
    '--quiet',
    '--c-include=gdk-pixbuf/gdk-pixbuf.h',
    '-DGDK_PIXBUF_COMPILATION',
  ]

  gnome.generate_gir(gdkpixbuf,
                     sources: gdkpixbuf_sources + gdkpixbuf_headers + gdkpixbuf_enums + [
                       gdk_pixbuf_features_h,
                       'gdk-pixdata.h',
                     ],
                     namespace: 'GdkPixbuf',
                     nsversion: gdk_pixbuf_api_version,
                     identifier_prefix: 'Gdk',
                     symbol_prefix: 'gdk',
                     export_packages: 'gdk-pixbuf-2.0',
                     includes: [ 'GModule-2.0', 'Gio-2.0', ],
                     install: true,
                     extra_args: gir_args)
endif