Skip to content

script: expose slang-resolved headers as all_headers for templates#334

Open
colluca wants to merge 1 commit into
masterfrom
script-all-headers
Open

script: expose slang-resolved headers as all_headers for templates#334
colluca wants to merge 1 commit into
masterfrom
script-all-headers

Conversation

@colluca

@colluca colluca commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new all_headers variable to the bender script template context: the
fine-grained, transitive, deduplicated set of header files slang actually
resolved via `include while parsing, mirroring what verilator -MMD
reports.

Today flist emits only source files and flist-plus adds +incdir+
directories — neither surfaces the individual header files that were pulled
in. slang already tracks them (resolved_include_paths), and
apply_slang_filters already computed this list for --trim-incdirs, then
discarded it. This PR keeps that list and exposes it to templates, so users can
build precise dependency lists (e.g. a Makefile .d) that invalidate correctly
when a header changes.

What changed

  • apply_slang_filters now returns the resolved-header paths (computed
    whenever the slang pass runs, instead of only for --trim-incdirs).
  • run() threads them through to emit_template, which inserts a sorted,
    deduplicated all_headers (absolute paths, consistent with
    all_files/all_incdirs) into the Tera context.
  • all_headers is populated whenever the slang pass runs (--top,
    --trim-incdirs {always | auto+--top}, or a --broken/--encrypted
    policy) and is empty otherwise.

No new C++ (the slang machinery already existed). flist/flist-plus output
is unchanged
— the new variable is only consumed by templates
that reference it.

Add `all_headers` to the `bender script` template context: the fine-grained,
transitive, deduplicated set of header files slang resolved via `include for
the kept trees (reachable-from-top with `--top`, otherwise all parsed trees).

This reuses the resolved-include list `apply_slang_filters` already computed
for `--trim-incdirs` (previously discarded) and surfaces it to
`template`/`template-json`, so users can emit precise dependency (`.d`) files
that track header edits the way `verilator -MMD` does. It is populated whenever
the slang pass runs (`--top`/`--trim-incdirs`/`--broken`/`--encrypted`) and is
empty otherwise; `flist`/`flist-plus` output is unchanged.

Adds three integration tests (the first to exercise `resolved_include_paths`)
plus book and CHANGELOG entries.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant