@samitouri / QOSamiQemu / commits / c28f118805

ui: extract common sources into a static library

Move clipboard, cursor, display-surface, input-keymap, kbd-state, keymaps, vt100, and qemu-pixman into a separate static library 'qemuui'. This allows these common UI sources to be linked by targets outside of the system emulator build, such as standalone VNC or D-Bus display binaries. keymaps generation has to be moved earlier, so that header dependency are resolved first. The library objects are re-exported via a dependency so existing system_ss consumers are unaffected. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Feb 23, 2026 at 11:42 UTC c28f1188055a1a2581e3f635b8bcded8e57d7299
1 file changed +55 -48
ui/meson.build
+55 -48
@@ -1,25 +1,67 @@
1 -system_ss.add(pixman)
1 +keymaps = [
2 + ['atset1', 'qcode'],
3 + ['linux', 'qcode'],
4 + ['qcode', 'atset1'],
5 + ['qcode', 'atset2'],
6 + ['qcode', 'atset3'],
7 + ['qcode', 'linux'],
8 + ['qcode', 'qnum'],
9 + ['qcode', 'sun'],
10 + ['qnum', 'qcode'],
11 + ['usb', 'qcode'],
12 + ['win32', 'qcode'],
13 + ['x11', 'qcode'],
14 + ['xorgevdev', 'qcode'],
15 + ['xorgkbd', 'qcode'],
16 + ['xorgxquartz', 'qcode'],
17 + ['xorgxwin', 'qcode'],
18 + ['osx', 'qcode'],
19 +]
20 +
21 +if have_system or xkbcommon.found()
22 + keycodemapdb_proj = subproject('keycodemapdb', required: true)
23 + foreach e : keymaps
24 + output = 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1])
25 + genh += custom_target(output,
26 + output: output,
27 + capture: true,
28 + input: keycodemapdb_proj.get_variable('keymaps_csv'),
29 + command: [python, keycodemapdb_proj.get_variable('keymap_gen').full_path(),
30 + 'code-map', '--lang', 'glib2',
31 + '--varname', 'qemu_input_map_@0@_to_@1@'.format(e[0], e[1]),
32 + '@INPUT0@', e[0], e[1]])
33 + endforeach
34 +endif
35 +
36 +libui_sources = files(
37 + 'clipboard.c',
38 + 'console.c',
39 + 'cursor.c',
40 + 'dmabuf.c',
41 + 'display-surface.c',
42 + 'input-keymap.c',
43 + 'kbd-state.c',
44 + 'keymaps.c',
45 + 'qemu-pixman.c',
46 + 'vgafont.c',
47 + )
48 +if pixman.found()
49 + libui_sources += files('cp437.c', 'vt100.c')
50 +endif
51 +libui = static_library('qemuui', libui_sources + genh,
52 + dependencies: [pixman],
53 + build_by_default: false)
54 +ui = declare_dependency(objects: libui.extract_all_objects(recursive: false), dependencies: [pixman])
55 system_ss.add(png)
56 system_ss.add(files(
4 - 'clipboard.c',
5 - 'console.c',
6 - 'cp437.c',
7 - 'cursor.c',
8 - 'display-surface.c',
9 - 'dmabuf.c',
10 - 'input-keymap.c',
57 'input-legacy.c',
58 'input-barrier.c',
59 'input.c',
14 - 'kbd-state.c',
15 - 'keymaps.c',
16 - 'qemu-pixman.c',
60 'ui-hmp-cmds.c',
61 'ui-qmp-cmds.c',
62 'util.c',
20 - 'vgafont.c',
21 - 'vt100.c',
63 ))
64 +system_ss.add(ui)
65 system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c'))
66 if dbus_display
67 system_ss.add(files('dbus-module.c'))
@@ -149,41 +191,6 @@ if spice.found()
191 endif
192 endif
193
152 -keymaps = [
153 - ['atset1', 'qcode'],
154 - ['linux', 'qcode'],
155 - ['qcode', 'atset1'],
156 - ['qcode', 'atset2'],
157 - ['qcode', 'atset3'],
158 - ['qcode', 'linux'],
159 - ['qcode', 'qnum'],
160 - ['qcode', 'sun'],
161 - ['qnum', 'qcode'],
162 - ['usb', 'qcode'],
163 - ['win32', 'qcode'],
164 - ['x11', 'qcode'],
165 - ['xorgevdev', 'qcode'],
166 - ['xorgkbd', 'qcode'],
167 - ['xorgxquartz', 'qcode'],
168 - ['xorgxwin', 'qcode'],
169 - ['osx', 'qcode'],
170 -]
171 -
172 -if have_system or xkbcommon.found()
173 - keycodemapdb_proj = subproject('keycodemapdb', required: true)
174 - foreach e : keymaps
175 - output = 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1])
176 - genh += custom_target(output,
177 - output: output,
178 - capture: true,
179 - input: keycodemapdb_proj.get_variable('keymaps_csv'),
180 - command: [python, keycodemapdb_proj.get_variable('keymap_gen').full_path(),
181 - 'code-map', '--lang', 'glib2',
182 - '--varname', 'qemu_input_map_@0@_to_@1@'.format(e[0], e[1]),
183 - '@INPUT0@', e[0], e[1]])
184 - endforeach
185 -endif
186 -
194 subdir('shader')
195
196 if have_system