Skip to content

Instantly share code, notes, and snippets.

@mattnite
Last active October 3, 2020 17:28
Show Gist options
  • Save mattnite/f4cc0f21bd247ee22ff5d9f68a6f2be0 to your computer and use it in GitHub Desktop.
Save mattnite/f4cc0f21bd247ee22ff5d9f68a6f2be0 to your computer and use it in GitHub Desktop.
Minimal build script for BPF programs
const std = @import("std");
const Builder = std.build.Builder;
const builtin = @import("builtin");
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{});
const obj = b.addObject("probe", "src/probe.zig");
obj.setTarget(std.zig.CrossTarget{
.cpu_arch = switch ((target.cpu_arch orelse builtin.arch).endian()) {
.Big => .bpfeb,
.Little => .bpfel,
},
.os_tag = .freestanding,
});
obj.setBuildMode(.ReleaseFast);
obj.setOutputDir("src");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment