Break relay into a specific program

This commit is contained in:
2025-04-04 22:09:06 -04:00
parent 93161ff4bd
commit 448e900004
2 changed files with 9 additions and 9 deletions

View File

@@ -16,34 +16,34 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
// We will also create a module for our other entry point, 'main.zig'. // We will also create a module for our other entry point, 'main.zig'.
const exe_mod = b.createModule(.{ const relay_exe_mod = b.createModule(.{
// `root_source_file` is the Zig "entry point" of the module. If a module // `root_source_file` is the Zig "entry point" of the module. If a module
// only contains e.g. external object files, you can make this `null`. // only contains e.g. external object files, you can make this `null`.
// In this case the main source file is merely a path, however, in more // In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file. // complicated build scripts, this could be a generated file.
.root_source_file = b.path("src/main.zig"), .root_source_file = b.path("src/saprus_relay.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
exe_mod.addImport("network", b.dependency("network", .{}).module("network")); relay_exe_mod.addImport("network", b.dependency("network", .{}).module("network"));
// This creates another `std.Build.Step.Compile`, but this one builds an executable // This creates another `std.Build.Step.Compile`, but this one builds an executable
// rather than a static library. // rather than a static library.
const exe = b.addExecutable(.{ const relay_exe = b.addExecutable(.{
.name = "zaprus", .name = "saprus_relay",
.root_module = exe_mod, .root_module = relay_exe_mod,
}); });
// This declares intent for the executable to be installed into the // This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default // standard location when the user invokes the "install" step (the default
// step when running `zig build`). // step when running `zig build`).
b.installArtifact(exe); b.installArtifact(relay_exe);
// This *creates* a Run step in the build graph, to be executed when another // This *creates* a Run step in the build graph, to be executed when another
// step is evaluated that depends on it. The next line below will establish // step is evaluated that depends on it. The next line below will establish
// such a dependency. // such a dependency.
const run_cmd = b.addRunArtifact(exe); const run_cmd = b.addRunArtifact(relay_exe);
// By making the run step depend on the install step, it will be run from the // By making the run step depend on the install step, it will be run from the
// installation directory rather than directly from within the cache directory. // installation directory rather than directly from within the cache directory.
@@ -64,7 +64,7 @@ pub fn build(b: *std.Build) void {
run_step.dependOn(&run_cmd.step); run_step.dependOn(&run_cmd.step);
const exe_unit_tests = b.addTest(.{ const exe_unit_tests = b.addTest(.{
.root_module = exe_mod, .root_module = relay_exe_mod,
}); });
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);