Merge branch 'master' into analysis_rework

This commit is contained in:
pq
2016-05-06 08:58:49 -07:00
25 changed files with 226 additions and 130 deletions

View File

@@ -102,7 +102,7 @@ Future<Null> main(List<String> args) async {
flutterUsage.sendException(error, chain);
if (Platform.environment.containsKey('FLUTTER_DEV')) {
if (Platform.environment.containsKey('FLUTTER_DEV') || isRunningOnBot) {
// If we're working on the tools themselves, just print the stack trace.
stderr.writeln('$error');
stderr.writeln(chain.terse.toString());

View File

@@ -49,23 +49,49 @@ class AndroidDevice extends Device {
final String modelID;
final String deviceCodeName;
Map<String, String> _properties;
bool _isLocalEmulator;
TargetPlatform _platform;
String _getProperty(String name) {
if (_properties == null) {
String getpropOutput = runCheckedSync(adbCommandForDevice(<String>['shell', 'getprop']));
RegExp propertyExp = new RegExp(r'\[(.*?)\]: \[(.*?)\]');
_properties = <String, String>{};
for (Match m in propertyExp.allMatches(getpropOutput)) {
_properties[m.group(1)] = m.group(2);
}
}
return _properties[name];
}
@override
bool get isLocalEmulator {
if (_isLocalEmulator == null) {
String characteristics = _getProperty('ro.build.characteristics');
_isLocalEmulator = characteristics != null && characteristics.contains('emulator');
}
return _isLocalEmulator;
}
@override
TargetPlatform get platform {
if (_platform == null) {
// http://developer.android.com/ndk/guides/abis.html (x86, armeabi-v7a, ...)
try {
String value = runCheckedSync(adbCommandForDevice(
<String>['shell', 'getprop', 'ro.product.cpu.abi']
));
_isLocalEmulator = value.startsWith('x86');
} catch (error) {
_isLocalEmulator = false;
switch (_getProperty('ro.product.cpu.abi')) {
case 'x86_64':
_platform = TargetPlatform.android_x64;
break;
case 'x86':
_platform = TargetPlatform.android_x86;
break;
default:
_platform = TargetPlatform.android_arm;
break;
}
}
return _isLocalEmulator;
return _platform;
}
_AdbLogReader _logReader;
@@ -123,9 +149,7 @@ class AndroidDevice extends Device {
runCheckedSync(<String>[androidSdk.adbPath, 'start-server']);
// Sample output: '22'
String sdkVersion = runCheckedSync(
adbCommandForDevice(<String>['shell', 'getprop', 'ro.build.version.sdk'])
).trimRight();
String sdkVersion = _getProperty('ro.build.version.sdk');
int sdkVersionParsed = int.parse(sdkVersion, onError: (String source) => null);
if (sdkVersionParsed == null) {
@@ -333,9 +357,6 @@ class AndroidDevice extends Device {
return runCommandAndStreamOutput(command).then((int exitCode) => exitCode == 0);
}
@override
TargetPlatform get platform => isLocalEmulator ? TargetPlatform.android_x64 : TargetPlatform.android_arm;
@override
void clearLogs() {
runSync(adbCommandForDevice(<String>['logcat', '-c']));

View File

@@ -103,6 +103,7 @@ ApplicationPackage getApplicationPackageForPlatform(TargetPlatform platform) {
switch (platform) {
case TargetPlatform.android_arm:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
return new AndroidApk.fromCurrentDirectory();
case TargetPlatform.ios:
return new IOSApp.fromCurrentDirectory();
@@ -122,6 +123,7 @@ class ApplicationPackageStore {
switch (platform) {
case TargetPlatform.android_arm:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
android ??= new AndroidApk.fromCurrentDirectory();
return android;
case TargetPlatform.ios:

View File

@@ -8,6 +8,13 @@ import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as path;
bool get isRunningOnBot {
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
return
Platform.environment['TRAVIS'] == 'true' ||
Platform.environment['CONTINUOUS_INTEGRATION'] == 'true';
}
String hex(List<int> bytes) {
StringBuffer result = new StringBuffer();
for (int part in bytes)

View File

@@ -41,6 +41,7 @@ String getNameForHostPlatform(HostPlatform platform) {
enum TargetPlatform {
android_arm,
android_x64,
android_x86,
ios,
darwin_x64,
linux_x64

View File

@@ -192,7 +192,8 @@ class FlutterEngine {
'android-arm',
'android-arm-profile',
'android-arm-release',
'android-x64'
'android-x64',
'android-x86',
];
if (Platform.isMacOS)

View File

@@ -34,15 +34,8 @@ class AnalyzeCommand extends FlutterCommand {
argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
argParser.addOption('dart-sdk', help: 'The path to the Dart SDK.', hide: true);
// Options to enable a benchmarking mode.
argParser.addFlag('benchmark',
negatable: false,
hide: true
);
argParser.addOption('benchmark-expected',
hide: true,
help: 'The time (in seconds) that the benchmark is expected to run.'
);
// Hidden option to enable a benchmarking mode.
argParser.addFlag('benchmark', negatable: false, hide: true);
usesPubOption();
}
@@ -393,19 +386,12 @@ class AnalyzeCommand extends FlutterCommand {
void _writeBenchmark(Stopwatch stopwatch, int errorCount) {
final String benchmarkOut = 'analysis_benchmark.json';
String expectedTime = argResults['benchmark-expected'];
Map<String, dynamic> data = <String, dynamic>{
'time': (stopwatch.elapsedMilliseconds / 1000.0),
'issues': errorCount
};
if (expectedTime != null)
data['expected'] = expectedTime;
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
new File(benchmarkOut).writeAsStringSync(encoder.convert(data) + '\n');
printStatus('Analysis benchmark written to $benchmarkOut.');
}
}

View File

@@ -261,6 +261,21 @@ class BuildApkCommand extends FlutterCommand {
}
}
// Return the directory name within the APK that is used for native code libraries
// on the given platform.
String getAbiDirectory(TargetPlatform platform) {
switch (platform) {
case TargetPlatform.android_arm:
return 'armeabi-v7a';
case TargetPlatform.android_x64:
return 'x86_64';
case TargetPlatform.android_x86:
return 'x86';
default:
throw new Exception('Unsupported platform.');
}
}
Future<_ApkComponents> _findApkComponents(
TargetPlatform platform,
BuildMode buildMode,
@@ -274,7 +289,7 @@ Future<_ApkComponents> _findApkComponents(
components.extraFiles = extraFiles != null ? extraFiles : <String, File>{};
if (tools.isLocalEngine) {
String abiDir = platform == TargetPlatform.android_arm ? 'armeabi-v7a' : 'x86_64';
String abiDir = getAbiDirectory(platform);
String enginePath = tools.engineSrcPath;
String buildDir = tools.getEngineArtifactsDirectory(platform, buildMode).path;
@@ -348,7 +363,7 @@ int _buildApk(
_AssetBuilder artifactBuilder = new _AssetBuilder(tempDir, 'artifacts');
artifactBuilder.add(classesDex, 'classes.dex');
String abiDir = platform == TargetPlatform.android_arm ? 'armeabi-v7a' : 'x86_64';
String abiDir = getAbiDirectory(platform);
artifactBuilder.add(components.libSkyShell, 'lib/$abiDir/libsky_shell.so');
for (String relativePath in components.extraFiles.keys)

View File

@@ -10,7 +10,7 @@ import '../base/process.dart';
import '../dart/pub.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
import '../runner/version.dart';
import '../version.dart';
class UpgradeCommand extends FlutterCommand {
@override

View File

@@ -57,7 +57,7 @@ class DeviceManager {
devices = devices.where((Device device) {
return (device.id.toLowerCase().startsWith(deviceId) ||
device.name.toLowerCase().startsWith(deviceId));
});
}).toList();
return devices.length == 1 ? devices.first : null;
}

View File

@@ -12,7 +12,7 @@ import 'base/context.dart';
import 'base/os.dart';
import 'globals.dart';
import 'ios/ios_workflow.dart';
import 'runner/version.dart';
import 'version.dart';
const Map<String, String> _osNames = const <String, String>{
'macos': 'Mac OS',

View File

@@ -18,7 +18,7 @@ import '../build_configuration.dart';
import '../globals.dart';
import '../package_map.dart';
import '../toolchain.dart';
import 'version.dart';
import '../version.dart';
const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo)
const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo)

View File

@@ -144,10 +144,9 @@ class ToolConfiguration {
switch (platform) {
case TargetPlatform.android_arm:
type = 'android';
break;
case TargetPlatform.android_x64:
type = 'android_sim';
case TargetPlatform.android_x86:
type = 'android';
break;
// TODO(devoncarew): We will need an ios vs ios_x86 target (for ios vs. ios_sim).
@@ -166,6 +165,18 @@ class ToolConfiguration {
if (isAotBuildMode(mode))
buildOutputPath += '_Deploy';
// Add a suffix for the target architecture.
switch (platform) {
case TargetPlatform.android_x64:
buildOutputPath += '_x64';
break;
case TargetPlatform.android_x86:
buildOutputPath += '_x86';
break;
default:
break;
}
return new Directory(path.join(engineSrcPath, buildOutputPath));
} else {
String suffix = mode != BuildMode.debug ? '-${getModeName(mode)}' : '';

View File

@@ -8,8 +8,9 @@ import 'package:usage/src/usage_impl_io.dart';
import 'package:usage/usage.dart';
import 'base/context.dart';
import 'base/utils.dart';
import 'globals.dart';
import 'runner/version.dart';
import 'version.dart';
// TODO(devoncarew): We'll need to do some work on the user agent in order to
// correctly track usage by operating system (dart-lang/usage/issues/70).
@@ -22,7 +23,19 @@ class Usage {
Usage() {
String version = FlutterVersion.getVersionString(whitelistBranchName: true);
_analytics = new AnalyticsIO(_kFlutterUA, 'flutter', version);
_analytics.analyticsOpt = AnalyticsOpt.optOut;
bool runningOnCI = false;
// Many CI systems don't do a full git checkout.
if (version.startsWith('unknown/'))
runningOnCI = true;
// Check for common CI systems.
if (isRunningOnBot)
runningOnCI = true;
// If we think we're running on a CI system, default to not sending analytics.
_analytics.analyticsOpt = runningOnCI ? AnalyticsOpt.optIn : AnalyticsOpt.optOut;
}
/// Returns [Usage] active in the current app context.
@@ -82,10 +95,14 @@ class Usage {
final String versionString = FlutterVersion.getVersionString(whitelistBranchName: true);
String welcomeString = 'Welcome to Flutter! - Flutter version $versionString - https://flutter.io';
welcomeString = welcomeString.padLeft((welcomeString.length + 100) ~/ 2);
welcomeString = welcomeString.padRight(100);
printStatus('');
printStatus('''
╔════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - Flutter version $versionString - https://flutter.io ║
║$welcomeString║
║ ║
║ The Flutter tool anonymously reports feature usage statistics and basic crash reports to Google in ║
║ order to help Google contribute improvements to Flutter over time. See Google's privacy policy: ║

View File

@@ -4,8 +4,8 @@
import 'dart:io';
import '../artifacts.dart';
import '../base/process.dart';
import 'artifacts.dart';
import 'base/process.dart';
final Set<String> kKnownBranchNames = new Set<String>.from(<String>[
'master',
@@ -64,7 +64,7 @@ class FlutterVersion {
return new FlutterVersion(flutterRoot != null ? flutterRoot : ArtifactStore.flutterRoot);
}
/// Return a short string for the version (`a76bc8e22b/alpha`).
/// Return a short string for the version (`alpha/a76bc8e22b`).
static String getVersionString({ bool whitelistBranchName: false }) {
final String cwd = ArtifactStore.flutterRoot;
@@ -80,7 +80,7 @@ class FlutterVersion {
branch = 'dev';
}
return '$commit/$branch';
return '$branch/$commit';
}
}