Skip to content

Commit 0837c38

Browse files
committed
Restart repo
1 parent 4982fbd commit 0837c38

30 files changed

+171
-3840
lines changed

.github/workflows/ci.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build_and_test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Zig
17+
uses: goto-bus-stop/setup-zig@v2
18+
with:
19+
version: master
20+
21+
- name: Build
22+
run: zig build
23+
24+
- name: Unit Test
25+
run: zig build test
26+
27+
crosscompile:
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix:
31+
os: [
32+
ubuntu-latest,
33+
windows-latest,
34+
macos-latest,
35+
]
36+
target: [
37+
x86_64-linux-gnu
38+
x86_64-linux-musl
39+
aarch64-linux-gnu
40+
aarch64-linux-musl
41+
]
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Zig
47+
uses: goto-bus-stop/setup-zig@v2
48+
with:
49+
version: master
50+
51+
- name: Build
52+
run: zig build -Dtarget=${{ matrix.target }}

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
zig-cache
2-
src/probe.o
1+
zig-out
2+
.zig-cache

.travis.yml

-3
This file was deleted.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2022 Matthew Knight
1+
Copyright Matthew Knight
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of
44
this software and associated documentation files (the "Software"), to deal in

README.md

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1 @@
1-
# bpf: a Zig BPF library
2-
3-
This library aims to provide similar functionality as libbpf but leveraging the
4-
zig programming language. Probes writen in either library should be able to be
5-
loaded by the other.
6-
7-
# Roadmap
8-
9-
stdlib work:
10-
- document all map types
11-
- document all cmd types
12-
- document all program and attach types
13-
- zigify cmds
14-
- determine all possible errnos
15-
- zigify bpf helpers (include documentation)
16-
- get layout for members of structs found in bpf helpers
17-
18-
this lib work:
19-
- determine how section naming translates into program types and events
20-
- typify section naming
21-
- figure out btf and map relocations
22-
- typify maps
23-
- @Type(.Struct) object
1+
# WIP eBPF Package for Zig

build.zig

+57-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,60 @@
1-
const Builder = @import("std").build.Builder;
1+
const std = @import("std");
22

3-
pub fn build(b: *Builder) void {
4-
var tests = b.addTest("exports.zig");
3+
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
const optimize = b.standardOptimizeOption(.{});
56

6-
const test_step = b.step("test", "Run library tests");
7-
test_step.dependOn(&tests.step);
7+
const lib_mod = b.createModule(.{
8+
.root_source_file = b.path("src/root.zig"),
9+
.target = target,
10+
.optimize = optimize,
11+
});
12+
13+
const exe_mod = b.createModule(.{
14+
.root_source_file = b.path("src/main.zig"),
15+
.target = target,
16+
.optimize = optimize,
17+
});
18+
19+
exe_mod.addImport("bpf_lib", lib_mod);
20+
21+
const lib = b.addStaticLibrary(.{
22+
.name = "bpf",
23+
.root_module = lib_mod,
24+
});
25+
26+
b.installArtifact(lib);
27+
28+
const exe = b.addExecutable(.{
29+
.name = "bpf",
30+
.root_module = exe_mod,
31+
});
32+
b.installArtifact(exe);
33+
34+
const run_cmd = b.addRunArtifact(exe);
35+
36+
run_cmd.step.dependOn(b.getInstallStep());
37+
38+
if (b.args) |args| {
39+
run_cmd.addArgs(args);
40+
}
41+
42+
const run_step = b.step("run", "Run the app");
43+
run_step.dependOn(&run_cmd.step);
44+
45+
const lib_unit_tests = b.addTest(.{
46+
.root_module = lib_mod,
47+
});
48+
49+
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
50+
51+
const exe_unit_tests = b.addTest(.{
52+
.root_module = exe_mod,
53+
});
54+
55+
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
56+
57+
const test_step = b.step("test", "Run unit tests");
58+
test_step.dependOn(&run_lib_unit_tests.step);
59+
test_step.dependOn(&run_exe_unit_tests.step);
860
}

build.zig.zon

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.{
2+
.name = "bpf",
3+
.version = "0.0.0",
4+
.paths = .{
5+
"LICENSE",
6+
"README.md",
7+
"build.zig",
8+
"build.zig.zon",
9+
"src",
10+
},
11+
}

ci/zig-install.sh

-50
This file was deleted.

exports.zig

-9
This file was deleted.

src/btf.zig

-151
This file was deleted.

0 commit comments

Comments
 (0)