-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.zig
66 lines (55 loc) · 2.11 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
const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
var config_data: ?[]const u8 = null;
// setup config options
{
const config_path = b.option(
[]const u8,
"config_path",
"Path to configuration file. If none supplied, uses the configuration defined in `config.zig`",
);
if (config_path) |path| {
const file = if (std.fs.path.isAbsolute(path))
std.fs.openFileAbsolute(path, .{}) catch unreachable
else
std.fs.cwd().openFile(path, .{}) catch unreachable;
defer file.close();
config_data = file.readToEndAlloc(b.allocator, std.math.maxInt(u64)) catch unreachable;
}
}
const exe = b.addExecutable("juicebox", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
exe.addPackage(.{ .name = "x11", .path = .{ .path = "src/x11/x11.zig" } });
exe.addBuildOption(?[]const u8, "config_data", config_data);
exe.install();
// Running the binary
{
const run_cmd = exe.run();
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);
}
// Xephyr building steps
{
const size = b.option([]const u8, "size", "Sets the Xephyr window size") orelse "800x600";
const xinit = b.addSystemCommand(&[_][]const u8{
"xinit", "./xinitrc", "--",
"/usr/bin/Xephyr", ":2", "-ac",
"-screen", size, "-host-cursor",
"-reset", "-terminate",
});
const xephyr_step = b.step(
"xephyr",
"Runs the window manager inside Xephyr. Useful for testing without obstructing your current window manager",
);
xephyr_step.dependOn(b.getInstallStep());
xephyr_step.dependOn(&xinit.step);
}
}