chore: make stuff work

This commit is contained in:
Jacob Jonsson 2025-11-30 22:52:22 +01:00
parent 936bf470c7
commit 1e4c90822a
Signed by: Jassob
GPG key ID: 7E30B9B047F7202E
4 changed files with 267 additions and 117 deletions

View file

@ -21,6 +21,12 @@ pub fn build(b: *std.Build) void {
// target and optimize options) will be listed when running `zig build --help`
// in this directory.
// Dependencies
const zircon = b.dependency("zircon", .{
.target = target,
.optimize = optimize,
});
// This creates a module, which represents a collection of source files alongside
// some compilation options, such as optimization mode and linked system libraries.
// Zig modules are the preferred way of making Zig code available to consumers.
@ -39,6 +45,9 @@ pub fn build(b: *std.Build) void {
// Later on we'll use this module as the root module of a test executable
// which requires us to specify a target.
.target = target,
.imports = &.{
.{ .name = "zircon", .module = zircon.module("zircon") },
},
});
// Here we define an executable. An executable needs to have a root module
@ -79,17 +88,11 @@ pub fn build(b: *std.Build) void {
// can be extremely useful in case of collisions (which can happen
// importing modules from different packages).
.{ .name = "zigeru", .module = mod },
.{ .name = "zircon", .module = zircon.module("zircon") },
},
}),
});
const zircon = b.dependency("zircon", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zircon", zircon.module("zircon"));
mod.addImport("zircon", zircon.module("zircon"));
exe.linkLibC();
// This declares intent for the executable to be installed into the
@ -134,6 +137,21 @@ pub fn build(b: *std.Build) void {
// A run step that will run the test executable.
const run_mod_tests = b.addRunArtifact(mod_tests);
const bot_tests = b.addTest(.{
.root_module = b.addModule("bot", .{
.target = target,
.root_source_file = b.path("src/bot.zig"),
.imports = &.{
.{
.name = "zircon",
.module = zircon.module("zircon"),
},
},
}),
});
const run_bot_tests = b.addRunArtifact(bot_tests);
// Creates an executable that will run `test` blocks from the executable's
// root module. Note that test executables only test one module at a time,
// hence why we have to create two separate ones.
@ -150,6 +168,7 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_exe_tests.step);
test_step.dependOn(&run_bot_tests.step);
// Just like flags, top level steps are also listed in the `--help` menu.
//