Use arm deploy (#3374)

* download android-arm-deploy

* wire up --deploy to android-arm-deploy

* fix interpolation
This commit is contained in:
Devon Carew 2016-04-18 09:01:43 -07:00
parent f132acaf1d
commit 12cac94cda
12 changed files with 83 additions and 72 deletions

View File

@ -1 +1 @@
c3504b519fcd95179ea832460758712ecd0e433d 57043227981727ae8ceb1d51514a2e0d14bf53f9

View File

@ -48,7 +48,6 @@ export PATH="$DART_SDK_PATH/bin:$PATH"
set +e set +e
if [ $FLUTTER_DEV ]; then if [ $FLUTTER_DEV ]; then
echo -e "(FLUTTER_DEV set - ignoring $SNAPSHOT_PATH)\n"
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" "$@" "$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" "$@"
else else
"$DART" "$SNAPSHOT_PATH" "$@" "$DART" "$SNAPSHOT_PATH" "$@"

View File

@ -214,7 +214,7 @@ class _AnsiStatus extends Status {
_AnsiStatus(this.message) { _AnsiStatus(this.message) {
stopwatch = new Stopwatch()..start(); stopwatch = new Stopwatch()..start();
stdout.write('${message.padRight(44)} '); stdout.write('${message.padRight(50)} ');
stdout.write('${_progress[0]}'); stdout.write('${_progress[0]}');
timer = new Timer.periodic(new Duration(milliseconds: 100), _callback); timer = new Timer.periodic(new Duration(milliseconds: 100), _callback);

View File

@ -184,18 +184,31 @@ class FlutterEngine {
final Cache cache; final Cache cache;
List<String> _getPackageDirs() => <String>['sky_engine', 'sky_services'];
List<String> _getEngineDirs() { List<String> _getEngineDirs() {
List<String> dirs = <String>['android-arm', 'android-x64']; List<String> dirs = <String>[
'android-arm',
'android-arm-deploy',
'android-x64'
];
if (Platform.isMacOS) if (Platform.isMacOS)
dirs.addAll(<String>['ios', 'darwin-x64']); dirs.add('ios');
else if (Platform.isLinux) else if (Platform.isLinux)
dirs.add('linux-x64'); dirs.add('linux-x64');
return dirs; return dirs;
} }
List<String> _getPackageDirs() => <String>['sky_engine', 'sky_services']; List<String> _getToolsDirs() {
if (Platform.isMacOS)
return <String>['darwin-x64'];
else if (Platform.isLinux)
return <String>['linux-x64'];
else
return <String>[];
}
bool isUpToDate() { bool isUpToDate() {
Directory pkgDir = cache.getCacheDir('pkg'); Directory pkgDir = cache.getCacheDir('pkg');
@ -212,6 +225,12 @@ class FlutterEngine {
return false; return false;
} }
for (String dirName in _getToolsDirs()) {
Directory dir = new Directory(path.join(engineDir.path, dirName));
if (!dir.existsSync())
return false;
}
return cache.getVersionFor(kName) == cache.getStampFor(kName); return cache.getVersionFor(kName) == cache.getStampFor(kName);
} }
@ -236,6 +255,14 @@ class FlutterEngine {
if (!dir.existsSync() || allDirty) { if (!dir.existsSync() || allDirty) {
await _downloadItem('Downloading engine artifacts $dirName...', await _downloadItem('Downloading engine artifacts $dirName...',
url + dirName + '/artifacts.zip', dir); url + dirName + '/artifacts.zip', dir);
}
}
for (String dirName in _getToolsDirs()) {
Directory dir = new Directory(path.join(engineDir.path, dirName));
if (!dir.existsSync() || allDirty) {
await _downloadItem('Downloading engine tools $dirName...',
url + dirName + '/artifacts.zip', dir);
_makeFilesExecutable(dir); _makeFilesExecutable(dir);
} }
} }

View File

@ -8,7 +8,6 @@ import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../android/android_sdk.dart'; import '../android/android_sdk.dart';
import '../artifacts.dart';
import '../base/file_system.dart' show ensureDirectoryExists; import '../base/file_system.dart' show ensureDirectoryExists;
import '../base/os.dart'; import '../base/os.dart';
import '../base/process.dart'; import '../base/process.dart';
@ -207,8 +206,6 @@ class BuildApkCommand extends FlutterCommand {
TargetPlatform.android_arm, TargetPlatform.android_arm,
variant, variant,
toolchain: toolchain, toolchain: toolchain,
configs: buildConfigurations,
enginePath: runner.enginePath,
force: true, force: true,
manifest: argResults['manifest'], manifest: argResults['manifest'],
resources: argResults['resources'], resources: argResults['resources'],
@ -227,51 +224,43 @@ class BuildApkCommand extends FlutterCommand {
Future<_ApkComponents> _findApkComponents( Future<_ApkComponents> _findApkComponents(
TargetPlatform platform, TargetPlatform platform,
BuildConfiguration config, BuildVariant buildVariant,
String enginePath,
String manifest, String manifest,
String resources, String resources
BuildVariant buildVariant
) async { ) async {
// TODO(devoncarew): Get the right artifacts for [buildVariant].
List<String> artifactPaths;
if (enginePath != null) {
String abiDir = platform == TargetPlatform.android_arm ? 'armeabi-v7a' : 'x86_64';
artifactPaths = [
'$enginePath/third_party/icu/android/icudtl.dat',
'${config.buildDir}/gen/sky/shell/shell/classes.dex.jar',
'${config.buildDir}/gen/sky/shell/shell/shell/libs/$abiDir/libsky_shell.so',
'$enginePath/build/android/ant/chromium-debug.keystore',
];
} else {
List<ArtifactType> artifactTypes = <ArtifactType>[
ArtifactType.androidIcuData,
ArtifactType.androidClassesJar,
ArtifactType.androidLibSkyShell,
ArtifactType.androidKeystore,
];
artifactPaths = artifactTypes.map((ArtifactType type) {
return ArtifactStore.getPath(ArtifactStore.getArtifact(
type: type,
targetPlatform: config.targetPlatform
));
}).toList();
}
_ApkComponents components = new _ApkComponents(); _ApkComponents components = new _ApkComponents();
components.manifest = new File(manifest); components.manifest = new File(manifest);
components.icuData = new File(artifactPaths[0]);
components.jars = [new File(artifactPaths[1])];
components.libSkyShell = new File(artifactPaths[2]);
components.debugKeystore = new File(artifactPaths[3]);
components.resources = resources == null ? null : new Directory(resources); components.resources = resources == null ? null : new Directory(resources);
if (tools.isLocalEngine) {
String abiDir = platform == TargetPlatform.android_arm ? 'armeabi-v7a' : 'x86_64';
String enginePath = tools.engineSrcPath;
String buildDir = tools.getEngineArtifactsDirectory(platform, buildVariant).path;
components.icuData = new File('$enginePath/third_party/icu/android/icudtl.dat');
components.jars = <File>[
new File('$buildDir/gen/sky/shell/shell/classes.dex.jar')
];
components.libSkyShell = new File('$buildDir/gen/sky/shell/shell/shell/libs/$abiDir/libsky_shell.so');
components.debugKeystore = new File('$enginePath/build/android/ant/chromium-debug.keystore');
} else {
Directory artifacts = tools.getEngineArtifactsDirectory(platform, buildVariant);
components.icuData = new File(path.join(artifacts.path, 'icudtl.dat'));
components.jars = <File>[
new File(path.join(artifacts.path, 'classes.dex.jar'))
];
components.libSkyShell = new File(path.join(artifacts.path, 'libsky_shell.so'));
components.debugKeystore = new File(path.join(artifacts.path, 'chromium-debug.keystore'));
}
await parseServiceConfigs(components.services, jars: components.jars); await parseServiceConfigs(components.services, jars: components.jars);
for (File file in <File>[ List<File> allFiles = <File>[
components.manifest, components.icuData, components.libSkyShell, components.debugKeystore components.manifest, components.icuData, components.libSkyShell, components.debugKeystore
]..addAll(components.jars)) { ]..addAll(components.jars);
for (File file in allFiles) {
if (!file.existsSync()) { if (!file.existsSync()) {
printError('Cannot locate file: ${file.path}'); printError('Cannot locate file: ${file.path}');
return null; return null;
@ -333,7 +322,8 @@ int _buildApk(
File apkShaFile = new File('$outputFile.sha1'); File apkShaFile = new File('$outputFile.sha1');
apkShaFile.writeAsStringSync(calculateSha(finalApk)); apkShaFile.writeAsStringSync(calculateSha(finalApk));
printStatus('Generated APK to ${finalApk.path}.'); double size = finalApk.lengthSync() / (1024 * 1024);
printStatus('Built ${finalApk.path} (${size.toStringAsFixed(1)}MB).');
return 0; return 0;
} finally { } finally {
@ -403,8 +393,6 @@ Future<int> buildAndroid(
TargetPlatform platform, TargetPlatform platform,
BuildVariant buildVariant, { BuildVariant buildVariant, {
Toolchain toolchain, Toolchain toolchain,
List<BuildConfiguration> configs,
String enginePath,
bool force: false, bool force: false,
String manifest: _kDefaultAndroidManifestPath, String manifest: _kDefaultAndroidManifestPath,
String resources, String resources,
@ -441,17 +429,17 @@ Future<int> buildAndroid(
resources = _kDefaultResourcesPath; resources = _kDefaultResourcesPath;
} }
BuildConfiguration config = configs.firstWhere((BuildConfiguration bc) => bc.targetPlatform == platform);
_ApkComponents components = await _findApkComponents( _ApkComponents components = await _findApkComponents(
platform, config, enginePath, manifest, resources, buildVariant platform, buildVariant, manifest, resources
); );
if (components == null) { if (components == null) {
printError('Failure building APK. Unable to find components.'); printError('Failure building APK: unable to find components.');
return 1; return 1;
} }
printStatus('Building APK in ${getVariantName(buildVariant)} mode...'); String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, buildVariant).path);
printStatus('Building APK in ${getVariantName(buildVariant)} mode ($typeName)...');
if (flxPath != null && flxPath.isNotEmpty) { if (flxPath != null && flxPath.isNotEmpty) {
if (!FileSystemEntity.isFileSync(flxPath)) { if (!FileSystemEntity.isFileSync(flxPath)) {
@ -475,14 +463,12 @@ Future<int> buildAndroid(
Future<int> buildApk( Future<int> buildApk(
TargetPlatform platform, TargetPlatform platform,
Toolchain toolchain, Toolchain toolchain, {
List<BuildConfiguration> configs, {
String enginePath,
String target, String target,
BuildVariant buildVariant: BuildVariant.develop BuildVariant buildVariant: BuildVariant.develop
}) async { }) async {
if (!FileSystemEntity.isFileSync(_kDefaultAndroidManifestPath)) { if (!FileSystemEntity.isFileSync(_kDefaultAndroidManifestPath)) {
printError('Cannot build APK. Missing $_kDefaultAndroidManifestPath.'); printError('Cannot build APK: missing $_kDefaultAndroidManifestPath.');
return 1; return 1;
} }
@ -490,8 +476,6 @@ Future<int> buildApk(
platform, platform,
buildVariant, buildVariant,
toolchain: toolchain, toolchain: toolchain,
configs: configs,
enginePath: enginePath,
force: false, force: false,
target: target target: target
); );

View File

@ -30,7 +30,7 @@ class BuildIOSCommand extends FlutterCommand {
return 1; return 1;
} }
IOSApp app = applicationPackages.iOS; IOSApp app = applicationPackages.getPackageForPlatform(TargetPlatform.ios);
if (app == null) { if (app == null) {
printError('Application not configured for iOS'); printError('Application not configured for iOS');
@ -47,7 +47,7 @@ class BuildIOSCommand extends FlutterCommand {
String logTarget = forSimulator ? "simulator" : "device"; String logTarget = forSimulator ? "simulator" : "device";
printStatus('Building the application for $logTarget.'); printStatus('Building $app for $logTarget...');
bool result = await buildIOSXcodeProject(app, bool result = await buildIOSXcodeProject(app,
buildForDevice: !forSimulator, codesign: shouldCodesign); buildForDevice: !forSimulator, codesign: shouldCodesign);

View File

@ -265,7 +265,6 @@ class AppDomain extends Domain {
int result = await startApp( int result = await startApp(
device, device,
command.toolchain, command.toolchain,
command.buildConfigurations,
stop: true, stop: true,
target: args['target'], target: args['target'],
route: args['route'], route: args['route'],

View File

@ -243,8 +243,9 @@ Future<int> startApp(DriveCommand command) async {
if (command.device is AndroidDevice) { if (command.device is AndroidDevice) {
printTrace('Building an APK.'); printTrace('Building an APK.');
int result = await build_apk.buildApk( int result = await build_apk.buildApk(
command.device.platform, command.toolchain, command.buildConfigurations, command.device.platform,
enginePath: command.runner.enginePath, target: command.target command.toolchain,
target: command.target
); );
if (result != 0) if (result != 0)

View File

@ -59,7 +59,6 @@ class ListenCommand extends RunCommandBase {
result = await startApp( result = await startApp(
deviceForCommand, deviceForCommand,
toolchain, toolchain,
buildConfigurations,
target: target, target: target,
install: firstTime, install: firstTime,
stop: true, stop: true,

View File

@ -97,7 +97,6 @@ class RunCommand extends RunCommandBase {
int result = await startApp( int result = await startApp(
deviceForCommand, deviceForCommand,
toolchain, toolchain,
buildConfigurations,
target: target, target: target,
enginePath: runner.enginePath, enginePath: runner.enginePath,
install: true, install: true,
@ -127,8 +126,7 @@ String _getMissingPackageHintForPlatform(TargetPlatform platform) {
Future<int> startApp( Future<int> startApp(
Device device, Device device,
Toolchain toolchain, Toolchain toolchain, {
List<BuildConfiguration> configs, {
String target, String target,
String enginePath, String enginePath,
bool stop: true, bool stop: true,
@ -165,8 +163,8 @@ Future<int> startApp(
printTrace('Running build command.'); printTrace('Running build command.');
int result = await buildApk( int result = await buildApk(
device.platform, toolchain, configs, device.platform,
enginePath: enginePath, toolchain,
target: target, target: target,
buildVariant: BuildVariant.develop buildVariant: BuildVariant.develop
); );

View File

@ -98,6 +98,8 @@ class ToolConfiguration {
/// Used to override the directory calculated from engineSrcPath (--engine-out-dir). /// Used to override the directory calculated from engineSrcPath (--engine-out-dir).
String engineOutDir; String engineOutDir;
bool get isLocalEngine => engineSrcPath != null || engineOutDir != null;
String get _modeStr => release ? 'Release' : 'Debug'; String get _modeStr => release ? 'Release' : 'Debug';
/// The directory that contains development tools for the given platform. This /// The directory that contains development tools for the given platform. This
@ -159,9 +161,11 @@ class ToolConfiguration {
// Return something like 'out/android_Release'. // Return something like 'out/android_Release'.
return new Directory(path.join(engineSrcPath, 'out/${type}_$_modeStr')); return new Directory(path.join(engineSrcPath, 'out/${type}_$_modeStr'));
} else { } else {
// TODO(devoncarew): We'll want to suffix the directory name with the variant. // For now, only suffix for deploy variants.
String suffix = variant == BuildVariant.deploy ? '-${getVariantName(variant)}' : '';
String dirName = getNameForTargetPlatform(platform); // Create something like `android-arm` or `android-arm-deploy`.
String dirName = getNameForTargetPlatform(platform) + suffix;
Directory engineDir = _cache.getArtifactDirectory('engine'); Directory engineDir = _cache.getArtifactDirectory('engine');
return new Directory(path.join(engineDir.path, dirName)); return new Directory(path.join(engineDir.path, dirName));
} }

View File

@ -38,7 +38,7 @@ void main() {
); );
expect( expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildVariant.deploy).path, toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildVariant.deploy).path,
endsWith('cache/artifacts/engine/android-arm') endsWith('cache/artifacts/engine/android-arm-deploy')
); );
}); });