diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-12 13:54:03 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-12 13:54:03 +0200 |
| commit | f254217d2c8d024137ba5749d5f40ea7af841172 (patch) | |
| tree | 7a4d2a345a03dd91ecce24e1bc772de809b2eb78 /build.zig | |
| parent | 57a811583ce9ad4df0b1a55c9d4472873630a3d8 (diff) | |
| download | river-f254217d2c8d024137ba5749d5f40ea7af841172.tar.gz river-f254217d2c8d024137ba5749d5f40ea7af841172.tar.xz | |
Eliminate some code duplication
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 36 |
1 files changed, 14 insertions, 22 deletions
@@ -16,18 +16,7 @@ pub fn build(b: *std.build.Builder) !void { const exe = b.addExecutable("river", "src/main.zig"); exe.setTarget(target); exe.setBuildMode(mode); - - exe.step.dependOn(&scan_protocols.step); - exe.addIncludeDir("protocol"); - - exe.addCSourceFile("include/render.c", &[_][]const u8{"-std=c99"}); - exe.addIncludeDir("."); - - exe.linkLibC(); - exe.linkSystemLibrary("wayland-server"); - exe.linkSystemLibrary("wlroots"); - exe.linkSystemLibrary("xkbcommon"); - + addDeps(exe, &scan_protocols.step); exe.install(); const run_cmd = exe.run(); @@ -39,20 +28,23 @@ pub fn build(b: *std.build.Builder) !void { const test_exe = b.addTest("src/test_main.zig"); test_exe.setTarget(target); test_exe.setBuildMode(mode); + addDeps(test_exe, &scan_protocols.step); - test_exe.step.dependOn(&scan_protocols.step); - test_exe.addIncludeDir("protocol"); + const test_step = b.step("test", "Run the tests"); + test_step.dependOn(&test_exe.step); +} - test_exe.addCSourceFile("include/render.c", &[_][]const u8{"-std=c99"}); - test_exe.addIncludeDir("."); +fn addDeps(exe: *std.build.LibExeObjStep, protocol_step: *std.build.Step) void { + exe.step.dependOn(protocol_step); + exe.addIncludeDir("protocol"); - test_exe.linkLibC(); - test_exe.linkSystemLibrary("wayland-server"); - test_exe.linkSystemLibrary("wlroots"); - test_exe.linkSystemLibrary("xkbcommon"); + exe.addCSourceFile("include/render.c", &[_][]const u8{"-std=c99"}); + exe.addIncludeDir("."); - const test_step = b.step("test", "Run the tests"); - test_step.dependOn(&test_exe.step); + exe.linkLibC(); + exe.linkSystemLibrary("wayland-server"); + exe.linkSystemLibrary("wlroots"); + exe.linkSystemLibrary("xkbcommon"); } const ScanProtocolsStep = struct { |
