@@ -39,15 +39,20 @@ pub fn build(b: *std.Build) !void {
39
39
"Install the example binaries to zig-out" ,
40
40
) orelse false ;
41
41
42
+ const c_api_module = b .createModule (.{
43
+ .root_source_file = b .path ("src/c_api.zig" ),
44
+ .target = target ,
45
+ .optimize = optimize ,
46
+ });
47
+
42
48
// Static C lib
43
49
const static_lib : ? * Step.Compile = lib : {
44
50
if (target .result .os .tag == .wasi ) break :lib null ;
45
51
46
- const static_lib = b .addStaticLibrary (.{
52
+ const static_lib = b .addLibrary (.{
53
+ .linkage = .static ,
47
54
.name = "xev" ,
48
- .root_source_file = b .path ("src/c_api.zig" ),
49
- .target = target ,
50
- .optimize = optimize ,
55
+ .root_module = c_api_module ,
51
56
});
52
57
static_lib .linkLibC ();
53
58
if (target .result .os .tag == .windows ) {
@@ -62,11 +67,10 @@ pub fn build(b: *std.Build) !void {
62
67
// We require native so we can link to libxml2
63
68
if (! target .query .isNative ()) break :lib null ;
64
69
65
- const dynamic_lib = b .addSharedLibrary (.{
70
+ const dynamic_lib = b .addLibrary (.{
71
+ .linkage = .dynamic ,
66
72
.name = "xev" ,
67
- .root_source_file = b .path ("src/c_api.zig" ),
68
- .target = target ,
69
- .optimize = optimize ,
73
+ .root_module = c_api_module ,
70
74
});
71
75
break :lib dynamic_lib ;
72
76
};
@@ -115,10 +119,12 @@ pub fn build(b: *std.Build) !void {
115
119
);
116
120
const test_exe = b .addTest (.{
117
121
.name = "xev-test" ,
118
- .root_source_file = b .path ("src/main.zig" ),
119
- .target = target ,
120
- .optimize = optimize ,
121
- .filter = test_filter ,
122
+ .filters = if (test_filter ) | filter | &.{filter } else &.{},
123
+ .root_module = b .createModule (.{
124
+ .root_source_file = b .path ("src/main.zig" ),
125
+ .target = target ,
126
+ .optimize = optimize ,
127
+ }),
122
128
});
123
129
switch (target .result .os .tag ) {
124
130
.linux , .macos = > test_exe .linkLibC (),
@@ -190,12 +196,14 @@ fn buildBenchmarks(
190
196
// Executable builder.
191
197
const exe = b .addExecutable (.{
192
198
.name = name ,
193
- .root_source_file = b .path (b .fmt (
194
- "src/bench/{s}" ,
195
- .{entry .name },
196
- )),
197
- .target = target ,
198
- .optimize = .ReleaseFast , // benchmarks are always release fast
199
+ .root_module = b .createModule (.{
200
+ .root_source_file = b .path (b .fmt (
201
+ "src/bench/{s}" ,
202
+ .{entry .name },
203
+ )),
204
+ .target = target ,
205
+ .optimize = .ReleaseFast , // benchmarks are always release fast
206
+ }),
199
207
});
200
208
exe .root_module .addImport ("xev" , b .modules .get ("xev" ).? );
201
209
@@ -239,21 +247,25 @@ fn buildExamples(
239
247
const exe : * Step.Compile = if (is_zig ) exe : {
240
248
const exe = b .addExecutable (.{
241
249
.name = name ,
242
- .root_source_file = b .path (b .fmt (
243
- "examples/{s}" ,
244
- .{entry .name },
245
- )),
246
- .target = target ,
247
- .optimize = optimize ,
250
+ .root_module = b .createModule (.{
251
+ .root_source_file = b .path (b .fmt (
252
+ "examples/{s}" ,
253
+ .{entry .name },
254
+ )),
255
+ .target = target ,
256
+ .optimize = optimize ,
257
+ }),
248
258
});
249
259
exe .root_module .addImport ("xev" , b .modules .get ("xev" ).? );
250
260
break :exe exe ;
251
261
} else exe : {
252
262
const c_lib = c_lib_ orelse return error .UnsupportedPlatform ;
253
263
const exe = b .addExecutable (.{
254
264
.name = name ,
255
- .target = target ,
256
- .optimize = optimize ,
265
+ .root_module = b .createModule (.{
266
+ .target = target ,
267
+ .optimize = optimize ,
268
+ }),
257
269
});
258
270
exe .linkLibC ();
259
271
exe .addIncludePath (b .path ("include" ));
0 commit comments