Files
zig_progvs2/tiva/build.zig
2026-03-09 10:20:42 +01:00

47 lines
1.3 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{
.cpu_arch = .thumb,
.os_tag = .freestanding,
.abi = .eabi,
.cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m4 },
});
const optimize = b.standardOptimizeOption(.{});
// Create the module separately
const tiva_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const cmsis_path = "/home/priec/programs/CMSIS";
// Generic CMSIS Core (for core_cm4.h)
tiva_module.addIncludePath(.{ .cwd_relative = cmsis_path ++ "/CMSIS/Include" });
// TM4C Device Specific (for TM4C123GH6PM.h)
tiva_module.addIncludePath(.{ .cwd_relative = cmsis_path ++ "/Device/TI/TM4C/Include" });
const elf = b.addExecutable(.{
.name = "tiva-app",
.root_module = tiva_module,
});
elf.root_module.strip = true;
elf.root_module.omit_frame_pointer = true;
elf.root_module.unwind_tables = .none;
// Disable red zone for bare metal
elf.root_module.red_zone = false;
// Provide basic built-in functions
elf.bundle_compiler_rt = true;
// Use your custom linker script
elf.setLinkerScript(b.path("layout.ld"));
b.installArtifact(elf);
}