-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
31 lines (25 loc) · 1.05 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = std.zig.CrossTarget{
.cpu_arch = std.Target.Cpu.Arch.riscv32,
.os_tag = std.Target.Os.Tag.freestanding,
.abi = std.Target.Abi.eabi,
.cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32 },
.cpu_features_add = std.Target.riscv.featureSet(&[_]std.Target.riscv.Feature{ .c, .m, .a }),
};
const optimize = std.builtin.OptimizeMode.ReleaseSmall;
const exe = b.addExecutable(.{
.name = "weact-ch582f",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const link_file_path = comptime root() ++ "link.ld";
exe.setLinkerScriptPath(std.build.FileSource{ .path = link_file_path });
//exe.strip = false; // set to false to keep debug symbols for llvm-objdump
exe.addAssemblyFile((.{ .path = "./src/startup.s" }));
b.installArtifact(exe);
}
fn root() []const u8 {
return comptime (std.fs.path.dirname(@src().file) orelse ".") ++ "/";
}