Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregate builder not rebuild when one of multiple output files is deleted #3364

Closed
lcdsmao opened this issue Sep 7, 2022 · 3 comments · Fixed by #3370
Closed

aggregate builder not rebuild when one of multiple output files is deleted #3364

lcdsmao opened this issue Sep 7, 2022 · 3 comments · Fixed by #3370
Assignees

Comments

@lcdsmao
Copy link

lcdsmao commented Sep 7, 2022

Thank you for taking the time to file an issue!

In order to route, prioritize, and act on this as soon as possible please include:

Dart SDK Version (dart --version)

Dart SDK version: 2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "macos_x64"

What package(s) from this repo you are using, and the version (i.e. build_runner 0.7.12)

  • build: 2.3.0
  • build_runner: 2.2.0

What builder(s) you are using (or writing yourself). Try to give a short summary of what they do.

I am trying to build an aggregate builder that generates multiple files.
For example, we have the following buildExtensions:

  @override
  Map<String, List<String>> get buildExtensions => const {
        r'$package$': [
          'lib/foo.gen.dart',
          'lib/bar.gen.dart',
        ],
      };

First, we run the build_runner and generate all those files.
Then if I delete the first file (lib/foo.gen.dart) and run build_runner again, files will be generated again properly.
But if I delete the second file (lib/bar.gen.dart) and run build_runner again, files won't be generated.

Here is the repo that reproduces this bug:
https://github.com/lcdsmao/aggregate_builder_bug/blob/main/lib/builder.dart

cd example
dart pub get
dart run build_runner build
# files should be generated

rm lib/foo.gen.dart
dart run build_runner build
# files generated again

rm lib/bar.gen.dart
dart run build_runner build
# files are not generated

I am trying to fix a bug of flutter_gen, and facing this bug.

@jakemac53 jakemac53 self-assigned this Sep 13, 2022
@jakemac53
Copy link
Contributor

Going to try and take a look at this today

@jakemac53
Copy link
Contributor

var firstOutput = outputs.first;
this line looks like the issue - when a file is manually deleted which is one of many outputs, the assumption here doesn't hold.

Can fix it by either checking all outputs to see if any are invalidated, or invalidating all the outputs of the same build step when we see the delete.

@jakemac53
Copy link
Contributor

Thanks for the full reproduction repo @lcdsmao that helped a lot with diagnosing the issue efficiently! I have a fix out and should be able to publish it later today or tomorrow.

jakemac53 added a commit that referenced this issue Sep 13, 2022
… outputs (#3370)

Fixes #3364

When a manual delete happens, we mark just that output as definitelyNeedsUpdate, but when checking if a given build step needs to run, we were only checking the state of the first output, based on an assumption that all outputs got invalidated together. That is true for all cases except this one.

This changes it to check if any of the output nodes definitely need an update, to cover this particular case.
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 a pull request may close this issue.

2 participants