Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.87 KB

File metadata and controls

30 lines (19 loc) · 1.87 KB

Project Instructions

Code Generation Pipeline

This project uses a three-stage code generation pipeline (see README.md for details):

  1. Stage 1 (make specs): tools/cmd/specgen + c2ffi extracts structured YAML specs from C headers into spec/generated/.
  2. Stage 2 (make capi): tools/cmd/capigen generates raw CGo bindings in capi/{module}/ from specs + manifests.
  3. Stage 3 (make idiomatic): tools/cmd/idiomgen generates idiomatic Go packages from specs + overlays + templates.

Rules

Never edit generated bindings directly

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/): edit capi/manifests/{module}.yaml or tools/pkg/capigen/. Nobody else writes to capi/ but capigen!
  • 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/ or tools/pkg/overlaymodel/.

After modifying sources, regenerate with make idiomatic (or make regen for a full rebuild).

Examples must use only idiomatic bindings

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.