@@ -2,33 +2,12 @@ const std = @import("std");
2
2
const LibExeObjStep = std .build .LibExeObjStep ;
3
3
const ScdocStep = @import ("src/build/ScdocStep.zig" );
4
4
5
- /// DEPRECATED: This is the old std.build.Pkg for older versions of Zig.
6
- /// I won't keep this around too long but there is no harm in exposing it
7
- /// for now since our code works with older versions just fine (for now).
8
- pub const pkg = std.build.Pkg {
9
- .name = "xev" ,
10
- .source = .{ .path = thisDir () ++ "/src/main.zig" },
11
- };
12
-
13
- /// Returns the module for libxev. The recommended approach is to depend
14
- /// on libxev in your build.zig.zon file, then use
15
- /// `b.dependency("libxev").module("xev")`. But if you're not using
16
- /// a build.zig.zon yet this will work.
17
- pub fn module (b : * std.Build ) * std.Build.Module {
18
- return b .createModule (.{
19
- .source_file = .{ .path = (comptime thisDir ()) ++ "/src/main.zig" },
20
- });
21
- }
22
-
23
5
pub fn build (b : * std.Build ) ! void {
24
- // Modules available to downstream dependencies
25
- _ = b .addModule ("xev" , .{
26
- .source_file = .{ .path = (comptime thisDir ()) ++ "/src/main.zig" },
27
- });
28
-
29
6
const target = b .standardTargetOptions (.{});
30
7
const optimize = b .standardOptimizeOption (.{});
31
8
9
+ _ = b .addModule ("xev" , .{ .source_file = .{ .path = "src/main.zig" } });
10
+
32
11
const man_pages = b .option (
33
12
bool ,
34
13
"man-pages" ,
@@ -111,8 +90,11 @@ pub fn build(b: *std.Build) !void {
111
90
.optimize = optimize ,
112
91
});
113
92
static_binding_test .linkLibC ();
114
- static_binding_test .addIncludePath ("include" );
115
- static_binding_test .addCSourceFile ("examples/_basic.c" , &[_ ][]const u8 { "-Wall" , "-Wextra" , "-pedantic" , "-std=c99" , "-D_POSIX_C_SOURCE=199309L" });
93
+ static_binding_test .addIncludePath (.{ .path = "include" });
94
+ static_binding_test .addCSourceFile (.{
95
+ .file = .{ .path = "examples/_basic.c" },
96
+ .flags = &[_ ][]const u8 { "-Wall" , "-Wextra" , "-pedantic" , "-std=c99" , "-D_POSIX_C_SOURCE=199309L" },
97
+ });
116
98
static_binding_test .linkLibrary (static_lib );
117
99
if (test_install ) b .installArtifact (static_binding_test );
118
100
@@ -145,8 +127,11 @@ pub fn build(b: *std.Build) !void {
145
127
.optimize = optimize ,
146
128
});
147
129
dynamic_binding_test .linkLibC ();
148
- dynamic_binding_test .addIncludePath ("include" );
149
- dynamic_binding_test .addCSourceFile ("examples/_basic.c" , &[_ ][]const u8 { "-Wall" , "-Wextra" , "-pedantic" , "-std=c99" });
130
+ dynamic_binding_test .addIncludePath (.{ .path = "include" });
131
+ dynamic_binding_test .addCSourceFile (.{
132
+ .file = .{ .path = "examples/_basic.c" },
133
+ .flags = &[_ ][]const u8 { "-Wall" , "-Wextra" , "-pedantic" , "-std=c99" },
134
+ });
150
135
dynamic_binding_test .linkLibrary (dynamic_lib );
151
136
if (test_install ) b .installArtifact (dynamic_binding_test );
152
137
@@ -239,9 +224,13 @@ fn benchTargets(
239
224
.target = target ,
240
225
.optimize = .ReleaseFast , // benchmarks are always release fast
241
226
});
242
- c_exe .addModule ("xev" , module (b ));
243
- c_exe .override_dest_dir = std.Build.InstallDir { .custom = "bench" };
244
- if (install ) b .installArtifact (c_exe );
227
+ c_exe .addModule ("xev" , b .modules .get ("xev" ).? );
228
+ if (install ) {
229
+ const install_step = b .addInstallArtifact (c_exe , .{
230
+ .dest_dir = .{ .override = .{ .custom = "bench" } },
231
+ });
232
+ b .getInstallStep ().dependOn (& install_step .step );
233
+ }
245
234
246
235
// Store the mapping
247
236
try map .put (try b .allocator .dupe (u8 , name ), c_exe );
@@ -293,9 +282,13 @@ fn exampleTargets(
293
282
.target = target ,
294
283
.optimize = optimize ,
295
284
});
296
- c_exe .addModule ("xev" , module (b ));
297
- c_exe .override_dest_dir = std.Build.InstallDir { .custom = "example" };
298
- if (install ) b .installArtifact (c_exe );
285
+ c_exe .addModule ("xev" , b .modules .get ("xev" ).? );
286
+ if (install ) {
287
+ const install_step = b .addInstallArtifact (c_exe , .{
288
+ .dest_dir = .{ .override = .{ .custom = "example" } },
289
+ });
290
+ b .getInstallStep ().dependOn (& install_step .step );
291
+ }
299
292
} else {
300
293
const c_lib = c_lib_ orelse return error .UnsupportedPlatform ;
301
294
const c_exe = b .addExecutable (.{
@@ -304,17 +297,24 @@ fn exampleTargets(
304
297
.optimize = optimize ,
305
298
});
306
299
c_exe .linkLibC ();
307
- c_exe .addIncludePath ("include" );
308
- c_exe .addCSourceFile (path , &[_ ][]const u8 {
309
- "-Wall" ,
310
- "-Wextra" ,
311
- "-pedantic" ,
312
- "-std=c99" ,
313
- "-D_POSIX_C_SOURCE=199309L" ,
300
+ c_exe .addIncludePath (.{ .path = "include" });
301
+ c_exe .addCSourceFile (.{
302
+ .file = .{ .path = path },
303
+ .flags = &[_ ][]const u8 {
304
+ "-Wall" ,
305
+ "-Wextra" ,
306
+ "-pedantic" ,
307
+ "-std=c99" ,
308
+ "-D_POSIX_C_SOURCE=199309L" ,
309
+ },
314
310
});
315
311
c_exe .linkLibrary (c_lib );
316
- c_exe .override_dest_dir = std.Build.InstallDir { .custom = "example" };
317
- if (install ) b .installArtifact (c_exe );
312
+ if (install ) {
313
+ const install_step = b .addInstallArtifact (c_exe , .{
314
+ .dest_dir = .{ .override = .{ .custom = "example" } },
315
+ });
316
+ b .getInstallStep ().dependOn (& install_step .step );
317
+ }
318
318
}
319
319
320
320
// If we have specified a specific name, only install that one.
0 commit comments