From 38cab2e423b14bb1c8a6273a9387be6b0f9d6c38 Mon Sep 17 00:00:00 2001 From: Ali Chraghi <63465728+AliChraghi@users.noreply.github.com> Date: Fri, 24 Dec 2021 11:36:51 +0330 Subject: [PATCH] add wayland cross-compilation support (#140) * add wayland-headers include path * add wayland protocols header to wayland target includes * move `xkb_unicode.c` to `sources_linux.c` * glfw: document where wayland generated sources come from * glfw: update sdk-linux-x86_64 to include Wayland protocol sources See https://github.com/hexops/sdk-linux-x86_64/pull/2 Co-authored-by: Stephen Gutekanst --- glfw/src/sources_linux.c | 3 ++- glfw/src/sources_linux_wayland.c | 9 +++++++++ glfw/src/sources_linux_x11.c | 1 - glfw/system_sdk.zig | 16 ++++++++++------ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/glfw/src/sources_linux.c b/glfw/src/sources_linux.c index e15d954d..efe14f5a 100644 --- a/glfw/src/sources_linux.c +++ b/glfw/src/sources_linux.c @@ -3,4 +3,5 @@ // General Linux-like sources #include "posix_time.c" #include "posix_thread.c" -#include "linux_joystick.c" \ No newline at end of file +#include "linux_joystick.c" +#include "xkb_unicode.c" \ No newline at end of file diff --git a/glfw/src/sources_linux_wayland.c b/glfw/src/sources_linux_wayland.c index c96d0e77..31efe7a3 100644 --- a/glfw/src/sources_linux_wayland.c +++ b/glfw/src/sources_linux_wayland.c @@ -2,3 +2,12 @@ #include "wl_monitor.c" #include "wl_window.c" #include "wl_init.c" + +// Note: These sources are generated by wayland-scanner, and distributed in sdk-linux-* +// See e.g. https://github.com/hexops/sdk-linux-x86_64/blob/main/generate-wayland.sh +#include "wayland-viewporter-client-protocol.c" +#include "wayland-xdg-decoration-client-protocol.c" +#include "wayland-xdg-shell-client-protocol.c" +#include "wayland-idle-inhibit-unstable-v1-client-protocol.c" +#include "wayland-pointer-constraints-unstable-v1-client-protocol.c" +#include "wayland-relative-pointer-unstable-v1-client-protocol.c" \ No newline at end of file diff --git a/glfw/src/sources_linux_x11.c b/glfw/src/sources_linux_x11.c index 43e706ad..e2e1c79e 100644 --- a/glfw/src/sources_linux_x11.c +++ b/glfw/src/sources_linux_x11.c @@ -2,5 +2,4 @@ #include "x11_init.c" #include "x11_window.c" #include "x11_monitor.c" -#include "xkb_unicode.c" #include "glx_context.c" diff --git a/glfw/system_sdk.zig b/glfw/system_sdk.zig index ccacd497..9d876c5a 100644 --- a/glfw/system_sdk.zig +++ b/glfw/system_sdk.zig @@ -27,7 +27,7 @@ //! Best way to get this file in your own repository? We suggest just copying it, or importing it //! from a project that includes it if you're using one (e.g. mach-glfw) //! -//! version: 1.0 +//! version: Dec 24, 2021 const std = @import("std"); const Builder = std.build.Builder; @@ -46,7 +46,7 @@ pub const Options = struct { /// The Linux x86-64 SDK repository name. linux_x86_64: []const u8 = "sdk-linux-x86_64", - linux_x86_64_revision: []const u8 = "ce9ef1e0b45d982a399fac6a9456a47a5e1f0d2e", + linux_x86_64_revision: []const u8 = "ab7fa8f3a05b06e0b06f4277b484e27004bfb20f", /// If true, the Builder.sysroot will set to the SDK path. This has the drawback of preventing /// you from including headers, libraries, etc. from outside the SDK generally. However, it can @@ -101,11 +101,15 @@ fn includeSdkLinuxX8664(b: *Builder, step: *std.build.LibExeObjStep, options: Op } var sdk_root_includes = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/include" }) catch unreachable; - defer b.allocator.free(sdk_root_includes); - step.addSystemIncludeDir(sdk_root_includes); - + var wayland_protocols_include = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/share/wayland-generated" }) catch unreachable; var sdk_root_libs = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/lib/x86_64-linux-gnu" }) catch unreachable; - defer b.allocator.free(sdk_root_libs); + defer { + b.allocator.free(sdk_root_includes); + b.allocator.free(wayland_protocols_include); + b.allocator.free(sdk_root_libs); + } + step.addSystemIncludeDir(sdk_root_includes); + step.addSystemIncludeDir(wayland_protocols_include); step.addLibPath(sdk_root_libs); }