flipperzero-zig/build.zig
2024-08-21 19:27:21 -07:00

38 lines
1.2 KiB
Zig

const std = @import("std");
const Target = std.Target;
const Build = std.Build;
pub fn build(b: *Build) void {
// Module
const flipperzero = b.addModule("flipperzero", .{
.root_source_file = b.path("lib/flipperzero/flipperzero.zig"),
});
// Configuration
const optimize = b.standardOptimizeOption(.{});
const target_query = .{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &Target.arm.cpu.cortex_m4 }, .os_tag = .freestanding, .abi = .none };
// Relocatable elf
const elf = b.addObject(.{
.name = "zlipper.fap",
.root_source_file = b.path("src/start.zig"),
.target = b.resolveTargetQuery(target_query),
.optimize = optimize,
.strip = true,
.pic = true,
});
elf.root_module.addImport("flipperzero", flipperzero);
elf.setLinkerScript(b.path("linker.ld"));
elf.setVerboseLink(true);
elf.build_id = .none;
elf.bundle_compiler_rt = false;
elf.link_gc_sections = true;
elf.linkage = .static;
b.default_step.dependOn(&elf.step);
const install_artifact = b.addInstallArtifact(elf, .{ .dest_dir = .{ .override = .{ .bin = {} } } });
b.getInstallStep().dependOn(&install_artifact.step);
}