-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
176 lines (154 loc) · 6.74 KB
/
Copy pathbuild.zig
File metadata and controls
176 lines (154 loc) · 6.74 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
const std = @import("std");
const Build = std.Build;
pub fn build(b: *Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const janet = b.dependency("janet", .{ .linkage = .dynamic });
const janet_static = b.dependency("janet", .{
.target = target,
.optimize = optimize,
.linkage = .static,
});
const spork = b.dependency("spork", .{});
const rawterm = b.addLibrary(.{
.name = "rawterm",
.root_module = b.createModule(.{
.target = b.graph.host,
.link_libc = true,
}),
.linkage = .dynamic,
});
rawterm.root_module.addCSourceFile(.{ .file = spork.path("src/rawterm.c") });
rawterm.root_module.linkLibrary(janet.artifact("janet"));
const rawterm_static = b.addLibrary(.{
.name = "rawterm",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
.linkage = .static,
});
rawterm_static.root_module.addCSourceFile(.{
.file = spork.path("src/rawterm.c"),
.flags = &.{"-DJANET_ENTRY_NAME=janet_module_entry_rawterm"},
});
rawterm_static.root_module.linkLibrary(janet_static.artifact("janet"));
const lemongrass = b.dependency("lemongrass", .{});
const janet_wayland = b.dependency("janet_wayland", .{});
const wayland = b.dependency("wayland", .{ .linkage = .dynamic });
const wayland_native = b.addLibrary(.{
.name = "wayland-native",
.root_module = b.createModule(.{
.target = b.graph.host,
.link_libc = true,
}),
.linkage = .dynamic,
});
wayland_native.root_module.addCSourceFile(.{ .file = janet_wayland.path("src/wayland-native.c") });
wayland_native.root_module.linkLibrary(janet.artifact("janet"));
wayland_native.root_module.linkLibrary(wayland.artifact("wayland-client"));
const wayland_static = b.dependency("wayland", .{
.target = target,
.optimize = optimize,
.linkage = .static,
});
const wayland_native_static = b.addLibrary(.{
.name = "wayland-native",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
.linkage = .static,
});
wayland_native_static.root_module.addCSourceFile(.{
.file = janet_wayland.path("src/wayland-native.c"),
.flags = &.{"-DJANET_ENTRY_NAME=janet_module_entry_wayland_native"},
});
wayland_native_static.root_module.linkLibrary(janet_static.artifact("janet"));
wayland_native_static.root_module.linkLibrary(wayland_static.artifact("wayland-client"));
const janet_xkbcommon = b.dependency("janet_xkbcommon", .{});
const xkbcommon = b.dependency("libxkbcommon", .{ .linkage = .dynamic });
const xkbcommon_native = b.addLibrary(.{
.name = "xkbcommon-native",
.root_module = b.createModule(.{
.target = b.graph.host,
.link_libc = true,
}),
.linkage = .dynamic,
});
xkbcommon_native.root_module.addCSourceFile(.{ .file = janet_xkbcommon.path("src/xkbcommon-native.c") });
xkbcommon_native.root_module.linkLibrary(janet.artifact("janet"));
xkbcommon_native.root_module.linkLibrary(xkbcommon.artifact("xkbcommon"));
const xkbcommon_static = b.dependency("libxkbcommon", .{
.target = target,
.optimize = optimize,
.linkage = .static,
});
const xkbcommon_native_static = b.addLibrary(.{
.name = "xkbcommon-native",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
.linkage = .static,
});
xkbcommon_native_static.root_module.addCSourceFile(.{
.file = janet_xkbcommon.path("src/xkbcommon-native.c"),
.flags = &.{"-DJANET_ENTRY_NAME=janet_module_entry_xkbcommon_native"},
});
xkbcommon_native_static.root_module.linkLibrary(janet_static.artifact("janet"));
xkbcommon_native_static.root_module.linkLibrary(xkbcommon_static.artifact("xkbcommon"));
const gen_protocols = b.addRunArtifact(janet.artifact("janet-bin"));
gen_protocols.addFileArg(b.path("build/gen-protocols.janet"));
const protocols_image = gen_protocols.addOutputFileArg("protocols.jimage");
gen_protocols.addFileArg(wayland.namedLazyPath("wayland-xml"));
const wayland_protocols = b.dependency("wayland_protocols", .{});
gen_protocols.addDirectoryArg(wayland_protocols.path("."));
const river = b.dependency("river", .{});
gen_protocols.addDirectoryArg(river.path("protocol"));
const gen_c = b.addRunArtifact(janet.artifact("janet-bin"));
// This is necessary to re-run every build to ensure changes to
// janet files in src other than ashrwm.janet are picked up.
// TODO better integrate into the zig build cache.
gen_c.has_side_effects = true;
gen_c.addFileArg(b.path("build/gen-c-source.janet"));
gen_c.addFileArg(b.path("ashrwm.janet"));
_ = gen_c.addOutputFileArg("image.jimage");
const generated = gen_c.addOutputFileArg("main.c");
gen_c.addArgs(&.{ "--image", "protocols" });
gen_c.addFileArg(protocols_image);
gen_c.addArgs(&.{ "--source", "wayland" });
gen_c.addFileArg(janet_wayland.path("src/wayland.janet"));
gen_c.addArgs(&.{ "--native", "wayland-native", "janet_module_entry_wayland_native" });
gen_c.addArtifactArg(wayland_native);
gen_c.addArgs(&.{ "--source", "lemongrass" });
gen_c.addFileArg(lemongrass.path("init.janet"));
gen_c.addArgs(&.{ "--source", "spork/sh" });
gen_c.addFileArg(spork.path("spork/sh.janet"));
gen_c.addArgs(&.{ "--source", "spork/netrepl" });
gen_c.addFileArg(spork.path("spork/netrepl.janet"));
gen_c.addArgs(&.{ "--native", "spork/rawterm", "janet_module_entry_rawterm" });
gen_c.addArtifactArg(rawterm);
gen_c.addArgs(&.{ "--source", "xkbcommon" });
gen_c.addFileArg(janet_xkbcommon.path("src/xkbcommon.janet"));
gen_c.addArgs(&.{ "--native", "xkbcommon-native", "janet_module_entry_xkbcommon_native" });
gen_c.addArtifactArg(xkbcommon_native);
b.getInstallStep().dependOn(&gen_c.step);
const ashrwm = b.addExecutable(.{
.name = "ashrwm",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
ashrwm.root_module.addCSourceFile(.{ .file = generated });
ashrwm.root_module.linkLibrary(janet_static.artifact("janet"));
ashrwm.root_module.linkLibrary(wayland_native_static);
ashrwm.root_module.linkLibrary(rawterm_static);
ashrwm.root_module.linkLibrary(xkbcommon_native_static);
b.installArtifact(ashrwm);
}