Reverts "Expose build mode in environment of asset transformer processes (#144752)" (#144957)

Reverts: flutter/flutter#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 https://github.com/flutter/flutter/issues/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 https://github.com/flutter/flutter/issues/101077#issuecomment-1890379501:

> 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…](579912d470). The rest of the change is updating call sites with a new argument.
This commit is contained in:
auto-submit[bot]
2024-03-11 21:00:17 +00:00
committed by GitHub
parent 83fad74535
commit 187ec75eb5
13 changed files with 9 additions and 70 deletions

View File

@@ -8,7 +8,6 @@ import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/tools/asset_transformer.dart';
import 'package:flutter_tools/src/flutter_manifest.dart';
@@ -54,7 +53,6 @@ void main() {
processManager: processManager,
fileSystem: fileSystem,
dartBinaryPath: artifacts.getArtifactPath(Artifact.engineDartBinary),
buildMode: BuildMode.debug,
);
final AssetTransformationFailure? transformationFailure = await transformer.transformAsset(
@@ -114,7 +112,6 @@ void main() {
processManager: processManager,
fileSystem: fileSystem,
dartBinaryPath: dartBinaryPath,
buildMode: BuildMode.debug,
);
final AssetTransformationFailure? failure = await transformer.transformAsset(
@@ -174,7 +171,6 @@ Something went wrong''');
processManager: processManager,
fileSystem: fileSystem,
dartBinaryPath: dartBinaryPath,
buildMode: BuildMode.debug,
);
final AssetTransformationFailure? failure = await transformer.transformAsset(
@@ -269,7 +265,6 @@ Transformation failed, but I forgot to exit with a non-zero code.'''
processManager: processManager,
fileSystem: fileSystem,
dartBinaryPath: dartBinaryPath,
buildMode: BuildMode.debug,
);
final AssetTransformationFailure? failure = await transformer.transformAsset(
@@ -336,10 +331,7 @@ Transformation failed, but I forgot to exit with a non-zero code.'''
onRun: (List<String> args) {
// Do nothing.
},
stderr: 'Transformation failed, but I forgot to exit with a non-zero code.',
environment: const <String, String>{
'FLUTTER_BUILD_MODE': 'debug',
},
stderr: 'Transformation failed, but I forgot to exit with a non-zero code.'
),
]);
@@ -347,7 +339,6 @@ Transformation failed, but I forgot to exit with a non-zero code.'''
processManager: processManager,
fileSystem: fileSystem,
dartBinaryPath: dartBinaryPath,
buildMode: BuildMode.debug,
);
final AssetTransformationFailure? failure = await transformer.transformAsset(

View File

@@ -38,9 +38,7 @@ void main() {
fileSystem: fileSystem,
logger: BufferLogger.test(),
platform: FakePlatform(),
defines: <String, String>{
kBuildMode: BuildMode.debug.cliName,
},
defines: <String, String>{},
);
fileSystem.file(environment.buildDir.childFile('app.dill')).createSync(recursive: true);
fileSystem.file('packages/flutter_tools/lib/src/build_system/targets/assets.dart')
@@ -180,9 +178,7 @@ flutter:
fileSystem: fileSystem,
logger: logger,
platform: globals.platform,
defines: <String, String>{
kBuildMode: BuildMode.debug.cliName,
},
defines: <String, String>{},
);
await fileSystem.file('.packages').create();
@@ -266,9 +262,7 @@ flutter:
fileSystem: fileSystem,
logger: logger,
platform: globals.platform,
defines: <String, String>{
kBuildMode: BuildMode.debug.cliName,
},
defines: <String, String>{},
);
await fileSystem.file('.packages').create();

View File

@@ -68,7 +68,6 @@ void main() {
outputDir: globals.fs.currentDirectory.childDirectory('bar'),
defines: <String, String>{
kTargetFile: globals.fs.path.join('foo', 'lib', 'main.dart'),
kBuildMode: BuildMode.debug.cliName,
},
artifacts: Artifacts.test(),
processManager: processManager,

View File

@@ -135,7 +135,6 @@ void main() {
httpClient: FakeHttpClient.any(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
expect(() async => devFS.create(), throwsA(isA<DevFSException>()));
});
@@ -161,7 +160,6 @@ void main() {
httpClient: FakeHttpClient.any(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
expect(await devFS.create(), isNotNull);
@@ -212,7 +210,6 @@ void main() {
uploadRetryThrottle: Duration.zero,
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -248,7 +245,6 @@ void main() {
httpClient: FakeHttpClient.any(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -291,7 +287,6 @@ void main() {
httpClient: FakeHttpClient.any(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -336,7 +331,6 @@ void main() {
httpClient: HttpClient(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -388,7 +382,6 @@ void main() {
httpClient: FakeHttpClient.any(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -468,7 +461,6 @@ void main() {
}),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -515,7 +507,6 @@ void main() {
httpClient: FakeHttpClient.any(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -621,8 +612,7 @@ void main() {
httpClient: FakeHttpClient.any(),
config: Config.test(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
artifacts: Artifacts.test(),
);
await devFS.create();
@@ -680,8 +670,7 @@ void main() {
httpClient: FakeHttpClient.any(),
config: Config.test(),
processManager: FakeProcessManager.empty(),
artifacts: Artifacts.test(),
buildMode: BuildMode.debug,
artifacts: Artifacts.test(),
);
await devFS.create();
@@ -774,7 +763,6 @@ void main() {
config: Config.test(),
processManager: processManager,
artifacts: artifacts,
buildMode: BuildMode.debug,
);
await devFS.create();
@@ -855,7 +843,6 @@ void main() {
config: Config.test(),
processManager: processManager,
artifacts: artifacts,
buildMode: BuildMode.debug,
);
await devFS.create();