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 <stephen@hexops.com>
This commit is contained in:
Ali Chraghi 2021-12-24 11:36:51 +03:30 committed by GitHub
parent ad8e1a4292
commit 38cab2e423
Failed to generate hash of commit
4 changed files with 21 additions and 8 deletions

View file

@ -3,4 +3,5 @@
// General Linux-like sources
#include "posix_time.c"
#include "posix_thread.c"
#include "linux_joystick.c"
#include "linux_joystick.c"
#include "xkb_unicode.c"

View file

@ -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"

View file

@ -2,5 +2,4 @@
#include "x11_init.c"
#include "x11_window.c"
#include "x11_monitor.c"
#include "xkb_unicode.c"
#include "glx_context.c"

View file

@ -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);
}