@@ -39,15 +39,20 @@ pub fn build(b: *std.Build) !void {
3939 "Install the example binaries to zig-out" ,
4040 ) orelse false ;
4141
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+
4248 // Static C lib
4349 const static_lib : ? * Step.Compile = lib : {
4450 if (target .result .os .tag == .wasi ) break :lib null ;
4551
46- const static_lib = b .addStaticLibrary (.{
52+ const static_lib = b .addLibrary (.{
53+ .linkage = .static ,
4754 .name = "xev" ,
48- .root_source_file = b .path ("src/c_api.zig" ),
49- .target = target ,
50- .optimize = optimize ,
55+ .root_module = c_api_module ,
5156 });
5257 static_lib .linkLibC ();
5358 if (target .result .os .tag == .windows ) {
@@ -62,11 +67,10 @@ pub fn build(b: *std.Build) !void {
6267 // We require native so we can link to libxml2
6368 if (! target .query .isNative ()) break :lib null ;
6469
65- const dynamic_lib = b .addSharedLibrary (.{
70+ const dynamic_lib = b .addLibrary (.{
71+ .linkage = .dynamic ,
6672 .name = "xev" ,
67- .root_source_file = b .path ("src/c_api.zig" ),
68- .target = target ,
69- .optimize = optimize ,
73+ .root_module = c_api_module ,
7074 });
7175 break :lib dynamic_lib ;
7276 };
@@ -115,10 +119,12 @@ pub fn build(b: *std.Build) !void {
115119 );
116120 const test_exe = b .addTest (.{
117121 .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+ }),
122128 });
123129 switch (target .result .os .tag ) {
124130 .linux , .macos = > test_exe .linkLibC (),
@@ -190,12 +196,14 @@ fn buildBenchmarks(
190196 // Executable builder.
191197 const exe = b .addExecutable (.{
192198 .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+ }),
199207 });
200208 exe .root_module .addImport ("xev" , b .modules .get ("xev" ).? );
201209
@@ -239,21 +247,25 @@ fn buildExamples(
239247 const exe : * Step.Compile = if (is_zig ) exe : {
240248 const exe = b .addExecutable (.{
241249 .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+ }),
248258 });
249259 exe .root_module .addImport ("xev" , b .modules .get ("xev" ).? );
250260 break :exe exe ;
251261 } else exe : {
252262 const c_lib = c_lib_ orelse return error .UnsupportedPlatform ;
253263 const exe = b .addExecutable (.{
254264 .name = name ,
255- .target = target ,
256- .optimize = optimize ,
265+ .root_module = b .createModule (.{
266+ .target = target ,
267+ .optimize = optimize ,
268+ }),
257269 });
258270 exe .linkLibC ();
259271 exe .addIncludePath (b .path ("include" ));
0 commit comments