{mach, gpu-dawn}: don't hardcode linux window manager to X11
This commit is contained in:
parent
8a645fa1bf
commit
a97a33334c
3 changed files with 58 additions and 60 deletions
|
|
@ -3,15 +3,7 @@ const Builder = std.build.Builder;
|
||||||
|
|
||||||
pub fn Sdk(comptime deps: anytype) type {
|
pub fn Sdk(comptime deps: anytype) type {
|
||||||
return struct {
|
return struct {
|
||||||
pub const LinuxWindowManager = enum {
|
|
||||||
X11,
|
|
||||||
Wayland,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// Defaults to X11 on Linux.
|
|
||||||
linux_window_manager: ?LinuxWindowManager = null,
|
|
||||||
|
|
||||||
/// Defaults to true on Windows
|
/// Defaults to true on Windows
|
||||||
d3d12: ?bool = null,
|
d3d12: ?bool = null,
|
||||||
|
|
||||||
|
|
@ -50,25 +42,20 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
/// Detects the default options to use for the given target.
|
/// Detects the default options to use for the given target.
|
||||||
pub fn detectDefaults(self: Options, target: std.Target) Options {
|
pub fn detectDefaults(self: Options, target: std.Target) Options {
|
||||||
const tag = target.os.tag;
|
const tag = target.os.tag;
|
||||||
const linux_desktop_like = isLinuxDesktopLike(target);
|
|
||||||
|
|
||||||
var options = self;
|
var options = self;
|
||||||
if (options.linux_window_manager == null and linux_desktop_like) options.linux_window_manager = .X11;
|
|
||||||
if (options.d3d12 == null) options.d3d12 = tag == .windows;
|
if (options.d3d12 == null) options.d3d12 = tag == .windows;
|
||||||
if (options.metal == null) options.metal = tag.isDarwin();
|
if (options.metal == null) options.metal = tag.isDarwin();
|
||||||
if (options.vulkan == null) options.vulkan = tag == .fuchsia or linux_desktop_like;
|
if (options.vulkan == null) options.vulkan = tag == .fuchsia or isLinuxDesktopLike(target);
|
||||||
|
|
||||||
// TODO(build-system): technically Dawn itself defaults desktop_gl to true on Windows.
|
// TODO(build-system): technically Dawn itself defaults desktop_gl to true on Windows.
|
||||||
if (options.desktop_gl == null) options.desktop_gl = linux_desktop_like;
|
if (options.desktop_gl == null) options.desktop_gl = isLinuxDesktopLike(target);
|
||||||
options.opengl_es = false; // TODO(build-system): OpenGL ES
|
|
||||||
// if (options.opengl_es == null) options.opengl_es = tag == .windows or tag == .emscripten or target.isAndroid() or linux_desktop_like;
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn appendFlags(self: Options, flags: *std.ArrayList([]const u8), debug_symbols: bool, is_cpp: bool) !void {
|
// TODO(build-system): OpenGL ES
|
||||||
if (debug_symbols) try flags.append("-g1") else try flags.append("-g0");
|
options.opengl_es = false;
|
||||||
if (is_cpp) try flags.append("-std=c++17");
|
// if (options.opengl_es == null) options.opengl_es = tag == .windows or tag == .emscripten or target.isAndroid() or linux_desktop_like;
|
||||||
if (self.linux_window_manager != null and self.linux_window_manager.? == .X11) try flags.append("-DDAWN_USE_X11");
|
|
||||||
|
return options;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -290,7 +277,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
step.addIncludePath(include_dir);
|
step.addIncludePath(include_dir);
|
||||||
step.addIncludePath(sdkPath("/src/dawn"));
|
step.addIncludePath(sdkPath("/src/dawn"));
|
||||||
|
|
||||||
if (options.linux_window_manager != null and options.linux_window_manager.? == .X11) {
|
if (isLinuxDesktopLike(step.target_info.target)) {
|
||||||
step.linkSystemLibraryName("X11");
|
step.linkSystemLibraryName("X11");
|
||||||
}
|
}
|
||||||
if (options.metal.?) {
|
if (options.metal.?) {
|
||||||
|
|
@ -557,6 +544,15 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
return !tag.isDarwin() and tag != .windows and tag != .fuchsia and tag != .emscripten and !target.isAndroid();
|
return !tag.isDarwin() and tag != .windows and tag != .fuchsia and tag != .emscripten and !target.isAndroid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn appendFlags(step: *std.build.LibExeObjStep, flags: *std.ArrayList([]const u8), debug_symbols: bool, is_cpp: bool) !void {
|
||||||
|
if (debug_symbols) try flags.append("-g1") else try flags.append("-g0");
|
||||||
|
if (is_cpp) try flags.append("-std=c++17");
|
||||||
|
if (isLinuxDesktopLike(step.target_info.target)) {
|
||||||
|
try flags.append("-DDAWN_USE_X11");
|
||||||
|
try flags.append("-DDAWN_USE_WAYLAND");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn buildLibMachDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Options) !*std.build.LibExeObjStep {
|
fn buildLibMachDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Options) !*std.build.LibExeObjStep {
|
||||||
const lib = if (!options.separate_libs) step else blk: {
|
const lib = if (!options.separate_libs) step else blk: {
|
||||||
const separate_lib = b.addStaticLibrary("dawn-native-mach", null);
|
const separate_lib = b.addStaticLibrary("dawn-native-mach", null);
|
||||||
|
|
@ -572,7 +568,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
try deps.glfw.link(b, lib, .{ .system_sdk = .{ .set_sysroot = false } });
|
try deps.glfw.link(b, lib, .{ .system_sdk = .{ .set_sysroot = false } });
|
||||||
|
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try options.appendFlags(&cpp_flags, options.debug, true);
|
try appendFlags(step, &cpp_flags, options.debug, true);
|
||||||
try appendDawnEnableBackendTypeFlags(&cpp_flags, options);
|
try appendDawnEnableBackendTypeFlags(&cpp_flags, options);
|
||||||
try cpp_flags.appendSlice(&.{
|
try cpp_flags.appendSlice(&.{
|
||||||
include(deps.glfw_include_dir),
|
include(deps.glfw_include_dir),
|
||||||
|
|
@ -609,7 +605,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
include("libs/dawn/out/Debug/gen/include"),
|
include("libs/dawn/out/Debug/gen/include"),
|
||||||
include("libs/dawn/out/Debug/gen/src"),
|
include("libs/dawn/out/Debug/gen/src"),
|
||||||
});
|
});
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/dawn/common/",
|
"libs/dawn/src/dawn/common/",
|
||||||
"libs/dawn/out/Debug/gen/src/dawn/common/",
|
"libs/dawn/out/Debug/gen/src/dawn/common/",
|
||||||
|
|
@ -638,7 +634,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try cpp_flags.appendSlice(flags.items);
|
try cpp_flags.appendSlice(flags.items);
|
||||||
try options.appendFlags(&cpp_flags, options.debug, true);
|
try appendFlags(step, &cpp_flags, options.debug, true);
|
||||||
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
@ -656,7 +652,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
};
|
};
|
||||||
|
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try options.appendFlags(&cpp_flags, options.debug, true);
|
try appendFlags(step, &cpp_flags, options.debug, true);
|
||||||
try cpp_flags.appendSlice(&.{
|
try cpp_flags.appendSlice(&.{
|
||||||
include("libs/dawn/src"),
|
include("libs/dawn/src"),
|
||||||
include("libs/dawn/include"),
|
include("libs/dawn/include"),
|
||||||
|
|
@ -755,7 +751,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
if (options.d3d12.?) try flags.appendSlice(dawn_d3d12_flags);
|
if (options.d3d12.?) try flags.appendSlice(dawn_d3d12_flags);
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/out/Debug/gen/src/dawn/",
|
"libs/dawn/out/Debug/gen/src/dawn/",
|
||||||
"libs/dawn/src/dawn/native/",
|
"libs/dawn/src/dawn/native/",
|
||||||
|
|
@ -774,7 +770,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// dawn_native_gen
|
// dawn_native_gen
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/out/Debug/gen/src/dawn/native/",
|
"libs/dawn/out/Debug/gen/src/dawn/native/",
|
||||||
},
|
},
|
||||||
|
|
@ -798,7 +794,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
try cpp_sources.append(abs_path);
|
try cpp_sources.append(abs_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/dawn/native/d3d12/",
|
"libs/dawn/src/dawn/native/d3d12/",
|
||||||
},
|
},
|
||||||
|
|
@ -814,7 +810,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
lib.linkFramework("IOSurface");
|
lib.linkFramework("IOSurface");
|
||||||
lib.linkFramework("QuartzCore");
|
lib.linkFramework("QuartzCore");
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.objc = true,
|
.objc = true,
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/dawn/native/metal/",
|
"libs/dawn/src/dawn/native/metal/",
|
||||||
|
|
@ -825,7 +821,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.linux_window_manager != null and options.linux_window_manager.? == .X11) {
|
if (isLinuxDesktopLike(step.target_info.target)) {
|
||||||
lib.linkSystemLibraryName("X11");
|
lib.linkSystemLibraryName("X11");
|
||||||
inline for ([_][]const u8{
|
inline for ([_][]const u8{
|
||||||
"src/dawn/native/XlibXcbFunctions.cpp",
|
"src/dawn/native/XlibXcbFunctions.cpp",
|
||||||
|
|
@ -852,7 +848,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.desktop_gl.?) {
|
if (options.desktop_gl.?) {
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/out/Debug/gen/src/dawn/native/opengl/",
|
"libs/dawn/out/Debug/gen/src/dawn/native/opengl/",
|
||||||
"libs/dawn/src/dawn/native/opengl/",
|
"libs/dawn/src/dawn/native/opengl/",
|
||||||
|
|
@ -863,7 +859,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.vulkan.?) {
|
if (options.vulkan.?) {
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/dawn/native/vulkan/",
|
"libs/dawn/src/dawn/native/vulkan/",
|
||||||
},
|
},
|
||||||
|
|
@ -980,7 +976,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try cpp_flags.appendSlice(flags.items);
|
try cpp_flags.appendSlice(flags.items);
|
||||||
try options.appendFlags(&cpp_flags, options.debug, true);
|
try appendFlags(step, &cpp_flags, options.debug, true);
|
||||||
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
@ -1022,7 +1018,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// libtint_core_all_src
|
// libtint_core_all_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint",
|
"libs/dawn/src/tint",
|
||||||
"libs/dawn/src/tint/diagnostic/",
|
"libs/dawn/src/tint/diagnostic/",
|
||||||
|
|
@ -1049,7 +1045,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// libtint_sem_src
|
// libtint_sem_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/sem/",
|
"libs/dawn/src/tint/sem/",
|
||||||
},
|
},
|
||||||
|
|
@ -1058,7 +1054,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// libtint_spv_reader_src
|
// libtint_spv_reader_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/reader/spirv/",
|
"libs/dawn/src/tint/reader/spirv/",
|
||||||
},
|
},
|
||||||
|
|
@ -1067,7 +1063,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// libtint_spv_writer_src
|
// libtint_spv_writer_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/writer/spirv/",
|
"libs/dawn/src/tint/writer/spirv/",
|
||||||
},
|
},
|
||||||
|
|
@ -1077,7 +1073,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
// TODO(build-system): make optional
|
// TODO(build-system): make optional
|
||||||
// libtint_wgsl_reader_src
|
// libtint_wgsl_reader_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/reader/wgsl/",
|
"libs/dawn/src/tint/reader/wgsl/",
|
||||||
},
|
},
|
||||||
|
|
@ -1087,7 +1083,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
// TODO(build-system): make optional
|
// TODO(build-system): make optional
|
||||||
// libtint_wgsl_writer_src
|
// libtint_wgsl_writer_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/writer/wgsl/",
|
"libs/dawn/src/tint/writer/wgsl/",
|
||||||
},
|
},
|
||||||
|
|
@ -1097,7 +1093,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
// TODO(build-system): make optional
|
// TODO(build-system): make optional
|
||||||
// libtint_msl_writer_src
|
// libtint_msl_writer_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/writer/msl/",
|
"libs/dawn/src/tint/writer/msl/",
|
||||||
},
|
},
|
||||||
|
|
@ -1107,7 +1103,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
// TODO(build-system): make optional
|
// TODO(build-system): make optional
|
||||||
// libtint_hlsl_writer_src
|
// libtint_hlsl_writer_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/writer/hlsl/",
|
"libs/dawn/src/tint/writer/hlsl/",
|
||||||
},
|
},
|
||||||
|
|
@ -1117,7 +1113,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
// TODO(build-system): make optional
|
// TODO(build-system): make optional
|
||||||
// libtint_glsl_writer_src
|
// libtint_glsl_writer_src
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/src/tint/writer/glsl/",
|
"libs/dawn/src/tint/writer/glsl/",
|
||||||
},
|
},
|
||||||
|
|
@ -1127,7 +1123,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try cpp_flags.appendSlice(flags.items);
|
try cpp_flags.appendSlice(flags.items);
|
||||||
try options.appendFlags(&cpp_flags, options.debug, true);
|
try appendFlags(step, &cpp_flags, options.debug, true);
|
||||||
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
@ -1156,7 +1152,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// spvtools
|
// spvtools
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/",
|
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/",
|
||||||
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/util/",
|
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/util/",
|
||||||
|
|
@ -1166,7 +1162,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// spvtools_val
|
// spvtools_val
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/val/",
|
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/val/",
|
||||||
},
|
},
|
||||||
|
|
@ -1175,7 +1171,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// spvtools_opt
|
// spvtools_opt
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/",
|
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/",
|
||||||
},
|
},
|
||||||
|
|
@ -1184,7 +1180,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// spvtools_link
|
// spvtools_link
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/link/",
|
"libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/link/",
|
||||||
},
|
},
|
||||||
|
|
@ -1231,7 +1227,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
});
|
});
|
||||||
|
|
||||||
// absl
|
// absl
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/third_party/abseil-cpp/absl/strings/",
|
"libs/dawn/third_party/abseil-cpp/absl/strings/",
|
||||||
"libs/dawn/third_party/abseil-cpp/absl/strings/internal/",
|
"libs/dawn/third_party/abseil-cpp/absl/strings/internal/",
|
||||||
|
|
@ -1281,7 +1277,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
include("libs/dawn/out/Debug/gen/src"),
|
include("libs/dawn/out/Debug/gen/src"),
|
||||||
});
|
});
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/dawn/out/Debug/gen/src/dawn/wire/",
|
"libs/dawn/out/Debug/gen/src/dawn/wire/",
|
||||||
"libs/dawn/out/Debug/gen/src/dawn/wire/client/",
|
"libs/dawn/out/Debug/gen/src/dawn/wire/client/",
|
||||||
|
|
@ -1365,7 +1361,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try cpp_flags.appendSlice(flags.items);
|
try cpp_flags.appendSlice(flags.items);
|
||||||
try options.appendFlags(&cpp_flags, options.debug, true);
|
try appendFlags(step, &cpp_flags, options.debug, true);
|
||||||
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
lib.addCSourceFiles(cpp_sources.items, cpp_flags.items);
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
@ -1410,7 +1406,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
"-DLLVM_ON_WIN32=1",
|
"-DLLVM_ON_WIN32=1",
|
||||||
});
|
});
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.debug_symbols = false,
|
.debug_symbols = false,
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/DirectXShaderCompiler/lib/Analysis/IPA",
|
"libs/DirectXShaderCompiler/lib/Analysis/IPA",
|
||||||
|
|
@ -1443,7 +1439,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
.flags = flags.items,
|
.flags = flags.items,
|
||||||
});
|
});
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.debug_symbols = false,
|
.debug_symbols = false,
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/DirectXShaderCompiler/lib/Support",
|
"libs/DirectXShaderCompiler/lib/Support",
|
||||||
|
|
@ -1457,7 +1453,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
try appendLangScannedSources(b, lib, options, .{
|
try appendLangScannedSources(b, lib, .{
|
||||||
.debug_symbols = false,
|
.debug_symbols = false,
|
||||||
.rel_dirs = &.{
|
.rel_dirs = &.{
|
||||||
"libs/DirectXShaderCompiler/lib/Bitcode/Reader",
|
"libs/DirectXShaderCompiler/lib/Bitcode/Reader",
|
||||||
|
|
@ -1473,7 +1469,6 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
fn appendLangScannedSources(
|
fn appendLangScannedSources(
|
||||||
b: *Builder,
|
b: *Builder,
|
||||||
step: *std.build.LibExeObjStep,
|
step: *std.build.LibExeObjStep,
|
||||||
options: Options,
|
|
||||||
args: struct {
|
args: struct {
|
||||||
debug_symbols: bool = false,
|
debug_symbols: bool = false,
|
||||||
flags: []const []const u8,
|
flags: []const []const u8,
|
||||||
|
|
@ -1485,7 +1480,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
) !void {
|
) !void {
|
||||||
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
var cpp_flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try cpp_flags.appendSlice(args.flags);
|
try cpp_flags.appendSlice(args.flags);
|
||||||
try options.appendFlags(&cpp_flags, args.debug_symbols, true);
|
try appendFlags(step, &cpp_flags, args.debug_symbols, true);
|
||||||
const cpp_extensions: []const []const u8 = if (args.objc) &.{".mm"} else &.{ ".cpp", ".cc" };
|
const cpp_extensions: []const []const u8 = if (args.objc) &.{".mm"} else &.{ ".cpp", ".cc" };
|
||||||
try appendScannedSources(b, step, .{
|
try appendScannedSources(b, step, .{
|
||||||
.flags = cpp_flags.items,
|
.flags = cpp_flags.items,
|
||||||
|
|
@ -1497,7 +1492,7 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
try flags.appendSlice(args.flags);
|
try flags.appendSlice(args.flags);
|
||||||
try options.appendFlags(&flags, args.debug_symbols, false);
|
try appendFlags(step, &flags, args.debug_symbols, false);
|
||||||
const c_extensions: []const []const u8 = if (args.objc) &.{".m"} else &.{".c"};
|
const c_extensions: []const []const u8 = if (args.objc) &.{".m"} else &.{".c"};
|
||||||
try appendScannedSources(b, step, .{
|
try appendScannedSources(b, step, .{
|
||||||
.flags = flags.items,
|
.flags = flags.items,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ pub fn detectGLFWOptions() glfw.BackendOptions {
|
||||||
if (target.isDarwin()) return .{ .cocoa = true };
|
if (target.isDarwin()) return .{ .cocoa = true };
|
||||||
return switch (target.os.tag) {
|
return switch (target.os.tag) {
|
||||||
.windows => .{ .win32 = true },
|
.windows => .{ .win32 = true },
|
||||||
.linux => .{ .x11 = true },
|
.linux => .{ .x11 = true, .wayland = true },
|
||||||
else => .{},
|
else => .{},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ pub fn detectGLFWOptions() glfw.BackendOptions {
|
||||||
if (target.isDarwin()) return .{ .cocoa = true };
|
if (target.isDarwin()) return .{ .cocoa = true };
|
||||||
return switch (target.os.tag) {
|
return switch (target.os.tag) {
|
||||||
.windows => .{ .win32 = true },
|
.windows => .{ .win32 = true },
|
||||||
.linux => .{ .x11 = true },
|
.linux => .{ .x11 = true, .wayland = true },
|
||||||
else => .{},
|
else => .{},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +111,11 @@ pub fn createSurfaceForWindow(
|
||||||
.display = glfw_native.getX11Display(),
|
.display = glfw_native.getX11Display(),
|
||||||
.window = glfw_native.getX11Window(window),
|
.window = glfw_native.getX11Window(window),
|
||||||
},
|
},
|
||||||
|
} else if (glfw_options.wayland) gpu.Surface.Descriptor.NextInChain{
|
||||||
|
.from_wayland_surface = &.{
|
||||||
|
.display = glfw_native.getWaylandDisplay(),
|
||||||
|
.surface = glfw_native.getWaylandWindow(window),
|
||||||
|
},
|
||||||
} else if (glfw_options.cocoa) blk: {
|
} else if (glfw_options.cocoa) blk: {
|
||||||
const ns_window = glfw_native.getCocoaWindow(window);
|
const ns_window = glfw_native.getCocoaWindow(window);
|
||||||
const ns_view = msgSend(ns_window, "contentView", .{}, *anyopaque); // [nsWindow contentView]
|
const ns_view = msgSend(ns_window, "contentView", .{}, *anyopaque); // [nsWindow contentView]
|
||||||
|
|
@ -126,8 +131,6 @@ pub fn createSurfaceForWindow(
|
||||||
msgSend(layer.?, "setContentsScale:", .{scale_factor}, void); // [layer setContentsScale:scale_factor]
|
msgSend(layer.?, "setContentsScale:", .{scale_factor}, void); // [layer setContentsScale:scale_factor]
|
||||||
|
|
||||||
break :blk gpu.Surface.Descriptor.NextInChain{ .from_metal_layer = &.{ .layer = layer.? } };
|
break :blk gpu.Surface.Descriptor.NextInChain{ .from_metal_layer = &.{ .layer = layer.? } };
|
||||||
} else if (glfw_options.wayland) {
|
|
||||||
@panic("TODO: this example does not support Wayland");
|
|
||||||
} else unreachable;
|
} else unreachable;
|
||||||
|
|
||||||
return instance.createSurface(&gpu.Surface.Descriptor{
|
return instance.createSurface(&gpu.Surface.Descriptor{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue