Skip to content
0.2.0-dev Download ZIP
147 lines ·6.1 KB Raw
1#!/usr/bin/env python
2from misc.utility.scons_hints import *
3
4Import("env")
5
6File = env.File
7
8# TODO: Add warning to headers and code about their autogenerated status.
9if env["use_sowrap"]:
10 # We have to implement separate builders for so wrappers as the
11 # autogenerated Wayland protocol wrapper must include them instead of the
12 # native libraries.
13
14 WAYLAND_BUILDERS_SOWRAP = {
15 "WAYLAND_API_HEADER": Builder(
16 action=env.Run(
17 r"wayland-scanner -c client-header < ${SOURCE} | "
18 r"sed 's:wayland-client-core\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
19 ),
20 single_source=True,
21 ),
22 "WAYLAND_API_CODE": Builder(
23 action=env.Run(
24 r"wayland-scanner -c private-code < ${SOURCE} | "
25 r"sed 's:wayland-util\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
26 ),
27 single_source=True,
28 ),
29 }
30 env.Append(BUILDERS=WAYLAND_BUILDERS_SOWRAP)
31else:
32 WAYLAND_BUILDERS = {
33 "WAYLAND_API_HEADER": Builder(
34 action=env.Run(r"wayland-scanner -c client-header < ${SOURCE} > ${TARGET}"),
35 single_source=True,
36 ),
37 "WAYLAND_API_CODE": Builder(
38 action=env.Run(r"wayland-scanner -c private-code < ${SOURCE} > ${TARGET}"),
39 single_source=True,
40 ),
41 }
42 env.Append(BUILDERS=WAYLAND_BUILDERS)
43
44
45def generate_from_xml(name, path):
46 header = env.WAYLAND_API_HEADER(File(f"protocol/{name}.gen.h"), path)
47 source = env.WAYLAND_API_CODE(File(f"protocol/{name}.gen.c"), path)
48 env.NoCache(header, source)
49
50 return source
51
52
53generated_sources = [
54 # Core protocol
55 generate_from_xml("wayland", "#thirdparty/wayland/protocol/wayland.xml"),
56 # Stable protocols
57 generate_from_xml("tablet", "#thirdparty/wayland-protocols/stable/tablet/tablet-v2.xml"),
58 generate_from_xml("viewporter", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml"),
59 generate_from_xml("xdg_shell", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml"),
60 # Staging protocols
61 generate_from_xml(
62 "color_management", "#thirdparty/wayland-protocols/staging/color-management/color-management-v1.xml"
63 ),
64 generate_from_xml("cursor_shape", "#thirdparty/wayland-protocols/staging/cursor-shape/cursor-shape-v1.xml"),
65 generate_from_xml(
66 "fractional_scale", "#thirdparty/wayland-protocols/staging/fractional-scale/fractional-scale-v1.xml"
67 ),
68 generate_from_xml("xdg_activation", "#thirdparty/wayland-protocols/staging/xdg-activation/xdg-activation-v1.xml"),
69 generate_from_xml(
70 "xdg_system_bell", "#thirdparty/wayland-protocols/staging/xdg-system-bell/xdg-system-bell-v1.xml"
71 ),
72 generate_from_xml(
73 "xdg_toplevel_icon", "#thirdparty/wayland-protocols/staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml"
74 ),
75 generate_from_xml("pointer_warp", "#thirdparty/wayland-protocols/staging/pointer-warp/pointer-warp-v1.xml"),
76 # Unstable protocols
77 generate_from_xml(
78 "idle_inhibit", "#thirdparty/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
79 ),
80 generate_from_xml(
81 "pointer_constraints",
82 "#thirdparty/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml",
83 ),
84 generate_from_xml(
85 "pointer_gestures", "#thirdparty/wayland-protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"
86 ),
87 generate_from_xml(
88 "primary_selection",
89 "#thirdparty/wayland-protocols/unstable/primary-selection/primary-selection-unstable-v1.xml",
90 ),
91 generate_from_xml(
92 "relative_pointer", "#thirdparty/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
93 ),
94 generate_from_xml("text_input", "#thirdparty/wayland-protocols/unstable/text-input/text-input-unstable-v3.xml"),
95 generate_from_xml(
96 "xdg_decoration", "#thirdparty/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
97 ),
98 generate_from_xml(
99 "xdg_foreign_v1", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml"
100 ), # Note: deprecated
101 generate_from_xml(
102 "xdg_foreign_v2", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml"
103 ),
104 generate_from_xml("linux_dmabuf_v1", "#thirdparty/wayland-protocols/stable/linux-dmabuf/linux-dmabuf-v1.xml"),
105 generate_from_xml(
106 "linux_explicit_synchronization_unstable_v1",
107 "#thirdparty/wayland-protocols/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml",
108 ),
109 generate_from_xml("fifo_v1", "#thirdparty/wayland-protocols/staging/fifo/fifo-v1.xml"),
110 generate_from_xml("commit_timing_v1", "#thirdparty/wayland-protocols/staging/commit-timing/commit-timing-v1.xml"),
111 generate_from_xml(
112 "linux_drm_syncobj_v1", "#thirdparty/wayland-protocols/staging/linux-drm-syncobj/linux-drm-syncobj-v1.xml"
113 ),
114 generate_from_xml(
115 "tearing_control_v1", "#thirdparty/wayland-protocols/staging/tearing-control/tearing-control-v1.xml"
116 ),
117 generate_from_xml("wayland-drm", "#thirdparty/wayland-protocols/mesa/wayland-drm.xml"),
118 generate_from_xml("godot_embedding_compositor", "godot-embedding-compositor.xml"),
119]
120
121source_files = generated_sources + [
122 File("detect_prime_egl.cpp"),
123 File("display_server_wayland.cpp"),
124 File("key_mapping_xkb.cpp"),
125 File("wayland_thread.cpp"),
126 File("wayland_embedder.cpp"),
127]
128
129if env["use_sowrap"]:
130 source_files.append([
131 File("dynwrappers/wayland-cursor-so_wrap.c"),
132 File("dynwrappers/wayland-client-core-so_wrap.c"),
133 File("dynwrappers/wayland-egl-core-so_wrap.c"),
134 ])
135
136 if env["libdecor"]:
137 source_files.append(File("dynwrappers/libdecor-so_wrap.c"))
138
139
140if env["vulkan"]:
141 source_files.append(File("rendering_context_driver_vulkan_wayland.cpp"))
142
143if env["opengl3"]:
144 source_files.append(File("egl_manager_wayland.cpp"))
145 source_files.append(File("egl_manager_wayland_gles.cpp"))
146
147Return("source_files")