script: expose slang-resolved headers as all_headers for templates#334
Open
colluca wants to merge 1 commit into
Open
script: expose slang-resolved headers as all_headers for templates#334colluca wants to merge 1 commit into
all_headers for templates#334colluca wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
all_headersvariable to thebender scripttemplate context: thefine-grained, transitive, deduplicated set of header files slang actually
resolved via
`includewhile parsing, mirroring whatverilator -MMDreports.
Today
flistemits only source files andflist-plusadds+incdir+directories — neither surfaces the individual header files that were pulled
in. slang already tracks them (
resolved_include_paths), andapply_slang_filtersalready computed this list for--trim-incdirs, thendiscarded 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 correctlywhen a header changes.
What changed
apply_slang_filtersnow returns the resolved-header paths (computedwhenever the slang pass runs, instead of only for
--trim-incdirs).run()threads them through toemit_template, which inserts a sorted,deduplicated
all_headers(absolute paths, consistent withall_files/all_incdirs) into the Tera context.all_headersis populated whenever the slang pass runs (--top,--trim-incdirs {always | auto+--top}, or a--broken/--encryptedpolicy) and is empty otherwise.
No new C++ (the slang machinery already existed).
flist/flist-plusoutputis unchanged — the new variable is only consumed by templates
that reference it.