1// Copyright © 2020-2021 Sören Tempel2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU Affero General Public License as5// published by the Free Software Foundation, either version 3 of the6// License, or (at your option) any later version.7//8// This program is distributed in the hope that it will be useful, but9// WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11// Affero General Public License for more details.12//13// You should have received a copy of the GNU Affero General Public License14// along with this program. If not, see <https://www.gnu.org/licenses/>.1516const std = @import("std");17const Target = std.Target;18const Zig = std.zig;19const FileSource = std.build.FileSource;20const Builder = std.build.Builder;21const FeatureSet = std.Target.Cpu.Feature.Set;2223pub fn build(b: *Builder) void {24 var fe310_cpu_feat = FeatureSet.empty;25 const m: std.Target.riscv.Feature = .m;26 const a: std.Target.riscv.Feature = .a;27 const c: std.Target.riscv.Feature = .c;28 fe310_cpu_feat.addFeature(@enumToInt(a));29 fe310_cpu_feat.addFeature(@enumToInt(m));30 fe310_cpu_feat.addFeature(@enumToInt(c));3132 const target = Zig.CrossTarget{33 .cpu_arch = Target.Cpu.Arch.riscv32,34 .os_tag = Target.Os.Tag.freestanding,35 .abi = Target.Abi.none,36 .cpu_features_sub = std.Target.riscv.cpu.baseline_rv32.features,37 .cpu_features_add = fe310_cpu_feat,38 };3940 const mode = b.standardReleaseOptions();4142 const exe = b.addExecutable("main", "src/init.zig");43 exe.setLinkerScriptPath(FileSource{ .path = "fe310_g000.ld" });44 exe.setTarget(target);45 exe.setBuildMode(mode);4647 exe.addCSourceFile("src/start.S", &[_][]const u8{});48 exe.addCSourceFile("src/irq.S", &[_][]const u8{});49 exe.addCSourceFile("src/clock.c", &[_][]const u8{});5051 exe.addPackage(std.build.Pkg{52 .name = "zoap",53 .path = FileSource{ .path = "./zoap/src/zoap.zig" },54 });5556 b.default_step.dependOn(&exe.step);57 b.installArtifact(exe);58}