-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Expose build mode in environment of asset transformer processes #144752
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
Expose build mode in environment of asset transformer processes #144752
Conversation
f030d69 to
aadd25a
Compare
f5f85eb to
579912d
Compare
| _dartBinaryPath = dartBinaryPath, | ||
| _buildMode = buildMode; | ||
|
|
||
| static const String buildModeEnvVar = 'FLUTTER_BUILD_MODE'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have an internal instinct telling me that these should be namespaced, but FLUTTER_ASSET_TRANFORMER__BUILD_MODE feels a bit verbose. I think we are fine here.
|
I do think a better solution would be to allow users to define separate asset configurations per build mode. For purely demonstrative purposes, consider this example fictional pubspec: flutter:
assets:
- path: assets/hello.png
buildModes: ["debug"]
- path: assets/hello.png
buildModes: ["profile", "release"]
transformers:
- package: optimizer
args: --quality 95However, this would be 1) harder to implement and maintain and 2) would call for a bunch of design discussion. I think this PR is still useful as a stop gap. I imagine, for example, an image optimization transformer could provide an option like "--release-only" which tells the transformer to just copy the file as-is when not running in release mode. flutter:
assets:
- path: assets/hello.png
transformers:
- package: optimizer
args: --release-only --quality 95 |
| Future<void> build(Environment environment) async { | ||
| final String? buildModeEnvironment = environment.defines[kBuildMode]; | ||
| if (buildModeEnvironment == null) { | ||
| throw MissingDefineException(kBuildMode, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we'll ever hit this. merging this and then seeing if we need to roll back sounds good to me, though.
christopherfujino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
A reason for requesting a revert of flutter/flutter/144752 could |
|
Reason for revert: compilation issue has turned the tree red |
…ses (#144752)" (#144957) Reverts: #144752 Initiated by: andrewkolos Reason for reverting: compilation issue has turned the tree red Original PR Author: andrewkolos Reviewed By: {christopherfujino} This change reverts the following previous change: In service of #143348 When invoking a package to transform an asset, we set `FLUTTER_BUILD_MODE` to the CLI name of the build mode being used. Inspired by #101077 (comment): > Do transformers know whether they get executed in debug or release mode? I kinda imagine that being useful. Ex: There's a transformer that optimizes the file size of images. Depending on the amount and size of the images, that could take a significant amount of time. Therefore, I might want to only execute it in release builds. Note for the reviewer: the interesting part of this change can be found in the commit [set environment variable to build mode when running asset transformer…](579912d). The rest of the change is updating call sites with a new argument.
For posterity can you link a failing a build? (This is something I always check when reviewing re-lands) |
|
|
@CaseyHillers is it possible to get the presubmit google testing run for this PR? I see the check passed but it failed postsubmit |
The PR branch was stale—it branched off master before #144734 landed. That PR introduced a new |
Interesting. Thanks for the explanation @andrewkolos! |
Manual roll requested by [email protected] flutter/flutter@3bb2e59...1ca8873 2024-03-12 [email protected] Update integration tests regexes. (flutter/flutter#144847) 2024-03-11 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fail tests on exceptions raised after test completed (#144706)" (flutter/flutter#144970) 2024-03-11 [email protected] Make TabController communicating creation in constructor. (flutter/flutter#144912) 2024-03-11 [email protected] Fail tests on exceptions raised after test completed (flutter/flutter#144706) 2024-03-11 [email protected] Refactoring `if` chains into `switch` statements (flutter/flutter#144905) 2024-03-11 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Expose build mode in environment of asset transformer processes (#144752)" (flutter/flutter#144957) 2024-03-11 [email protected] Expose build mode in environment of asset transformer processes (flutter/flutter#144752) 2024-03-11 [email protected] Roll Flutter Engine from 9196947bc687 to 6745955bb49e (2 revisions) (flutter/flutter#144946) 2024-03-11 [email protected] Skip test temporarily until headingLevel is added in engine (issue 41� (flutter/flutter#135077) 2024-03-11 [email protected] Roll Flutter Engine from 3b0b59bb224d to 9196947bc687 (1 revision) (flutter/flutter#144934) 2024-03-11 [email protected] Roll Packages from 0badb43 to d489d84 (3 revisions) (flutter/flutter#144931) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…es" (#144958) Relands #144752, which had to be reverted because the branch was stale. The original branch branched off `master` before #144734 landed. That PR introduced a new `AssetTransformer` call site. This PR branch is identical to the original but with a new commit that addresses the new call site, [update new call sites](6bb5296).
…es" (flutter#144958) Relands flutter#144752, which had to be reverted because the branch was stale. The original branch branched off `master` before flutter#144734 landed. That PR introduced a new `AssetTransformer` call site. This PR branch is identical to the original but with a new commit that addresses the new call site, [update new call sites](flutter@6bb5296).
In service of #143348
When invoking a package to transform an asset, we set
FLUTTER_BUILD_MODEto the CLI name of the build mode being used. Inspired by #101077 (comment):Note for the reviewer: the interesting part of this change can be found in the commit set environment variable to build mode when running asset transformer…. The rest of the change is updating call sites with a new argument.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.