Unverified Commit c38ac448 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Eliminate unnecessary AOT build wrapper function (#17027)

Inlines the buildAotSnapshot function, which simply passes through its
arguments to Snapshotter.buildAotSnapshot.
parent ebcd08c6
...@@ -65,16 +65,28 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -65,16 +65,28 @@ class BuildAotCommand extends BuildSubCommand {
status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...', status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...',
expectSlowOperation: true); expectSlowOperation: true);
} }
final String outputPath = await buildAotSnapshot( final String outputPath = argResults['output-dir'] ?? getAotBuildDirectory();
findMainDartFile(targetFile), try {
platform, final Snapshotter snapshotter = new Snapshotter();
getBuildMode(), final int snapshotExitCode = await snapshotter.buildAotSnapshot(
outputPath: argResults['output-dir'], platform: platform,
buildMode: getBuildMode(),
mainPath: findMainDartFile(targetFile),
depfilePath: 'depFilePathGoesHere',
packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath,
previewDart2: argResults['preview-dart-2'], previewDart2: argResults['preview-dart-2'],
preferSharedLibrary: argResults['prefer-shared-library'],
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions], extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions], extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions],
preferSharedLibrary: argResults['prefer-shared-library'],
); );
if (snapshotExitCode != 0) {
printError('Snapshotting exited with non-zero exit code: $snapshotExitCode');
}
} on String catch (error) {
// Catch the String exceptions thrown from the `runCheckedSync` methods below.
printError(error);
}
status?.stop(); status?.stop();
if (outputPath == null) if (outputPath == null)
...@@ -88,42 +100,3 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -88,42 +100,3 @@ class BuildAotCommand extends BuildSubCommand {
} }
} }
} }
/// Build an AOT snapshot. Return null (and log to `printError`) if the method
/// fails.
Future<String> buildAotSnapshot(
String mainPath,
TargetPlatform platform,
BuildMode buildMode, {
String outputPath,
bool previewDart2: false,
List<String> extraFrontEndOptions,
List<String> extraGenSnapshotOptions,
bool preferSharedLibrary: false,
}) async {
outputPath ??= getAotBuildDirectory();
try {
final Snapshotter snapshotter = new Snapshotter();
final int snapshotExitCode = await snapshotter.buildAotSnapshot(
platform: platform,
buildMode: buildMode,
mainPath: mainPath,
depfilePath: 'depFilePathGoesHere',
packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath,
previewDart2: previewDart2,
preferSharedLibrary: preferSharedLibrary,
extraFrontEndOptions: extraFrontEndOptions,
extraGenSnapshotOptions: extraGenSnapshotOptions,
);
if (snapshotExitCode != 0) {
printError('Snapshotting exited with non-zero exit code: $snapshotExitCode');
return null;
}
return outputPath;
} on String catch (error) {
// Catch the String exceptions thrown from the `runCheckedSync` methods below.
printError(error);
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment