mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-14 16:07:52 +00:00
A build.zig project gets a configuration per build step (zig build, zig build run, zig build test and the project's own steps) and one per executable it declares, which runs zig build first and then the installed binary, debuggable with CodeLLDB. The build script is parsed, never run, to find them. Zig files get gutter markers: pub fn main runs the executable built from the file (or zig run for a file on its own), a test block runs zig test <file> --test-filter <name>, a file with tests only runs them all. Debugging a single file or test builds it into a binary first (build-exe, test --test-no-exec) and launches that. Adds fixtures/zig-app (Zig 0.17). Part of #3260.
32 lines
982 B
Zig
32 lines
982 B
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const tally = b.addModule("tally", .{
|
|
.root_source_file = b.path("src/tally.zig"),
|
|
.target = target,
|
|
});
|
|
|
|
const exe = b.addExecutable(.{
|
|
.name = "zig-app",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{.{ .name = "tally", .module = tally }},
|
|
}),
|
|
});
|
|
b.installArtifact(exe);
|
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
const run_step = b.step("run", "Run the app");
|
|
run_step.dependOn(&run_cmd.step);
|
|
|
|
const tests = b.addTest(.{ .root_module = tally });
|
|
const test_step = b.step("test", "Run the tests");
|
|
test_step.dependOn(&b.addRunArtifact(tests).step);
|
|
}
|