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:
@@ -15,7 +15,6 @@ import '../../devfs.dart';
|
||||
import '../../flutter_manifest.dart';
|
||||
import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
import '../exceptions.dart';
|
||||
import '../tools/asset_transformer.dart';
|
||||
import '../tools/scene_importer.dart';
|
||||
import '../tools/shader_compiler.dart';
|
||||
@@ -36,7 +35,7 @@ Future<Depfile> copyAssets(
|
||||
Directory outputDirectory, {
|
||||
Map<String, DevFSContent> additionalContent = const <String, DevFSContent>{},
|
||||
required TargetPlatform targetPlatform,
|
||||
required BuildMode buildMode,
|
||||
BuildMode? buildMode,
|
||||
List<File> additionalInputs = const <File>[],
|
||||
String? flavor,
|
||||
}) async {
|
||||
@@ -102,7 +101,6 @@ Future<Depfile> copyAssets(
|
||||
processManager: environment.processManager,
|
||||
fileSystem: environment.fileSystem,
|
||||
dartBinaryPath: environment.artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
buildMode: buildMode,
|
||||
);
|
||||
|
||||
final Map<String, AssetBundleEntry> assetEntries = <String, AssetBundleEntry>{
|
||||
@@ -188,7 +186,7 @@ Future<Depfile> copyAssets(
|
||||
// Copy deferred components assets only for release or profile builds.
|
||||
// The assets are included in assetBundle.entries as a normal asset when
|
||||
// building as debug.
|
||||
if (environment.defines[kDeferredComponents] == 'true') {
|
||||
if (environment.defines[kDeferredComponents] == 'true' && buildMode != null) {
|
||||
await Future.wait<void>(assetBundle.deferredComponentsEntries.entries.map<Future<void>>(
|
||||
(MapEntry<String, Map<String, AssetBundleEntry>> componentEntries) async {
|
||||
final Directory componentOutputDir =
|
||||
@@ -345,11 +343,6 @@ class CopyAssets extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = BuildMode.fromCliName(buildModeEnvironment);
|
||||
final Directory output = environment
|
||||
.buildDir
|
||||
.childDirectory('flutter_assets');
|
||||
@@ -358,7 +351,6 @@ class CopyAssets extends Target {
|
||||
environment,
|
||||
output,
|
||||
targetPlatform: TargetPlatform.android,
|
||||
buildMode: buildMode,
|
||||
flavor: environment.defines[kFlavor],
|
||||
);
|
||||
environment.depFileService.writeToFile(
|
||||
|
||||
@@ -503,7 +503,6 @@ abstract class IosAssetBundle extends Target {
|
||||
environment,
|
||||
assetDirectory,
|
||||
targetPlatform: TargetPlatform.ios,
|
||||
buildMode: buildMode,
|
||||
additionalInputs: <File>[
|
||||
flutterProject.ios.infoPlist,
|
||||
flutterProject.ios.appFrameworkInfoPlist,
|
||||
|
||||
@@ -137,7 +137,6 @@ abstract class BundleLinuxAssets extends Target {
|
||||
environment,
|
||||
outputDirectory,
|
||||
targetPlatform: targetPlatform,
|
||||
buildMode: buildMode,
|
||||
additionalContent: <String, DevFSContent>{
|
||||
'version.json': DevFSStringContent(versionInfo),
|
||||
},
|
||||
|
||||
@@ -438,7 +438,6 @@ abstract class MacOSBundleFlutterAssets extends Target {
|
||||
environment,
|
||||
assetDirectory,
|
||||
targetPlatform: TargetPlatform.darwin,
|
||||
buildMode: buildMode,
|
||||
flavor: environment.defines[kFlavor],
|
||||
);
|
||||
environment.depFileService.writeToFile(
|
||||
|
||||
@@ -380,21 +380,13 @@ class WebReleaseBundle extends Target {
|
||||
}
|
||||
}
|
||||
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = BuildMode.fromCliName(buildModeEnvironment);
|
||||
|
||||
createVersionFile(environment, environment.defines);
|
||||
final Directory outputDirectory = environment.outputDir.childDirectory('assets');
|
||||
outputDirectory.createSync(recursive: true);
|
||||
|
||||
final Depfile depfile = await copyAssets(
|
||||
environment,
|
||||
environment.outputDir.childDirectory('assets'),
|
||||
targetPlatform: TargetPlatform.web_javascript,
|
||||
buildMode: buildMode,
|
||||
);
|
||||
final DepfileService depfileService = environment.depFileService;
|
||||
depfileService.writeToFile(
|
||||
|
||||
@@ -142,7 +142,6 @@ abstract class BundleWindowsAssets extends Target {
|
||||
environment,
|
||||
outputDirectory,
|
||||
targetPlatform: targetPlatform,
|
||||
buildMode: buildMode,
|
||||
);
|
||||
environment.depFileService.writeToFile(
|
||||
depfile,
|
||||
|
||||
@@ -12,7 +12,6 @@ import '../../base/error_handling_io.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/io.dart';
|
||||
import '../../base/logger.dart';
|
||||
import '../../build_info.dart';
|
||||
import '../../devfs.dart';
|
||||
import '../../flutter_manifest.dart';
|
||||
import '../build_system.dart';
|
||||
@@ -23,18 +22,13 @@ final class AssetTransformer {
|
||||
required ProcessManager processManager,
|
||||
required FileSystem fileSystem,
|
||||
required String dartBinaryPath,
|
||||
required BuildMode buildMode,
|
||||
}) : _processManager = processManager,
|
||||
_fileSystem = fileSystem,
|
||||
_dartBinaryPath = dartBinaryPath,
|
||||
_buildMode = buildMode;
|
||||
|
||||
static const String buildModeEnvVar = 'FLUTTER_BUILD_MODE';
|
||||
_dartBinaryPath = dartBinaryPath;
|
||||
|
||||
final ProcessManager _processManager;
|
||||
final FileSystem _fileSystem;
|
||||
final String _dartBinaryPath;
|
||||
final BuildMode _buildMode;
|
||||
|
||||
/// The [Source] inputs that targets using this should depend on.
|
||||
///
|
||||
@@ -121,9 +115,6 @@ final class AssetTransformer {
|
||||
final ProcessResult result = await _processManager.run(
|
||||
command,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: <String, String>{
|
||||
AssetTransformer.buildModeEnvVar: _buildMode.cliName,
|
||||
}
|
||||
);
|
||||
final String stdout = result.stdout as String;
|
||||
final String stderr = result.stderr as String;
|
||||
|
||||
@@ -442,7 +442,6 @@ class DevFS {
|
||||
required FileSystem fileSystem,
|
||||
required ProcessManager processManager,
|
||||
required Artifacts artifacts,
|
||||
required BuildMode buildMode,
|
||||
HttpClient? httpClient,
|
||||
Duration? uploadRetryThrottle,
|
||||
StopwatchFactory stopwatchFactory = const StopwatchFactory(),
|
||||
@@ -466,7 +465,6 @@ class DevFS {
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
dartBinaryPath: artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
buildMode: buildMode,
|
||||
),
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
|
||||
@@ -387,7 +387,6 @@ class FlutterDevice {
|
||||
logger: globals.logger,
|
||||
processManager: globals.processManager,
|
||||
artifacts: globals.artifacts!,
|
||||
buildMode: buildInfo.mode,
|
||||
);
|
||||
return devFS!.create();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user