summaryrefslogtreecommitdiff
path: root/demos/gtk-demo/meson.build
blob: 5b79dfad5f2cf746befa0062bd7b812f690348a3 (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
# These should be in the order you want them to appear in the
# demo app, which means alphabetized by demo title, not filename
demos = files([
  'application_demo.c',
  'assistant.c',
  'builder.c',
  'clipboard.c',
  'combobox.c',
  'constraints.c',
  'constraints_interactive.c',
  'constraints_vfl.c',
  'constraints_builder.c',
  'css_accordion.c',
  'css_basics.c',
  'css_blendmodes.c',
  'css_multiplebgs.c',
  'css_pixbufs.c',
  'css_shadows.c',
  'cursors.c',
  'dialog.c',
  'drawingarea.c',
  'dnd.c',
  'editable_cells.c',
  'entry_completion.c',
  'entry_undo.c',
  'errorstates.c',
  'expander.c',
  'filtermodel.c',
  'fishbowl.c',
  'fixed.c',
  'fontrendering.c',
  'frames.c',
  'gears.c',
  'gestures.c',
  'glarea.c',
  'gltransition.c',
  'headerbar.c',
  'hypertext.c',
  'iconscroll.c',
  'iconview.c',
  'iconview_edit.c',
  'images.c',
  'infobar.c',
  'layoutmanager.c',
  'layoutmanager2.c',
  'links.c',
  'listbox.c',
  'listbox_controls.c',
  'menu.c',
  'flowbox.c',
  'list_store.c',
  'listview_applauncher.c',
  'listview_clocks.c',
  'listview_colors.c',
  'listview_filebrowser.c',
  'listview_minesweeper.c',
  'dropdown.c',
  'listview_settings.c',
  'listview_ucd.c',
  'listview_weather.c',
  'listview_words.c',
  'markup.c',
  'overlay.c',
  'overlay_decorative.c',
  'paint.c',
  'paintable.c',
  'paintable_animated.c',
  'paintable_emblem.c',
  'paintable_mediastream.c',
  'paintable_symbolic.c',
  'panes.c',
  'password_entry.c',
  'peg_solitaire.c',
  'pickers.c',
  'printing.c',
  'revealer.c',
  'rotated_text.c',
  'scale.c',
  'search_entry.c',
  'search_entry2.c',
  'shadertoy.c',
  'shortcuts.c',
  'shortcut_triggers.c',
  'sidebar.c',
  'sizegroup.c',
  'sliding_puzzle.c',
  'spinbutton.c',
  'spinner.c',
  'stack.c',
  'tabs.c',
  'tagged_entry.c',
  'textmask.c',
  'textundo.c',
  'textview.c',
  'textscroll.c',
  'themes.c',
  'theming_style_classes.c',
  'transparent.c',
  'tree_store.c',
  'video_player.c',
])

gtkdemo_deps = [ libgtk_dep, ]

extra_demo_sources = files([
  'main.c',
  'fontify.c',
  'gtkfishbowl.c',
  'fontplane.c',
  'gtkgears.c',
  'gtkshaderbin.c',
  'gtkshadertoy.c',
  'gtkshaderstack.c',
  'gskshaderpaintable.c',
  'puzzlepiece.c',
  'bluroverlay.c',
  'demoimage.c',
  'demotaggedentry.c',
  'demochild.c',
  'demolayout.c',
  'demowidget.c',
  'demo2layout.c',
  'singular_value_decomposition.c',
  'four_point_transform.c',
  'demo2widget.c',
  'demo3widget.c',
  'pixbufpaintable.c',
  'script-names.c',
  'unicode-names.c',
  'suggestionentry.c',
])

if harfbuzz_dep.found() and pangoft_dep.found()
  demos += files(['font_features.c'])
  extra_demo_sources += files(['language-names.c'])
  gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
endif

if os_unix
  demos += files('pagesetup.c')
endif

librsvg_dep = dependency('librsvg-2.0', version: '>= 2.52.0', required: false)

if librsvg_dep.found()
  demos += files('paintable_svg.c')
  extra_demo_sources += files(['svgpaintable.c'])
  gtkdemo_deps += [ librsvg_dep ]
endif

gtkdemo_args = [ '-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED', ]

demos_h = custom_target('gtk4 demo header',
  output: 'demos.h',
  input: demos,
  command: [ find_program('geninclude.py'), '@OUTPUT@', '@INPUT@' ],
)

objcopy_supports_add_symbol = false
objcopy = find_program('objcopy', required : false)
if objcopy.found()
  objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
endif

ld = find_program('ld', required : false)

if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
  glib_compile_resources = find_program('glib-compile-resources')

  # Create the resource blob
  gtkdemo_gresource = custom_target('gtkdemo.gresource',
      input : 'demo.gresource.xml',
      output : 'gtkdemo.gresource',
      depfile : 'gtkdemo.gresource.d',
      command : [glib_compile_resources,
                 '--generate',
                 '--target=@OUTPUT@',
                 '--dependency-file=@DEPFILE@',
                 '--sourcedir=' + meson.current_source_dir(),
                 '--sourcedir=' + meson.current_build_dir(),
                 '@INPUT@'])

  # Create resource data file
  gtkdemo_resources_c = custom_target('gtkdemo_resources.c',
      input : 'demo.gresource.xml',
      output : 'gtkdemo_resources.c',
      depfile : 'gtkdemo_resources.c.d',
      command : [glib_compile_resources,
                 '--generate-source',
                 '--target=@OUTPUT@',
                 '--dependency-file=@DEPFILE@',
                 '--sourcedir=' + meson.current_source_dir(),
                 '--sourcedir=' + meson.current_build_dir(),
                 '--external-data',
                 '--c-name', '_g_binary_gtkdemo',
                 '@INPUT@'])

  # Create object file containing resource data
  gtkdemo_resources_binary = custom_target('gtkdemo_resources.o',
      input : gtkdemo_gresource,
      output : 'gtkdemo_resources.o',
      command : [ld,
                 '-r',
                 '-b','binary',
                 '@INPUT@',
                 '-o','@OUTPUT@'])

  # Rename symbol to match the one in the C file
  gtkdemo_resources_o = custom_target('gtkdemo_resources2.o',
    input : gtkdemo_resources_binary,
    output : 'gtkdemo_resources2.o',
    command : [objcopy,
                 '--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
                 '@INPUT@',
                 '@OUTPUT@'])

  gtkdemo_resources = [
      gtkdemo_resources_c,
      gtkdemo_resources_o,
    ]
else
  gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
    'demo.gresource.xml',
    source_dir: '.',
  )
