-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
86 lines (68 loc) · 2.61 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const std = @import("std");
// don't use raylib library in system package, since it is meant to be used for DESKTOP, not DRM
const raySdk = @import("lib/raylib/src/build.zig");
fn addDependencyModules(
comp: *std.Build.Step.Compile,
b: *std.Build,
dep_name: []const u8,
modules: []const []const u8,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
) !void {
const dep = b.dependency(dep_name, .{ .target = target, .optimize = optimize });
for (modules) |module_name| {
const module = dep.module(module_name);
comp.root_module.addImport(module_name, module);
}
}
fn addDependencies(
comp: *std.Build.Step.Compile,
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
raylib: *std.Build.Step.Compile
) !void {
// raylib
comp.addIncludePath(.{ .path = "lib/raylib/src" });
comp.linkLibrary(raylib);
try addDependencyModules(comp, b, "cova", &.{"cova"}, target, optimize);
try addDependencyModules(comp, b, "greetd_ipc", &.{"greetd_ipc"}, target, optimize);
}
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "raygreet",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
if (exe.root_module.optimize != .Debug) {
exe.root_module.strip = true;
}
b.installArtifact(exe);
// dependencies ========================================
// raylib: ff1eeafb950b5d7b8e5b25aa2ac1e8e87e353d1b
const raylib = try raySdk.addRaylib(b, target, optimize, .{
.platform_drm = b.option(bool, "platform_drm", "Compile raylib in DRM mode") orelse false,
});
try addDependencies(exe, b, target, optimize, raylib);
// run command ========================================
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// test command ========================================
const exe_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
try addDependencies(exe_unit_tests, b, target, optimize, raylib);
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);
}