This project uses a three-stage code generation pipeline (see README.md for details):
- Stage 1 (
make specs):tools/cmd/specgen+c2ffiextracts structured YAML specs from C headers intospec/generated/. - Stage 2 (
make capi):tools/cmd/capigengenerates raw CGo bindings incapi/{module}/from specs + manifests. - Stage 3 (
make idiomatic):tools/cmd/idiomgengenerates idiomatic Go packages from specs + overlays + templates.
All files under capi/{module}/ and {module}/ (top-level idiomatic packages like looper/, camera/, sensor/, etc.) are generated. They contain // Code generated by ... DO NOT EDIT. headers.
Never edit these files. Instead, modify the appropriate source:
- To change raw CGo bindings (
capi/): editcapi/manifests/{module}.yamlortools/pkg/capigen/. Nobody else writes tocapi/butcapigen! - To change idiomatic Go API shape (type names, method receivers, error handling): edit
spec/overlays/{module}.yaml. - To change generated code patterns (struct layout, constructor/destructor shape, bridge code): edit
templates/*.tmpl. - To change spec extraction logic: edit
tools/pkg/specgen/. - To change idiomatic generation logic: edit
tools/pkg/idiomgen/ortools/pkg/overlaymodel/.
After modifying sources, regenerate with make idiomatic (or make regen for a full rebuild).
Code in examples/ must import only the idiomatic top-level packages (e.g., github.com/AndroidGoLab/ndk/looper, github.com/AndroidGoLab/ndk/camera). Never import capi/ packages or use import "C" / CGo directly in examples. If the idiomatic package is missing a needed function or type, add it via the overlay and regenerate rather than falling back to capi.