2025-06-10 08:39:20 +01:00

128 lines
4.7 KiB
Python

#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")
# TODO: Add warning to headers and code about their autogenerated status.
if env["use_sowrap"]:
# We have to implement separate builders for so wrappers as the
# autogenerated Wayland protocol wrapper must include them instead of the
# native libraries.
WAYLAND_BUILDERS_SOWRAP = {
"WAYLAND_API_HEADER": Builder(
action=env.Run(
r"wayland-scanner -c client-header < ${SOURCE} | "
r"sed 's:wayland-client-core\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
),
single_source=True,
),
"WAYLAND_API_CODE": Builder(
action=env.Run(
r"wayland-scanner -c private-code < ${SOURCE} | "
r"sed 's:wayland-util\.h:../dynwrappers/wayland-client-core-so_wrap\.h:' > ${TARGET}",
),
single_source=True,
),
}
env.Append(BUILDERS=WAYLAND_BUILDERS_SOWRAP)
else:
WAYLAND_BUILDERS = {
"WAYLAND_API_HEADER": Builder(
action=env.Run(r"wayland-scanner -c client-header < ${SOURCE} > ${TARGET}"),
single_source=True,
),
"WAYLAND_API_CODE": Builder(
action=env.Run(r"wayland-scanner -c private-code < ${SOURCE} > ${TARGET}"),
single_source=True,
),
}
env.Append(BUILDERS=WAYLAND_BUILDERS)
def generate_from_xml(name, path):
header = env.WAYLAND_API_HEADER(f"protocol/{name}.gen.h", path)
source = env.WAYLAND_API_CODE(f"protocol/{name}.gen.c", path)
env.NoCache(header, source)
return env.Object(f"protocol/{name}.gen.c")
objects = [
# Core protocol
generate_from_xml("wayland", "#thirdparty/wayland/protocol/wayland.xml"),
# Stable protocols
generate_from_xml("tablet", "#thirdparty/wayland-protocols/stable/tablet/tablet-v2.xml"),
generate_from_xml("viewporter", "#thirdparty/wayland-protocols/stable/viewporter/viewporter.xml"),
generate_from_xml("xdg_shell", "#thirdparty/wayland-protocols/stable/xdg-shell/xdg-shell.xml"),
# Staging protocols
generate_from_xml("cursor_shape", "#thirdparty/wayland-protocols/staging/cursor-shape/cursor-shape-v1.xml"),
generate_from_xml(
"fractional_scale", "#thirdparty/wayland-protocols/staging/fractional-scale/fractional-scale-v1.xml"
),
generate_from_xml("xdg_activation", "#thirdparty/wayland-protocols/staging/xdg-activation/xdg-activation-v1.xml"),
generate_from_xml(
"xdg_system_bell", "#thirdparty/wayland-protocols/staging/xdg-system-bell/xdg-system-bell-v1.xml"
),
# Unstable protocols
generate_from_xml(
"idle_inhibit", "#thirdparty/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
),
generate_from_xml(
"pointer_constraints",
"#thirdparty/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml",
),
generate_from_xml(
"pointer_gestures", "#thirdparty/wayland-protocols/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"
),
generate_from_xml(
"primary_selection",
"#thirdparty/wayland-protocols/unstable/primary-selection/primary-selection-unstable-v1.xml",
),
generate_from_xml(
"relative_pointer", "#thirdparty/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
),
generate_from_xml("text_input", "#thirdparty/wayland-protocols/unstable/text-input/text-input-unstable-v3.xml"),
generate_from_xml(
"xdg_decoration", "#thirdparty/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
),
generate_from_xml(
"xdg_foreign_v1", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml"
), # Note: deprecated
generate_from_xml(
"xdg_foreign_v2", "#thirdparty/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml"
),
]
source_files = [
"detect_prime_egl.cpp",
"display_server_wayland.cpp",
"key_mapping_xkb.cpp",
"wayland_thread.cpp",
]
if env["use_sowrap"]:
source_files.append(
[
"dynwrappers/wayland-cursor-so_wrap.c",
"dynwrappers/wayland-client-core-so_wrap.c",
"dynwrappers/wayland-egl-core-so_wrap.c",
]
)
if env["libdecor"]:
source_files.append("dynwrappers/libdecor-so_wrap.c")
if env["vulkan"]:
source_files.append("rendering_context_driver_vulkan_wayland.cpp")
if env["opengl3"]:
source_files.append("egl_manager_wayland.cpp")
source_files.append("egl_manager_wayland_gles.cpp")
for source_file in source_files:
objects.append(env.Object(source_file))
Return("objects")