[ImpellerC] Write a depfile when --shader-bundle is in use#186341
Merged
bdero merged 2 commits intoMay 12, 2026
Conversation
Threads a dependency-collecting set through GenerateShaderBundleFlatbuffer, GenerateShaderFB, and GenerateShaderBackendFB. Each Compiler reports its included file names plus the primary shader source file into the set, which dedupes naturally across the five target-platform compiles per shader. After successful bundle generation, GenerateShaderBundle emits a Ninja-style depfile when --depfile is set, mirroring the format produced by Compiler::CreateDepfileContents on the single-shader compile path. Previously, --depfile was silently dropped in --shader-bundle mode because the early return into GenerateShaderBundle bypassed OutputDepfile. Build systems consuming impellerc for shader bundles (notably Dart's hooks framework, which flutter_gpu_shaders goes through) had no way to discover which source files and transitive #include headers contributed to the bundle, and therefore couldn't rerun the bundle build when any input changed. Tests confirm the dependency set contains the primary source files. Both the explicit-collector and null-collector paths are exercised. Existing shader bundle tests continue to pass unchanged. Fixes flutter#186340
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements Ninja-style depfile generation for shader bundles by tracking source files and transitive includes during compilation. It updates the compilation pipeline to collect these dependencies, adds a utility to write them to disk, and includes unit tests to verify the new functionality. Review feedback recommends resolving paths relative to the specified working directory, simplifying string conversions in file operations, and using UTF-8 encoding for target paths to ensure cross-platform compatibility.
This was referenced May 12, 2026
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.
Fixes #186340
When
impellercis invoked with both--depfile=<path>and--shader-bundle=<json>, the depfile is silently dropped.impellerc_main.cctakes an early return intoGenerateShaderBundle(switches)when--shader-bundleis set, and the depfile-writing branch only runs on the non-bundle path. Build systems consuming impellerc for shader bundles (notably Dart'shooksframework, whichflutter_gpu_shaders'sbuildShaderBundleJsongoes through) have no way to discover which source files and transitive#includeheaders contributed to the produced bundle, and therefore cannot rerun the bundle build when any input changes. The user-visible effect is that editing a.fragreferenced by a shader bundle manifest does not invalidate the cached bundle output untilflutter cleanis run, which makes shader iteration painful and confuses new users.This change threads an optional
std::set<std::string>* out_dependenciesparameter throughGenerateShaderBundleFlatbuffer,GenerateShaderFB, andGenerateShaderBackendFB. EachCompilerinstance reports itsGetIncludedFileNames()plus the primary shader source file into the set, which dedupes naturally across the five target-platform compiles per shader. After successful bundle generation,GenerateShaderBundleemits a Ninja-style depfile when--depfileis set, mirroring the format produced byCompiler::CreateDepfileContentson the single-shader compile path.Manually verified end to end against a real bundle whose only shader transitively
#includes a header: the resulting depfile lists both files. The new unit tests cover both the explicit-collector path (set contains the primary source files) and the null-collector path (callers that don't pass a set get exactly today's behaviour). Existing shader-bundle unit tests continue to pass unchanged.Pre-launch Checklist
///).