Skip to content

Export: trimming enhancements#3530

Open
DuBento wants to merge 109 commits into
thought-machine:masterfrom
DuBento:export-from-package-metadata
Open

Export: trimming enhancements#3530
DuBento wants to merge 109 commits into
thought-machine:masterfrom
DuBento:export-from-package-metadata

Conversation

@DuBento

@DuBento DuBento commented May 1, 2026

Copy link
Copy Markdown
Contributor

Enhancements to plz export, moving from a basic target-level trimming (using gc.RewriteFile) to build statement-level trimming, including only the required build rules and subincludes.
For consistency, we format all the exported BUILD files.

Changelog:

  • Introduced PackageMetadata to track the relationship between BUILD file statements, the targets they generate, and the subincludes they require. Made optional to avoid the overhead for most ops and enabled for the export.
  • Introduced ScopeMetadata to track object origins (subincluded labels) and statement tracking during the interpreter phase. Made optional to avoid the overhead for most ops and enabled for the export.
  • Refactored src/export/export.go to enforce better separation of the DefaultExporter (for trimming) and NoTrimExporter.
  • Added logic to parse BUILD files and selectively write back statements based on whether the generated targets are part of the export set.
  • Implemented "minimal subinclude" generation, which rewrites subinclude() calls to only include labels actually used by the exported targets.
  • Update and added some of the e2e to reflect the changes in implementation.
  • Moved trimming from a GC-based target removal to a full AST statement walk.

duarte added 30 commits April 29, 2026 19:28
setting subincludes at package level instead of at target level
- register subinclude statements in the package metadata
- filter subincludes label
- export all non build_target related statements
…dary build def with sources

the updated test uses non-standard child naming to validate new trimming logic
@DuBento DuBento force-pushed the export-from-package-metadata branch 2 times, most recently from e584818 to 6b9f0c4 Compare June 10, 2026 18:07
@DuBento DuBento force-pushed the export-from-package-metadata branch from f6fbf1a to 7152109 Compare June 17, 2026 10:01
DuBento added 16 commits June 17, 2026 18:27
…a to also avoid tracking inside subincludes
…Parser is set.

This wasn't an issue before since we would force close all the channels and fail during the first parse, but now we will attempt to wait for parsed package during an export.
…ents (including non-target generators).

The reason for pivoting is that the previous implementation failed to identify necessary subincludes for variable declarations or other builtin methods (string join)
…ls to interpretStatements with the package level scope (e.g. for loop)
…y if blocks that have interpreted stmts (var redeclaration)
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.

3 participants