123456789101112131415161718192021222324252627282930313233
  1. const std = @import("std");
  2. // Learn more about this file here: https://ziglang.org/learn/build-system
  3. pub fn build(b: *std.Build) void {
  4. const exe = b.addExecutable(.{
  5. .name = "main",
  6. .root_source_file = b.path("src/main.zig"),
  7. .target = b.standardTargetOptions(.{}),
  8. .optimize = b.standardOptimizeOption(.{}),
  9. });
  10. // This declares intent for the executable to be installed into the
  11. // standard location when the user invokes the "install" step (the default
  12. // step when running `zig build`).
  13. b.installArtifact(exe);
  14. // This *creates* a Run step in the build graph, to be executed when another
  15. // step is evaluated that depends on it. The next line below will establish
  16. // such a dependency.
  17. const run_cmd = b.addRunArtifact(exe);
  18. // This creates a build step. It will be visible in the `zig build --help` menu,
  19. // and can be selected like this: `zig build run`
  20. // This will evaluate the `run` step rather than the default, which is "install".
  21. const run_step = b.step("run", "Run the app");
  22. run_step.dependOn(&run_cmd.step);
  23. // This allows the user to pass arguments to the application in the build
  24. // command itself, like this: `zig build run -- arg1 arg2 etc`
  25. if (b.args) |args| {
  26. run_cmd.addArgs(args);
  27. }
  28. }