script: filter out unreachable files#297
Open
fischeti wants to merge 11 commits into
Open
Conversation
0d4580e to
7930fa6
Compare
4967432 to
c36b891
Compare
Member
|
One question - does this also filter out the include directories if they are not required? I think that would be useful when restricting the file list. |
- script: scope the HashSet import to filter_srcs_by_top so a --no-default-features build no longer emits an unused-import warning - tests/script: assert exact basename-set membership instead of substring containment — "top.sv" previously also matched "unused_top.sv", so passing tests didn't actually prove what they claimed - bender-slang/analysis: guard getSourceBufferIds()[0] with an empty check, falling back to "<unknown>" in the duplicate-decl warning Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- bender-slang/analysis: replace the STDERR_IS_TTY macro with a small stderr_is_tty() helper, lift the duplicate-decl DiagCode and message format to file-scope named constants, and cache one DiagnosticEngine+TextDiagnosticClient per distinct SourceManager instead of constructing fresh ones on every collision. Trees within one parse group share an engine; trees across groups get separate ones (each SlangContext owns its own SourceManager). - bender-slang/analysis: the "top module not found" error now reports the number of known top-level declarations, which makes "no such module" vs "parser saw nothing" easy to distinguish at a glance. - script: clarify in the --top help text that only Verilog files are trimmed; VHDL and untyped files are always retained. - script: restore the small `concat` helper that the original feature commit replaced inline; the inline form (`[xs as &[_], ys].concat()`) was a drive-by unrelated to the filter feature and reads worse. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pure reformat of the previous cleanup commit — no behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extend the slang-based filtering to also drop `+incdir+` entries that slang did not actually resolve any `include directive through. A new --trim-incdirs flag controls the behavior: auto (default) drop iff --top is set always drop unused directories even without --top never keep every directory declared in Bender.yml bender-slang exposes a new resolved_include_paths_for() helper that walks each requested tree's getIncludeDirectives() and returns the deduped canonical paths from getFullPath(). The Rust side compares those paths against each SourceGroup's include_dirs / export_incdirs via Path::starts_with (with canonicalize() so symlinks and relative segments don't cause false negatives). The file/include-dir filters are now independent: filter_srcs_by_top was renamed to apply_slang_filters, which only filters files when --top is non-empty and only trims include dirs when asked. The "no top, no trim" path short-circuits without spinning up a SlangSession. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ab1d778 to
9abbc1c
Compare
The new include-dir filter used std::fs::canonicalize to normalize each SourceGroup's include path before checking it against the canonical paths slang resolved through. On Windows that returns the `\\?\C:\...` UNC form, while slang's internal `fs::weakly_canonical` returns plain `C:\...`. Path::starts_with then never matches, so every include directory was being dropped on Windows — the new tests fail because incdir_basenames returns an empty set. Use the same cfg-gated `canonicalize` import that sess.rs / cli.rs / cmd/parents.rs already use (std::fs on Unix, dunce on Windows). This matches the form slang emits and restores prefix matching on Windows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The new --trim-incdirs tests use an incdir_basenames helper that
rsplits each `+incdir+` line on '/' and asserts membership of bare
directory names like "include". On Windows, the Bender.yml entry
`include` is joined with the workspace root using '\\', producing a
fully-backslash path with no '/' anywhere — rsplit returns the whole
path and the assertion fails.
Source-file tests were unaffected because Bender.yml uses entries like
`src/top.sv` (with an embedded '/'), so the final path stays mixed
('\\…\\pickle/src/top.sv') and rsplit('/') still finds 'top.sv'.
Factor out a small `basename` helper that walks back to the last '/'
or '\\' before slicing. Both `source_basenames` and `incdir_basenames`
now use it.
Co-Authored-By: Claude Opus 4.7 (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.
script
Similar to the
picklecommand, thescriptcommand gains a new--topflag (can be specified multiple times), that will filter out all unreachable files from said top modules.bender-slangChanges resp. fixes the behaviour for duplicate defined symbols. The previous behaviour was actually wrong (also in the
picklecommand) because it was first-one-wins. Now it is last-one-wins which is also what all EDA tools do afaik.Further, it adds a slang diagnostic language whenever a module name already exists. The diagnostic is slang style and reuses slang infrastructure for this.
Tests
Integration tests
There are now integration tests for
script flistoutput to check for existence of files (or the lack thereof). The pickle repo test suite is extended for that with an example of a duplicate module definition.Real-world tests
Tested in cheshire for
vsimandvcstarget here, pipeline passes. Reduces file list from 670 to 444.Also tested in FlooNoc for
vcsandsynopsys(elaboration), where it even discovered a duplicate file in the bender manifest🤓TODOs
bender-slangonce approved