-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
50 lines (43 loc) · 1.81 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const std = @import("std");
const newlib = @import("stm32_hal").newlib;
pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{
.cpu_arch = .thumb,
.os_tag = .freestanding,
.abi = .eabihf,
.cpu_model = std.zig.CrossTarget.CpuModel{ .explicit = &std.Target.arm.cpu.cortex_m7 },
// Note that "fp_armv8d16sp" is the same instruction set as "fpv5-sp-d16", so LLVM only has the former
// https://github.com/llvm/llvm-project/issues/95053
.cpu_features_add = std.Target.arm.featureSet(&[_]std.Target.arm.Feature{std.Target.arm.Feature.fp_armv8d16sp}),
});
const executable_name = "blinky";
const optimize = b.standardOptimizeOption(.{});
const blinky_exe = b.addExecutable(.{
.name = executable_name ++ ".elf",
.target = target,
.optimize = optimize,
.link_libc = false,
.linkage = .static,
.single_threaded = true,
.root_source_file = b.path("src/main.zig"),
});
blinky_exe.setLinkerScriptPath(b.path("linker/STM32F750N8Hx.ld"));
blinky_exe.link_gc_sections = true;
blinky_exe.link_data_sections = true;
blinky_exe.link_function_sections = true;
// Produce .bin file from .elf
const bin = b.addObjCopy(blinky_exe.getEmittedBin(), .{
.format = .bin,
});
bin.step.dependOn(&blinky_exe.step);
const copy_bin = b.addInstallBinFile(bin.getOutput(), executable_name ++ ".bin");
b.default_step.dependOn(©_bin.step);
// Produce .hex file from .elf
const hex = b.addObjCopy(blinky_exe.getEmittedBin(), .{
.format = .hex,
});
hex.step.dependOn(&blinky_exe.step);
const copy_hex = b.addInstallBinFile(hex.getOutput(), executable_name ++ ".hex");
b.default_step.dependOn(©_hex.step);
b.installArtifact(blinky_exe);
}