Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# make — build everything (BPF objects + JS bundle)
# make bpf — compile bpf/*.bpf.c into bin/* only
# make veristat — load the built object with veristat (verifier check on this kernel)
# make bundle — resolve npm/jsr deps and bundle the JS entry
# make bundle — bundle the JS entry with the vendored esbuild
# make postgen — finalize a freshly generated project (git init)
# make clangd — write a local .clangd pointing at the resolved toolchain
# make clean — remove build artifacts
Expand All @@ -24,31 +24,26 @@
include build/toolchain.mk
include build/bpf.mk

NPM ?= npm

all: bpf bundle

# Bundle the entry with the vendored esbuild. esbuild inlines node_modules
# and honors tsconfig `paths` (so `@/` resolves at bundle time), while
# `yeet:*` builtins and `*.bpf.o` objects stay external. The bundle is
# written to src/index.jsx, which the entry ladder prefers over src/main.jsx
# — so once built, that is what runs. The .jsx extension keeps the bundle
# eligible for component auto-mount. Compiled BPF objects in bin/ are loaded
# by path at runtime, never imported, so they are not bundled.
# Bundle the entry with the vendored esbuild. esbuild honors tsconfig `paths`
# (so `@/` resolves at bundle time), while `yeet:*` builtins and `*.bpf.o`
# objects stay external. The bundle is written to src/index.jsx, which the
# entry ladder prefers over src/main.jsx — so once built, that is what runs.
# The .jsx extension keeps the bundle eligible for component auto-mount.
# Compiled BPF objects in bin/ are loaded by path at runtime, never imported,
# so they are not bundled.
#
# `npm install` still runs first: esbuild resolves the project's own
# dependencies out of node_modules when inlining them.
# No npm step: esbuild is the vendored toolchain binary and this project pulls
# in no npm packages. Add a package.json + `npm install` only if you import
# one — esbuild then inlines node_modules at bundle time.
ESBUILD_FLAGS := --bundle --format=esm --platform=neutral \
--main-fields=module,main --conditions=import,module \
--outfile=src/index.jsx --jsx=automatic --jsx-import-source=yeet:tui

bundle: node_modules | toolchain
bundle: | toolchain
$(ESBUILD) src/main.jsx $(ESBUILD_FLAGS) '--external:yeet:*' '--external:*.bpf.o'

node_modules: package.json
$(NPM) install
@touch node_modules

# Post-generation finalize: initialize a git repository with the vendored git
# (fetched via `vendored-git`). Idempotent — skipped if this is already a repo.
# The scaffolders (`yeet new`, `scripts/new`) run `make postgen` after creating
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ make bundle # just the JS bundle (src/main.jsx -> src/index.jsx)
make clean # remove build artifacts
```

`make` runs two independent compilers: **clang + bpftool** compile every `src/bpf/*.bpf.c` and link them into one loadable object `bin/probe.bpf.o`; **esbuild** bundles `src/main.jsx` into `src/index.jsx`, inlining npm deps and the `@/` alias and leaving `yeet:*` builtins external. The toolchain (clang, bpftool, esbuild) is fetched into a per-machine cache on first build — no system C/BPF toolchain required. The generated CO-RE header `src/bpf/include/vmlinux.h` and `bin/` are build artifacts (gitignored).
`make` runs two independent compilers: **clang + bpftool** compile every `src/bpf/*.bpf.c` and link them into one loadable object `bin/probe.bpf.o`; **esbuild** bundles `src/main.jsx` into `src/index.jsx`, resolving the `@/` alias and leaving `yeet:*` builtins external. The toolchain (clang, bpftool, esbuild) is fetched into a per-machine cache on first build — no system C/BPF toolchain and no Node/npm required. The generated CO-RE header `src/bpf/include/vmlinux.h` and `bin/` are build artifacts (gitignored).

`#/` (project root) and `@/` (source root) are **bundle-time aliases** that esbuild resolves via `tsconfig` `paths`; the runtime resolver doesn't know them, which is why the BPF object is located with `import.meta.dirname` in `probes/probe.js`.

Expand Down
2 changes: 1 addition & 1 deletion build/toolchain.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ GIT_SHA256_aarch64=19c6dda22c811324649e6e4aa8c369a8d822463d61d794d0e23e72fb77b53

# esbuild — official static (Go) binary from the @esbuild/<platform> npm
# package, re-hosted on our "toolchain" release. CI records the binary
# checksum. Keep ESBUILD_VERSION in sync with template/package.json.
# checksum.
ESBUILD_VERSION=0.28.1
ESBUILD_SHA256_x86_64=0c6588b092a2c291a72bab90659f3c9e0e25e0fe59c9ac12b4dae4d945e5548c
ESBUILD_SHA256_aarch64=51e829ba36f36be6d9aea6e329ddc4f9350302339b16aaca96a3cb97f64a8ebb
Expand Down
Loading
Loading