endif

# Use a subset of compiler flags
demo_cflags = []
foreach flag: common_cflags
  if flag not in ['-Werror=missing-prototypes', '-Wmissing-prototypes',
                  '-Werror=missing-declarations', '-Wmissing-declarations',
                  '-fvisibility=hidden']
    demo_cflags += flag
  endif
endforeach

gtkdemo_deps += [ demo_conf_h ]

executable('gtk4-demo',
  sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
  c_args: gtkdemo_args + demo_cflags,
  dependencies: gtkdemo_deps,
  include_directories: confinc,
  win_subsystem: 'windows',
  link_args: extra_demo_ldflags,
  install: true,
)

executable('gtk4-demo-application',
  sources: ['application.c', gtkdemo_resources],
  c_args: gtkdemo_args + common_cflags,
  dependencies: gtkdemo_deps,
  include_directories: confinc,
  win_subsystem: 'windows',
  link_args: extra_demo_ldflags,
  install: true,
)

# icons
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')

foreach size: ['scalable', 'symbolic']
  install_subdir('data/' + size, install_dir: icontheme_dir)
endforeach

# desktop file
install_data('org.gtk.Demo4.desktop', install_dir: gtk_applicationsdir)

# GSettings
install_data('org.gtk.Demo4.gschema.xml', install_dir: gtk_schemasdir)
gnome.compile_schemas()

# appdata
configure_file(
  input: 'org.gtk.Demo4.appdata.xml.in',
  output: 'org.gtk.Demo4.appdata.xml',
  configuration: appdata_config,
  install_dir: gtk_appdatadir
)