Micromouse/build.zig

40 lines
1.5 KiB
Zig

const std = @import("std");
const rp2040 = @import("rp2040");
pub fn build(b: *std.Build) void {
const microzig = @import("microzig").init(b, "microzig");
const optimize = b.standardOptimizeOption(.{});
// `addFirmware` basically works like addExecutable, but takes a
// `microzig.Target` for target instead of a `std.zig.CrossTarget`.
//
// The target will convey all necessary information on the chip,
// cpu and potentially the board as well.
const firmware = microzig.addFirmware(b, .{
.name = "micromouse",
.target = rp2040.boards.raspberry_pi.pico,
.optimize = optimize,
.source_file = .{ .path = "src/main.zig" },
});
// We also build a native executable for simulator testing
const exe = b.addExecutable(.{
.name = "micromouse",
.root_source_file = .{ .path = "src/main.zig" },
// Will be .target = b.host in 0.12
.target = b.standardTargetOptions(.{})
});
// `installFirmware()` is the MicroZig pendant to `Build.installArtifact()`
// and allows installing the firmware as a typical firmware file.
//
// This will also install into `$prefix/firmware` instead of `$prefix/bin`.
microzig.installFirmware(b, firmware, .{});
// For debugging, we also always install the firmware as an ELF file
microzig.installFirmware(b, firmware, .{ .format = .elf });
// Install the native executable into zig-out/bin/
b.installArtifact(exe);
}