From 7cb6c5d75a067539065089c51a603cd1de705e12 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 19 May 2020 13:43:41 +0200 Subject: Add riverctl binary to build.zig --- build.zig | 35 ++++++++++++++++++++--------------- src/main.zig | 42 ------------------------------------------ src/river.zig | 42 ++++++++++++++++++++++++++++++++++++++++++ src/riverctl.zig | 26 ++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 57 deletions(-) delete mode 100644 src/main.zig create mode 100644 src/river.zig create mode 100644 src/riverctl.zig diff --git a/build.zig b/build.zig index d57a142..2e66934 100644 --- a/build.zig +++ b/build.zig @@ -19,30 +19,35 @@ pub fn build(b: *std.build.Builder) !void { const scan_protocols = ScanProtocolsStep.create(b); - const exe = b.addExecutable("river", "src/main.zig"); - exe.setTarget(target); - exe.setBuildMode(mode); - exe.addBuildOption(bool, "xwayland", xwayland); - addDeps(exe, &scan_protocols.step); - exe.install(); - - const run_cmd = exe.run(); + const river = b.addExecutable("river", "src/river.zig"); + river.setTarget(target); + river.setBuildMode(mode); + river.addBuildOption(bool, "xwayland", xwayland); + addServerDeps(river, &scan_protocols.step); + river.install(); + + const run_cmd = river.run(); run_cmd.step.dependOn(b.getInstallStep()); const run_step = b.step("run", "Run the compositor"); run_step.dependOn(&run_cmd.step); - const test_exe = b.addTest("src/test_main.zig"); - test_exe.setTarget(target); - test_exe.setBuildMode(mode); - test_exe.addBuildOption(bool, "xwayland", xwayland); - addDeps(test_exe, &scan_protocols.step); + const riverctl = b.addExecutable("riverctl", "src/riverctl.zig"); + riverctl.setTarget(target); + riverctl.setBuildMode(mode); + riverctl.install(); + + const river_test = b.addTest("src/test_main.zig"); + river_test.setTarget(target); + river_test.setBuildMode(mode); + river_test.addBuildOption(bool, "xwayland", xwayland); + addServerDeps(river_test, &scan_protocols.step); const test_step = b.step("test", "Run the tests"); - test_step.dependOn(&test_exe.step); + test_step.dependOn(&river_test.step); } -fn addDeps(exe: *std.build.LibExeObjStep, protocol_step: *std.build.Step) void { +fn addServerDeps(exe: *std.build.LibExeObjStep, protocol_step: *std.build.Step) void { exe.step.dependOn(protocol_step); exe.addIncludeDir("protocol"); exe.addCSourceFile("protocol/river-window-management-unstable-v1-protocol.c", &[_][]const u8{"-std=c99"}); diff --git a/src/main.zig b/src/main.zig deleted file mode 100644 index a5f5334..0000000 --- a/src/main.zig +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of river, a dynamic tiling wayland compositor. -// -// Copyright 2020 Isaac Freund -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -const std = @import("std"); - -const c = @import("c.zig"); - -const Log = @import("log.zig").Log; -const Server = @import("Server.zig"); - -pub fn main() !void { - Log.init(Log.Debug); - c.wlr_log_init(.WLR_ERROR, null); - - Log.Info.log("Initializing server", .{}); - - var server: Server = undefined; - try server.init(std.heap.c_allocator); - defer server.deinit(); - - try server.start(); - - Log.Info.log("Running server...", .{}); - - server.run(); - - Log.Info.log("Shutting down server", .{}); -} diff --git a/src/river.zig b/src/river.zig new file mode 100644 index 0000000..a5f5334 --- /dev/null +++ b/src/river.zig @@ -0,0 +1,42 @@ +// This file is part of river, a dynamic tiling wayland compositor. +// +// Copyright 2020 Isaac Freund +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +const std = @import("std"); + +const c = @import("c.zig"); + +const Log = @import("log.zig").Log; +const Server = @import("Server.zig"); + +pub fn main() !void { + Log.init(Log.Debug); + c.wlr_log_init(.WLR_ERROR, null); + + Log.Info.log("Initializing server", .{}); + + var server: Server = undefined; + try server.init(std.heap.c_allocator); + defer server.deinit(); + + try server.start(); + + Log.Info.log("Running server...", .{}); + + server.run(); + + Log.Info.log("Shutting down server", .{}); +} diff --git a/src/riverctl.zig b/src/riverctl.zig new file mode 100644 index 0000000..b26bcb7 --- /dev/null +++ b/src/riverctl.zig @@ -0,0 +1,26 @@ +// This file is part of river, a dynamic tiling wayland compositor. +// +// Copyright 2020 Isaac Freund +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +const std = @import("std"); + +const c = @cImport({ + @cInclude(); +}); + +pub fn main() void { + std.debug.warn("hello world\n", .{}); +} -- cgit v1.2.3