Commit 4aba536a authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Support x86/x64 targets in the build apk command (#5660)

Fixes https://github.com/flutter/flutter/issues/5592
parent a4c9adfb
...@@ -181,6 +181,10 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -181,6 +181,10 @@ class BuildApkCommand extends BuildSubCommand {
argParser.addOption('flx', argParser.addOption('flx',
abbr: 'f', abbr: 'f',
help: 'Path to the FLX file. If this is not provided, an FLX will be built.'); help: 'Path to the FLX file. If this is not provided, an FLX will be built.');
argParser.addOption('target-arch',
defaultsTo: 'arm',
allowed: <String>['arm', 'x86', 'x64'],
help: 'Architecture of the target device.');
argParser.addOption('aot-path', argParser.addOption('aot-path',
help: 'Path to the ahead-of-time compiled snapshot directory.\n' help: 'Path to the ahead-of-time compiled snapshot directory.\n'
'If this is not provided, an AOT snapshot will be built.'); 'If this is not provided, an AOT snapshot will be built.');
...@@ -203,19 +207,42 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -203,19 +207,42 @@ class BuildApkCommand extends BuildSubCommand {
'debugging and a quick development cycle. \'release\' builds don\'t support debugging and are\n' 'debugging and a quick development cycle. \'release\' builds don\'t support debugging and are\n'
'suitable for deploying to app stores.'; 'suitable for deploying to app stores.';
TargetPlatform _getTargetPlatform(String targetArch) {
switch (targetArch) {
case 'arm':
return TargetPlatform.android_arm;
case 'x86':
return TargetPlatform.android_x86;
case 'x64':
return TargetPlatform.android_x64;
default:
throw new Exception('Unrecognized target architecture: $targetArch');
}
}
@override @override
Future<int> runInProject() async { Future<int> runInProject() async {
await super.runInProject(); await super.runInProject();
TargetPlatform targetPlatform = _getTargetPlatform(argResults['target-arch']);
if (targetPlatform != TargetPlatform.android_arm && getBuildMode() != BuildMode.debug) {
printError('Profile and release builds are only supported on ARM targets.');
return 1;
}
if (isProjectUsingGradle()) { if (isProjectUsingGradle()) {
if (targetPlatform != TargetPlatform.android_arm) {
printError('Gradle builds only support ARM targets.');
return 1;
}
return await buildAndroidWithGradle( return await buildAndroidWithGradle(
TargetPlatform.android_arm, TargetPlatform.android_arm,
getBuildMode(), getBuildMode(),
target: targetFile target: targetFile
); );
} else { } else {
// TODO(devoncarew): This command should take an arg for the output type (arm / x64).
return await buildAndroid( return await buildAndroid(
TargetPlatform.android_arm, targetPlatform,
getBuildMode(), getBuildMode(),
force: true, force: true,
manifest: argResults['manifest'], manifest: argResults['manifest'],
......
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