gamemode: use zig build

This commit is contained in:
Ali Chraghi 2022-09-18 21:31:01 +04:30 committed by Stephen Gutekanst
parent 15dfb2867a
commit 2ab3516795
6 changed files with 23 additions and 1650 deletions

View file

@ -9,6 +9,7 @@ const ecs = @import("libs/ecs/build.zig");
const freetype = @import("libs/freetype/build.zig"); const freetype = @import("libs/freetype/build.zig");
const basisu = @import("libs/basisu/build.zig"); const basisu = @import("libs/basisu/build.zig");
const sysjs = @import("libs/sysjs/build.zig"); const sysjs = @import("libs/sysjs/build.zig");
const gamemode = @import("libs/gamemode/build.zig");
const Pkg = std.build.Pkg; const Pkg = std.build.Pkg;
const gpu_dawn = gpu_dawn_sdk.Sdk(.{ const gpu_dawn = gpu_dawn_sdk.Sdk(.{
@ -167,12 +168,11 @@ pub fn build(b: *std.build.Builder) void {
lib.addPackage(gpu.pkg); lib.addPackage(gpu.pkg);
lib.addPackage(glfw.pkg); lib.addPackage(glfw.pkg);
lib.addPackage(sysaudio.pkg); lib.addPackage(sysaudio.pkg);
if (target.toTarget().os.tag == .linux) { if (target.toTarget().os.tag == .linux)
// TODO: add gamemode.pkg instead of using addPackagePath lib.addPackage(gamemode.pkg);
lib.addPackagePath("gamemode", (comptime thisDir()) ++ "/libs/gamemode/gamemode.zig");
}
glfw.link(b, lib, options.glfw_options); glfw.link(b, lib, options.glfw_options);
gpu.link(b, lib, options.gpuOptions()); gpu.link(b, lib, options.gpuOptions());
gamemode.link(lib);
lib.setOutputDir("./libmach/build"); lib.setOutputDir("./libmach/build");
lib.install(); lib.install();
} }
@ -282,10 +282,8 @@ pub const App = struct {
exe.addPackage(sysaudio.pkg); exe.addPackage(sysaudio.pkg);
exe.addPackage(glfw.pkg); exe.addPackage(glfw.pkg);
if (target.os.tag == .linux) { if (target.os.tag == .linux)
// TODO: add gamemode.pkg instead of using addPackagePath exe.addPackage(gamemode.pkg);
exe.addPackagePath("gamemode", (comptime thisDir()) ++ "/libs/gamemode/gamemode.zig");
}
break :blk exe; break :blk exe;
} }
@ -355,6 +353,8 @@ pub const App = struct {
if (app.platform != .web) { if (app.platform != .web) {
glfw.link(app.b, app.step, options.glfw_options); glfw.link(app.b, app.step, options.glfw_options);
gpu.link(app.b, app.step, options.gpuOptions()); gpu.link(app.b, app.step, options.gpuOptions());
if (app.step.target.isLinux())
gamemode.link(app.step);
} }
sysaudio.link(app.b, app.step, options.sysaudio_options); sysaudio.link(app.b, app.step, options.sysaudio_options);
} }

14
libs/gamemode/build.zig Normal file
View file

@ -0,0 +1,14 @@
const std = @import("std");
pub const pkg = std.build.Pkg{
.name = "gamemode",
.source = .{ .path = thisDir() ++ "/gamemode.zig" },
};
pub fn link(step: *std.build.LibExeObjStep) void {
step.addIncludeDir(comptime thisDir() ++ "/upstream/include");
}
fn thisDir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}

View file

@ -1,7 +1,7 @@
//! Note: All the above requests can be blocking - dbus requests can and will block while the daemon //! Note: All the above requests can be blocking - dbus requests can and will block while the daemon
//! handles the request. It is not recommended to make these calls in performance critical code //! handles the request. It is not recommended to make these calls in performance critical code
const builtin = @import("builtin"); const builtin = @import("builtin");
pub const c = @import("gamemode_client.zig"); pub const c = @cImport(@cInclude("gamemode_client.h"));
pub const GamemodeError = error{ pub const GamemodeError = error{
RequestFailed, RequestFailed,

File diff suppressed because it is too large Load diff