forked from firka/flutter
[flutter_tool] ensure extraGenSnapshotArguments are forwarded to gen_snapshot from Android builds (#47059)
This commit is contained in:
@@ -208,6 +208,8 @@ class AndroidAot extends AotElfBase {
|
||||
if (!output.existsSync()) {
|
||||
output.createSync(recursive: true);
|
||||
}
|
||||
final List<String> extraGenSnapshotOptions = environment.defines[kExtraGenSnapshotOptions]?.split(',')
|
||||
?? const <String>[];
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final int snapshotExitCode = await snapshotter.build(
|
||||
platform: targetPlatform,
|
||||
@@ -216,6 +218,7 @@ class AndroidAot extends AotElfBase {
|
||||
packagesPath: environment.projectDir.childFile('.packages').path,
|
||||
outputPath: output.path,
|
||||
bitcode: false,
|
||||
extraGenSnapshotOptions: extraGenSnapshotOptions,
|
||||
);
|
||||
if (snapshotExitCode != 0) {
|
||||
throw Exception('AOT snapshotter exited with code $snapshotExitCode');
|
||||
|
||||
@@ -253,6 +253,8 @@ abstract class AotElfBase extends Target {
|
||||
if (environment.defines[kTargetPlatform] == null) {
|
||||
throw MissingDefineException(kTargetPlatform, 'aot_elf');
|
||||
}
|
||||
final List<String> extraGenSnapshotOptions = environment.defines[kExtraGenSnapshotOptions]?.split(',')
|
||||
?? const <String>[];
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
|
||||
final int snapshotExitCode = await snapshotter.build(
|
||||
@@ -262,6 +264,7 @@ abstract class AotElfBase extends Target {
|
||||
packagesPath: environment.projectDir.childFile('.packages').path,
|
||||
outputPath: outputPath,
|
||||
bitcode: false,
|
||||
extraGenSnapshotOptions: extraGenSnapshotOptions,
|
||||
);
|
||||
if (snapshotExitCode != 0) {
|
||||
throw Exception('AOT snapshotter exited with code $snapshotExitCode');
|
||||
|
||||
@@ -77,6 +77,7 @@ class AssembleCommand extends FlutterCommand {
|
||||
'files will be written. Must be either absolute or relative from the '
|
||||
'root of the current Flutter project.',
|
||||
);
|
||||
argParser.addOption(kExtraGenSnapshotOptions);
|
||||
argParser.addOption(
|
||||
'resource-pool-size',
|
||||
help: 'The maximum number of concurrent tasks the build system will run.',
|
||||
@@ -150,17 +151,21 @@ class AssembleCommand extends FlutterCommand {
|
||||
return result;
|
||||
}
|
||||
|
||||
static Map<String, String> _parseDefines(List<String> values) {
|
||||
Map<String, String> _parseDefines(List<String> values) {
|
||||
final Map<String, String> results = <String, String>{};
|
||||
for (String chunk in values) {
|
||||
final List<String> parts = chunk.split('=');
|
||||
if (parts.length != 2) {
|
||||
final int indexEquals = chunk.indexOf('=');
|
||||
if (indexEquals == -1) {
|
||||
throwToolExit('Improperly formatted define flag: $chunk');
|
||||
}
|
||||
final String key = parts[0];
|
||||
final String value = parts[1];
|
||||
final String key = chunk.substring(0, indexEquals);
|
||||
final String value = chunk.substring(indexEquals + 1);
|
||||
results[key] = value;
|
||||
}
|
||||
// Workaround for extraGenSnapshot formatting.
|
||||
if (argResults.wasParsed(kExtraGenSnapshotOptions)) {
|
||||
results[kExtraGenSnapshotOptions] = argResults[kExtraGenSnapshotOptions] as String;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user