-
Notifications
You must be signed in to change notification settings - Fork 32
/
build.zig
85 lines (63 loc) · 3.41 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
const std = @import("std");
pub fn build(b: *std.Build) void {
_ = b.addModule("wlroots", .{
.root_source_file = b.path("src/wlroots.zig"),
});
const enable_tests = b.option(bool, "enable-tests", "allow running tests") orelse false;
// Hack to allow making all dependencies required for tests lazy.
if (!enable_tests) return;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const Scanner = (b.lazyImport(@This(), "zig-wayland") orelse return).Scanner;
const scanner = Scanner.create(b, .{});
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
scanner.addSystemProtocol("unstable/pointer-constraints/pointer-constraints-unstable-v1.xml");
scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml");
scanner.addSystemProtocol("unstable/xdg-decoration/xdg-decoration-unstable-v1.xml");
scanner.addSystemProtocol("unstable/tablet/tablet-unstable-v2.xml");
scanner.addSystemProtocol("staging/ext-session-lock/ext-session-lock-v1.xml");
scanner.addSystemProtocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml");
scanner.addSystemProtocol("staging/cursor-shape/cursor-shape-v1.xml");
scanner.addSystemProtocol("staging/tearing-control/tearing-control-v1.xml");
scanner.addCustomProtocol("protocol/wlr-layer-shell-unstable-v1.xml");
scanner.addCustomProtocol("protocol/wlr-output-power-management-unstable-v1.xml");
// These must be manually kept in sync with the versions wlroots supports
// until wlroots gives the option to request a specific version.
scanner.generate("wl_compositor", 4);
scanner.generate("wl_subcompositor", 1);
scanner.generate("wl_shm", 1);
scanner.generate("wl_output", 4);
scanner.generate("wl_seat", 7);
scanner.generate("wl_data_device_manager", 3);
scanner.generate("xdg_wm_base", 2);
scanner.generate("ext_session_lock_manager_v1", 1);
scanner.generate("zwp_pointer_gestures_v1", 3);
scanner.generate("zwp_pointer_constraints_v1", 1);
scanner.generate("zxdg_decoration_manager_v1", 1);
scanner.generate("zwp_tablet_manager_v2", 1);
scanner.generate("zwp_linux_dmabuf_v1", 4);
scanner.generate("wp_cursor_shape_manager_v1", 1);
scanner.generate("wp_tearing_control_manager_v1", 1);
scanner.generate("zwlr_layer_shell_v1", 4);
scanner.generate("zwlr_output_power_manager_v1", 1);
const wayland = b.createModule(.{ .root_source_file = scanner.result });
const xkbcommon = (b.lazyDependency("zig-xkbcommon", .{}) orelse return).module("xkbcommon");
const pixman = (b.lazyDependency("zig-pixman", .{}) orelse return).module("pixman");
const wlr_test = b.addTest(.{
.root_source_file = b.path("src/wlroots.zig"),
.target = target,
.optimize = optimize,
});
wlr_test.linkLibC();
wlr_test.root_module.addImport("wayland", wayland);
wlr_test.linkSystemLibrary("wayland-server");
// TODO: remove when https://github.com/ziglang/zig/issues/131 is implemented
scanner.addCSource(wlr_test);
wlr_test.root_module.addImport("xkbcommon", xkbcommon);
wlr_test.linkSystemLibrary("xkbcommon");
wlr_test.root_module.addImport("pixman", pixman);
wlr_test.linkSystemLibrary("pixman-1");
wlr_test.linkSystemLibrary("wlroots-0.18");
const test_step = b.step("test", "Run the tests");
test_step.dependOn(&wlr_test.step);
}