mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Clean up code organization in flutter_tools
1) Moved basic utility code into base/ directory to make it clear which code doesn't depend on Flutter-specific knowldge. 2) Move the CommandRunner subclasses into a runner/ directory because these aren't commands themselves.
This commit is contained in:
parent
3821560841
commit
9662d49e12
@ -9,12 +9,12 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:stack_trace/stack_trace.dart';
|
||||
|
||||
import 'src/base/process.dart';
|
||||
import 'src/commands/analyze.dart';
|
||||
import 'src/commands/apk.dart';
|
||||
import 'src/commands/build.dart';
|
||||
import 'src/commands/cache.dart';
|
||||
import 'src/commands/daemon.dart';
|
||||
import 'src/commands/flutter_command_runner.dart';
|
||||
import 'src/commands/init.dart';
|
||||
import 'src/commands/install.dart';
|
||||
import 'src/commands/list.dart';
|
||||
@ -26,7 +26,7 @@ import 'src/commands/stop.dart';
|
||||
import 'src/commands/test.dart';
|
||||
import 'src/commands/trace.dart';
|
||||
import 'src/commands/upgrade.dart';
|
||||
import 'src/process.dart';
|
||||
import 'src/runner/flutter_command_runner.dart';
|
||||
|
||||
/// Main entry point for commands.
|
||||
///
|
||||
|
@ -4,14 +4,11 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'artifacts.dart';
|
||||
import 'build_configuration.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.application_package');
|
||||
|
||||
abstract class ApplicationPackage {
|
||||
/// Path to the actual apk or bundle.
|
||||
final String localPath;
|
||||
|
@ -6,14 +6,12 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'build_configuration.dart';
|
||||
import 'os_utils.dart';
|
||||
import 'process.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.artifacts');
|
||||
import 'base/os.dart';
|
||||
import 'base/process.dart';
|
||||
import 'base/logging.dart';
|
||||
|
||||
String _getNameForHostPlatform(HostPlatform platform) {
|
||||
switch (platform) {
|
||||
@ -221,12 +219,12 @@ class ArtifactStore {
|
||||
/// and extract it to the local cache.
|
||||
static Future _doDownloadArtifactsFromZip(String platform) async {
|
||||
String url = getCloudStorageBaseUrl(platform) + 'artifacts.zip';
|
||||
_logging.info('Downloading $url.');
|
||||
logging.info('Downloading $url.');
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
HttpClientRequest request = await httpClient.getUrl(Uri.parse(url));
|
||||
HttpClientResponse response = await request.close();
|
||||
_logging.fine('Received response statusCode=${response.statusCode}');
|
||||
logging.fine('Received response statusCode=${response.statusCode}');
|
||||
if (response.statusCode != 200)
|
||||
throw new Exception(response.reasonPhrase);
|
||||
|
||||
@ -246,7 +244,7 @@ class ArtifactStore {
|
||||
|
||||
for (Artifact artifact in knownArtifacts) {
|
||||
if (artifact.platform == platform && artifact.executable) {
|
||||
ProcessResult result = osUtils.makeExecutable(
|
||||
ProcessResult result = os.makeExecutable(
|
||||
new File(path.join(cacheDir.path, artifact.fileName)));
|
||||
if (result.exitCode != 0)
|
||||
throw new Exception(result.stderr);
|
||||
@ -270,7 +268,7 @@ class ArtifactStore {
|
||||
|
||||
static Directory _getBaseCacheDir() {
|
||||
if (flutterRoot == null) {
|
||||
_logging.severe('FLUTTER_ROOT not specified. Cannot find artifact cache.');
|
||||
logging.severe('FLUTTER_ROOT not specified. Cannot find artifact cache.');
|
||||
throw new ProcessExit(2);
|
||||
}
|
||||
Directory cacheDir = new Directory(path.join(flutterRoot, 'bin', 'cache', 'artifacts'));
|
||||
@ -296,7 +294,7 @@ class ArtifactStore {
|
||||
if (!cachedFile.existsSync()) {
|
||||
await _downloadArtifactsFromZip(artifact.platform);
|
||||
if (!cachedFile.existsSync()) {
|
||||
_logging.severe('File not found in the platform artifacts: ${cachedFile.path}');
|
||||
logging.severe('File not found in the platform artifacts: ${cachedFile.path}');
|
||||
throw new ProcessExit(2);
|
||||
}
|
||||
}
|
||||
@ -305,7 +303,7 @@ class ArtifactStore {
|
||||
|
||||
static void clear() {
|
||||
Directory cacheDir = _getBaseCacheDir();
|
||||
_logging.fine('Clearing cache directory ${cacheDir.path}');
|
||||
logging.fine('Clearing cache directory ${cacheDir.path}');
|
||||
cacheDir.deleteSync(recursive: true);
|
||||
}
|
||||
|
||||
|
7
packages/flutter_tools/lib/src/base/logging.dart
Normal file
7
packages/flutter_tools/lib/src/base/logging.dart
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
final Logger logging = new Logger('flutter_tools');
|
@ -4,11 +4,7 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
final OperatingSystemUtils osUtils = new OperatingSystemUtils._();
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.os');
|
||||
final OperatingSystemUtils os = new OperatingSystemUtils._();
|
||||
|
||||
abstract class OperatingSystemUtils {
|
||||
factory OperatingSystemUtils._() {
|
@ -6,9 +6,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.process');
|
||||
import 'logging.dart';
|
||||
|
||||
/// This runs the command and streams stdout/stderr from the child process to
|
||||
/// this process' stdout/stderr.
|
||||
@ -17,7 +15,7 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
|
||||
RegExp filter,
|
||||
String workingDirectory
|
||||
}) async {
|
||||
_logging.info(cmd.join(' '));
|
||||
logging.info(cmd.join(' '));
|
||||
Process process = await Process.start(
|
||||
cmd[0],
|
||||
cmd.sublist(1),
|
||||
@ -49,13 +47,13 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
|
||||
Future runAndKill(List<String> cmd, Duration timeout) {
|
||||
Future<Process> proc = runDetached(cmd);
|
||||
return new Future.delayed(timeout, () async {
|
||||
_logging.info('Intentionally killing ${cmd[0]}');
|
||||
logging.info('Intentionally killing ${cmd[0]}');
|
||||
Process.killPid((await proc).pid);
|
||||
});
|
||||
}
|
||||
|
||||
Future<Process> runDetached(List<String> cmd) {
|
||||
_logging.info(cmd.join(' '));
|
||||
logging.info(cmd.join(' '));
|
||||
Future<Process> proc = Process.start(
|
||||
cmd[0], cmd.getRange(1, cmd.length).toList(),
|
||||
mode: ProcessStartMode.DETACHED);
|
||||
@ -81,20 +79,20 @@ String _runWithLoggingSync(List<String> cmd, {
|
||||
bool checked: false,
|
||||
String workingDirectory
|
||||
}) {
|
||||
_logging.info(cmd.join(' '));
|
||||
logging.info(cmd.join(' '));
|
||||
ProcessResult results =
|
||||
Process.runSync(cmd[0], cmd.getRange(1, cmd.length).toList(), workingDirectory: workingDirectory);
|
||||
if (results.exitCode != 0) {
|
||||
String errorDescription = 'Error code ${results.exitCode} '
|
||||
'returned when attempting to run command: ${cmd.join(' ')}';
|
||||
_logging.info(errorDescription);
|
||||
logging.info(errorDescription);
|
||||
if (results.stderr.length > 0)
|
||||
_logging.info('Errors logged: ${results.stderr.trim()}');
|
||||
logging.info('Errors logged: ${results.stderr.trim()}');
|
||||
if (checked)
|
||||
throw errorDescription;
|
||||
}
|
||||
if (results.stdout.trim().isNotEmpty)
|
||||
_logging.fine(results.stdout.trim());
|
||||
logging.fine(results.stdout.trim());
|
||||
return results.stdout;
|
||||
}
|
||||
|
@ -4,10 +4,9 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.build_configuration');
|
||||
import 'base/logging.dart';
|
||||
|
||||
enum BuildType {
|
||||
prebuilt,
|
||||
@ -33,7 +32,7 @@ HostPlatform getCurrentHostPlatform() {
|
||||
return HostPlatform.mac;
|
||||
if (Platform.isLinux)
|
||||
return HostPlatform.linux;
|
||||
_logging.warning('Unsupported host platform, defaulting to Linux');
|
||||
logging.warning('Unsupported host platform, defaulting to Linux');
|
||||
return HostPlatform.linux;
|
||||
}
|
||||
|
||||
@ -42,7 +41,7 @@ TargetPlatform getCurrentHostPlatformAsTarget() {
|
||||
return TargetPlatform.mac;
|
||||
if (Platform.isLinux)
|
||||
return TargetPlatform.linux;
|
||||
_logging.warning('Unsupported host platform, defaulting to Linux');
|
||||
logging.warning('Unsupported host platform, defaulting to Linux');
|
||||
return TargetPlatform.linux;
|
||||
}
|
||||
|
||||
|
@ -6,15 +6,13 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../process.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('sky_tools.analyze');
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class AnalyzeCommand extends FlutterCommand {
|
||||
String get name => 'analyze';
|
||||
@ -174,7 +172,7 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
for (String package in dependencies.keys) {
|
||||
if (packages.containsKey(package)) {
|
||||
if (packages[package] != dependencies[package]) {
|
||||
_logging.warning('Inconsistent requirements for $package; using ${packages[package]} (and not ${dependencies[package]}).');
|
||||
logging.warning('Inconsistent requirements for $package; using ${packages[package]} (and not ${dependencies[package]}).');
|
||||
hadInconsistentRequirements = true;
|
||||
}
|
||||
} else {
|
||||
@ -185,9 +183,9 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
}
|
||||
if (hadInconsistentRequirements) {
|
||||
if (argResults['flutter-repo'])
|
||||
_logging.warning('You may need to run "dart ${path.normalize(path.relative(path.join(ArtifactStore.flutterRoot, 'dev/update_packages.dart')))} --upgrade".');
|
||||
logging.warning('You may need to run "dart ${path.normalize(path.relative(path.join(ArtifactStore.flutterRoot, 'dev/update_packages.dart')))} --upgrade".');
|
||||
if (foundAnyInCurrentDirectory)
|
||||
_logging.warning('You may need to run "pub upgrade".');
|
||||
logging.warning('You may need to run "pub upgrade".');
|
||||
}
|
||||
|
||||
String buildDir = buildConfigurations.firstWhere((BuildConfiguration config) => config.testable, orElse: () => null)?.buildDir;
|
||||
@ -222,7 +220,7 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
mainFile.path
|
||||
];
|
||||
|
||||
_logging.info(cmd.join(' '));
|
||||
logging.info(cmd.join(' '));
|
||||
Process process = await Process.start(
|
||||
cmd[0],
|
||||
cmd.sublist(1),
|
||||
|
@ -5,15 +5,15 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../device.dart';
|
||||
import '../file_system.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'build.dart';
|
||||
import 'flutter_command.dart';
|
||||
import 'start.dart';
|
||||
|
||||
const String _kDefaultAndroidManifestPath = 'apk/AndroidManifest.xml';
|
||||
@ -24,8 +24,6 @@ const String _kKeystorePassword = "chromium";
|
||||
const String _kAndroidPlatformVersion = '22';
|
||||
const String _kBuildToolsVersion = '22.0.1';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.apk');
|
||||
|
||||
/// Copies files into a new directory structure.
|
||||
class _AssetBuilder {
|
||||
final Directory outDir;
|
||||
@ -172,19 +170,19 @@ class ApkCommand extends FlutterCommand {
|
||||
components.keystore = new File(artifactPaths[3]);
|
||||
|
||||
if (!components.androidSdk.existsSync()) {
|
||||
_logging.severe('Can not locate Android SDK: $androidSdkPath');
|
||||
logging.severe('Can not locate Android SDK: $androidSdkPath');
|
||||
return null;
|
||||
}
|
||||
if (!(new _ApkBuilder(components.androidSdk.path).checkSdkPath())) {
|
||||
_logging.severe('Can not locate expected Android SDK tools at $androidSdkPath');
|
||||
_logging.severe('You must install version $_kAndroidPlatformVersion of the SDK platform');
|
||||
_logging.severe('and version $_kBuildToolsVersion of the build tools.');
|
||||
logging.severe('Can not locate expected Android SDK tools at $androidSdkPath');
|
||||
logging.severe('You must install version $_kAndroidPlatformVersion of the SDK platform');
|
||||
logging.severe('and version $_kBuildToolsVersion of the build tools.');
|
||||
return null;
|
||||
}
|
||||
for (File f in [components.manifest, components.icuData, components.classesDex,
|
||||
components.libSkyShell, components.keystore]) {
|
||||
if (!f.existsSync()) {
|
||||
_logging.severe('Can not locate file: ${f.path}');
|
||||
logging.severe('Can not locate file: ${f.path}');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -227,7 +225,7 @@ class ApkCommand extends FlutterCommand {
|
||||
|
||||
_ApkComponents components = await _findApkComponents(config);
|
||||
if (components == null) {
|
||||
_logging.severe('Unable to build APK.');
|
||||
logging.severe('Unable to build APK.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -235,8 +233,8 @@ class ApkCommand extends FlutterCommand {
|
||||
|
||||
if (!flxPath.isEmpty) {
|
||||
if (!FileSystemEntity.isFileSync(flxPath)) {
|
||||
_logging.severe('FLX does not exist: $flxPath');
|
||||
_logging.severe('(Omit the --flx option to build the FLX automatically)');
|
||||
logging.severe('FLX does not exist: $flxPath');
|
||||
logging.severe('(Omit the --flx option to build the FLX automatically)');
|
||||
return 1;
|
||||
}
|
||||
return _buildApk(components, flxPath);
|
||||
|
@ -9,21 +9,19 @@ import 'dart:typed_data';
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:flx/bundle.dart';
|
||||
import 'package:flx/signing.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import '../file_system.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../toolchain.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
const String _kSnapshotKey = 'snapshot_blob.bin';
|
||||
const List<String> _kDensities = const ['drawable-xxhdpi'];
|
||||
const List<String> _kThemes = const ['white', 'black'];
|
||||
const List<int> _kSizes = const [18, 24, 36, 48];
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.build');
|
||||
|
||||
class _Asset {
|
||||
final String base;
|
||||
final String key;
|
||||
@ -182,7 +180,7 @@ class BuildCommand extends FlutterCommand {
|
||||
String privateKeyPath: _kDefaultPrivateKeyPath,
|
||||
bool precompiledSnapshot: false
|
||||
}) async {
|
||||
_logging.fine('Building $outputPath');
|
||||
logging.fine('Building $outputPath');
|
||||
|
||||
Map manifestDescriptor = _loadManifest(manifestPath);
|
||||
|
||||
|
@ -5,12 +5,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.cache');
|
||||
|
||||
class CacheCommand extends Command {
|
||||
final String name = 'cache';
|
||||
final String description = 'Manages Flutter\'s cache of binary artifacts.';
|
||||
|
@ -6,9 +6,8 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import 'flutter_command.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'start.dart';
|
||||
import 'stop.dart';
|
||||
|
||||
@ -20,8 +19,6 @@ const String domain = 'domain';
|
||||
/// A domain @command annotation.
|
||||
const String command = 'command';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.daemon');
|
||||
|
||||
// TODO: Create a `device` domain in order to list devices and fire events when
|
||||
// devices are added or removed.
|
||||
|
||||
@ -96,7 +93,7 @@ class Daemon {
|
||||
var id = command['id'];
|
||||
|
||||
if (id == null) {
|
||||
_logging.severe('no id for command: $command');
|
||||
logging.severe('no id for command: $command');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,7 +110,7 @@ class Daemon {
|
||||
_domains[prefix].handleEvent(name, id, command['params']);
|
||||
} catch (error, trace) {
|
||||
_send({'id': id, 'error': _toJsonable(error)});
|
||||
_logging.warning('error handling ${command['event']}', error, trace);
|
||||
logging.warning('error handling ${command['event']}', error, trace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +148,7 @@ abstract class Domain {
|
||||
}
|
||||
}).catchError((error, trace) {
|
||||
_send({'id': id, 'error': _toJsonable(error)});
|
||||
_logging.warning('error handling $name', error, trace);
|
||||
logging.warning('error handling $name', error, trace);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,12 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:mustache4dart/mustache4dart.dart' as mustache;
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../process.dart';
|
||||
|
||||
final Logger _logging = new Logger('sky_tools.init');
|
||||
import '../base/logging.dart';
|
||||
import '../base/process.dart';
|
||||
|
||||
class InitCommand extends Command {
|
||||
final String name = 'init';
|
||||
@ -82,7 +80,7 @@ class InitCommand extends Command {
|
||||
if (!pubSpecYaml.existsSync()) {
|
||||
if (skipIfAbsent)
|
||||
return 0;
|
||||
_logging.severe('$directory: no pubspec.yaml found');
|
||||
logging.severe('$directory: no pubspec.yaml found');
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -101,7 +99,7 @@ class InitCommand extends Command {
|
||||
(dotPackages.existsSync() && dotPackages.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())))
|
||||
return 0;
|
||||
|
||||
_logging.severe('$directory: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state');
|
||||
logging.severe('$directory: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import 'dart:async';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../device.dart';
|
||||
import 'flutter_command.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class InstallCommand extends FlutterCommand {
|
||||
final String name = 'install';
|
||||
|
@ -4,12 +4,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../device.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.list');
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class ListCommand extends FlutterCommand {
|
||||
final String name = 'list';
|
||||
|
@ -5,15 +5,12 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../base/process.dart';
|
||||
import '../device.dart';
|
||||
import '../process.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'build.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.listen');
|
||||
|
||||
class ListenCommand extends FlutterCommand {
|
||||
final String name = 'listen';
|
||||
@ -48,7 +45,7 @@ class ListenCommand extends FlutterCommand {
|
||||
}
|
||||
|
||||
while (true) {
|
||||
_logging.info('Updating running Flutter apps...');
|
||||
logging.info('Updating running Flutter apps...');
|
||||
|
||||
BuildCommand builder = new BuildCommand();
|
||||
builder.inheritFromParent(this);
|
||||
@ -85,7 +82,7 @@ class ListenCommand extends FlutterCommand {
|
||||
try {
|
||||
runCheckedSync(['which', 'fswatch']);
|
||||
} catch (e) {
|
||||
_logging.severe('"listen" command is only useful if you have installed '
|
||||
logging.severe('"listen" command is only useful if you have installed '
|
||||
'fswatch on Mac. Run "brew install fswatch" to install it with '
|
||||
'homebrew.');
|
||||
return null;
|
||||
@ -95,7 +92,7 @@ class ListenCommand extends FlutterCommand {
|
||||
try {
|
||||
runCheckedSync(['which', 'inotifywait']);
|
||||
} catch (e) {
|
||||
_logging.severe('"listen" command is only useful if you have installed '
|
||||
logging.severe('"listen" command is only useful if you have installed '
|
||||
'inotifywait on Linux. Run "apt-get install inotify-tools" or '
|
||||
'equivalent to install it.');
|
||||
return null;
|
||||
@ -109,7 +106,7 @@ class ListenCommand extends FlutterCommand {
|
||||
'modify,close_write,move,create,delete',
|
||||
]..addAll(directories);
|
||||
} else {
|
||||
_logging.severe('"listen" command is only available on Mac and Linux.');
|
||||
logging.severe('"listen" command is only available on Mac and Linux.');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -121,7 +118,7 @@ class ListenCommand extends FlutterCommand {
|
||||
try {
|
||||
runCheckedSync(watchCommand);
|
||||
} catch (e) {
|
||||
_logging.warning('Watching directories failed.', e);
|
||||
logging.warning('Watching directories failed.', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../device.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.logs');
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class LogsCommand extends FlutterCommand {
|
||||
final String name = 'logs';
|
||||
|
@ -9,16 +9,15 @@ import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../process.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'build.dart';
|
||||
import 'flutter_command.dart';
|
||||
import 'start.dart';
|
||||
|
||||
const String _kDefaultBundlePath = 'build/app.flx';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.run_mojo');
|
||||
|
||||
class RunMojoCommand extends FlutterCommand {
|
||||
final String name = 'run_mojo';
|
||||
final String description = 'Run a Flutter app in mojo.';
|
||||
@ -121,9 +120,9 @@ class RunMojoCommand extends FlutterCommand {
|
||||
if (useDevtools) {
|
||||
final String buildFlag = argResults['mojo-debug'] ? '--debug' : '--release';
|
||||
args.add(buildFlag);
|
||||
if (_logging.level <= Level.INFO) {
|
||||
if (logging.level <= Level.INFO) {
|
||||
args.add('--verbose');
|
||||
if (_logging.level <= Level.FINE) {
|
||||
if (logging.level <= Level.FINE) {
|
||||
args.add('--verbose');
|
||||
}
|
||||
}
|
||||
@ -141,12 +140,12 @@ class RunMojoCommand extends FlutterCommand {
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
if ((argResults['mojo-path'] == null && argResults['devtools-path'] == null) || (argResults['mojo-path'] != null && argResults['devtools-path'] != null)) {
|
||||
_logging.severe('Must specify either --mojo-path or --devtools-path.');
|
||||
logging.severe('Must specify either --mojo-path or --devtools-path.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argResults['mojo-debug'] && argResults['mojo-release']) {
|
||||
_logging.severe('Cannot specify both --mojo-debug and --mojo-release');
|
||||
logging.severe('Cannot specify both --mojo-debug and --mojo-release');
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -5,18 +5,16 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../device.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'build.dart';
|
||||
import 'flutter_command.dart';
|
||||
import 'install.dart';
|
||||
import 'stop.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.start');
|
||||
|
||||
class StartCommand extends FlutterCommand {
|
||||
final String name = 'start';
|
||||
final String description = 'Start your Flutter app on attached devices.';
|
||||
@ -51,7 +49,7 @@ class StartCommand extends FlutterCommand {
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
_logging.fine('downloading toolchain');
|
||||
logging.fine('downloading toolchain');
|
||||
|
||||
await Future.wait([
|
||||
downloadToolchain(),
|
||||
@ -60,13 +58,13 @@ class StartCommand extends FlutterCommand {
|
||||
|
||||
bool poke = argResults['poke'];
|
||||
if (!poke) {
|
||||
_logging.fine('running stop command');
|
||||
logging.fine('running stop command');
|
||||
|
||||
StopCommand stopper = new StopCommand();
|
||||
stopper.inheritFromParent(this);
|
||||
stopper.stop();
|
||||
|
||||
_logging.fine('running install command');
|
||||
logging.fine('running install command');
|
||||
|
||||
// Only install if the user did not specify a poke
|
||||
InstallCommand installer = new InstallCommand();
|
||||
@ -91,14 +89,14 @@ class StartCommand extends FlutterCommand {
|
||||
continue;
|
||||
}
|
||||
|
||||
_logging.fine('running build command for $device');
|
||||
logging.fine('running build command for $device');
|
||||
|
||||
BuildCommand builder = new BuildCommand();
|
||||
builder.inheritFromParent(this);
|
||||
await builder.buildInTempDir(
|
||||
mainPath: mainPath,
|
||||
onBundleAvailable: (String localBundlePath) {
|
||||
_logging.fine('running start bundle for $device');
|
||||
logging.fine('running start bundle for $device');
|
||||
|
||||
if (device.startBundle(package, localBundlePath,
|
||||
poke: poke,
|
||||
@ -108,7 +106,7 @@ class StartCommand extends FlutterCommand {
|
||||
}
|
||||
);
|
||||
} else {
|
||||
_logging.fine('running start command for $device');
|
||||
logging.fine('running start command for $device');
|
||||
|
||||
if (await device.startApp(package))
|
||||
startedSomething = true;
|
||||
@ -117,13 +115,13 @@ class StartCommand extends FlutterCommand {
|
||||
|
||||
if (!startedSomething) {
|
||||
if (!devices.all.any((device) => device.isConnected())) {
|
||||
_logging.severe('Unable to run application - no connected devices.');
|
||||
logging.severe('Unable to run application - no connected devices.');
|
||||
} else {
|
||||
_logging.severe('Unable to run application.');
|
||||
logging.severe('Unable to run application.');
|
||||
}
|
||||
}
|
||||
|
||||
_logging.fine('finished start command');
|
||||
logging.fine('finished start command');
|
||||
|
||||
return startedSomething ? 0 : 2;
|
||||
}
|
||||
|
@ -4,13 +4,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../device.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.stop');
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class StopCommand extends FlutterCommand {
|
||||
final String name = 'stop';
|
||||
|
@ -5,16 +5,14 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/src/executable.dart' as executable;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../test/loader.dart' as loader;
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.test');
|
||||
|
||||
class TestCommand extends FlutterCommand {
|
||||
String get name => 'test';
|
||||
@ -88,7 +86,7 @@ class TestCommand extends FlutterCommand {
|
||||
foundOne = true;
|
||||
loader.shellPath = path.join(Directory.current.path, getShellPath(config.targetPlatform, config.buildDir));
|
||||
if (!FileSystemEntity.isFileSync(loader.shellPath)) {
|
||||
_logging.severe('Cannot find Flutter shell at ${loader.shellPath}');
|
||||
logging.severe('Cannot find Flutter shell at ${loader.shellPath}');
|
||||
return 1;
|
||||
}
|
||||
await _runTests(testArgs, testDir);
|
||||
|
@ -4,13 +4,10 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../device.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.trace');
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class TraceCommand extends FlutterCommand {
|
||||
final String name = 'trace';
|
||||
@ -32,7 +29,7 @@ class TraceCommand extends FlutterCommand {
|
||||
await downloadApplicationPackagesAndConnectToDevices();
|
||||
|
||||
if (!devices.android.isConnected()) {
|
||||
_logging.warning('No device connected, so no trace was completed.');
|
||||
logging.warning('No device connected, so no trace was completed.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -57,7 +54,7 @@ class TraceCommand extends FlutterCommand {
|
||||
void _stopTracing(AndroidDevice android, AndroidApk androidApp) {
|
||||
String tracePath = android.stopTracing(androidApp);
|
||||
if (tracePath == null) {
|
||||
_logging.warning('No trace file saved.');
|
||||
logging.warning('No trace file saved.');
|
||||
} else {
|
||||
print('Trace file saved to $tracePath');
|
||||
}
|
||||
|
@ -4,13 +4,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../process.dart';
|
||||
import 'flutter_command.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.upgrade');
|
||||
import '../base/process.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class UpgradeCommand extends FlutterCommand {
|
||||
final String name = 'upgrade';
|
||||
|
@ -6,14 +6,12 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'application_package.dart';
|
||||
import 'base/logging.dart';
|
||||
import 'base/process.dart';
|
||||
import 'build_configuration.dart';
|
||||
import 'process.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.device');
|
||||
|
||||
abstract class Device {
|
||||
final String id;
|
||||
@ -140,11 +138,11 @@ class IOSDevice extends Device {
|
||||
command = runCheckedSync(['which', command]).trim();
|
||||
} catch (e) {
|
||||
if (Platform.isMacOS) {
|
||||
_logging.severe(macInstructions);
|
||||
logging.severe(macInstructions);
|
||||
} else if (Platform.isLinux) {
|
||||
_logging.severe(linuxInstructions);
|
||||
logging.severe(linuxInstructions);
|
||||
} else {
|
||||
_logging.severe('$command is not available on your platform.');
|
||||
logging.severe('$command is not available on your platform.');
|
||||
}
|
||||
}
|
||||
return command;
|
||||
@ -204,7 +202,7 @@ class IOSDevice extends Device {
|
||||
(_) {
|
||||
return true;
|
||||
}, onError: (e) {
|
||||
_logging.info('Failure running $debuggerPath: ', e);
|
||||
logging.info('Failure running $debuggerPath: ', e);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
@ -297,11 +295,11 @@ class IOSSimulator extends Device {
|
||||
// More than one simulator is listed as booted, which is not allowed but
|
||||
// sometimes happens erroneously. Kill them all because we don't know
|
||||
// which one is actually running.
|
||||
_logging.warning('Multiple running simulators were detected, '
|
||||
logging.warning('Multiple running simulators were detected, '
|
||||
'which is not supposed to happen.');
|
||||
for (Match m in matches) {
|
||||
if (m.groupCount > 0) {
|
||||
_logging.warning('Killing simulator ${m.group(1)}');
|
||||
logging.warning('Killing simulator ${m.group(1)}');
|
||||
runSync([xcrunPath, 'simctl', 'shutdown', m.group(1)]);
|
||||
}
|
||||
}
|
||||
@ -312,7 +310,7 @@ class IOSSimulator extends Device {
|
||||
if (match != null && match.groupCount > 0) {
|
||||
return match.group(1);
|
||||
} else {
|
||||
_logging.info('No running simulators found');
|
||||
logging.info('No running simulators found');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -357,11 +355,11 @@ class IOSSimulator extends Device {
|
||||
runDetached([iOSSimPath]);
|
||||
Future<bool> checkConnection([int attempts = 20]) async {
|
||||
if (attempts == 0) {
|
||||
_logging.info('Timed out waiting for iOS Simulator $id to boot.');
|
||||
logging.info('Timed out waiting for iOS Simulator $id to boot.');
|
||||
return false;
|
||||
}
|
||||
if (!isConnected()) {
|
||||
_logging.info('Waiting for iOS Simulator $id to boot...');
|
||||
logging.info('Waiting for iOS Simulator $id to boot...');
|
||||
return await new Future.delayed(new Duration(milliseconds: 500),
|
||||
() => checkConnection(attempts - 1));
|
||||
}
|
||||
@ -372,7 +370,7 @@ class IOSSimulator extends Device {
|
||||
try {
|
||||
runCheckedSync([xcrunPath, 'simctl', 'boot', id]);
|
||||
} catch (e) {
|
||||
_logging.warning('Unable to boot iOS Simulator $id: ', e);
|
||||
logging.warning('Unable to boot iOS Simulator $id: ', e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -511,7 +509,7 @@ class AndroidDevice extends Device {
|
||||
try {
|
||||
runCheckedSync([adbPath, 'version']);
|
||||
} catch (e) {
|
||||
_logging.severe('Unable to find adb. Is "adb" in your path?');
|
||||
logging.severe('Unable to find adb. Is "adb" in your path?');
|
||||
return devices;
|
||||
}
|
||||
|
||||
@ -554,12 +552,12 @@ class AndroidDevice extends Device {
|
||||
} else if (unauthorizedRegex.hasMatch(line)) {
|
||||
Match match = unauthorizedRegex.firstMatch(line);
|
||||
String deviceID = match[1];
|
||||
_logging.warning(
|
||||
logging.warning(
|
||||
'Device $deviceID is not authorized.\n'
|
||||
'You might need to check your device for an authorization dialog.'
|
||||
);
|
||||
} else {
|
||||
_logging.warning(
|
||||
logging.warning(
|
||||
'Unexpected failure parsing device information from adb output:\n'
|
||||
'$line\n'
|
||||
'Please report a bug at https://github.com/flutter/flutter/issues/new');
|
||||
@ -578,7 +576,7 @@ class AndroidDevice extends Device {
|
||||
_hasValidAndroid = _checkForSupportedAndroidVersion();
|
||||
|
||||
if (!_hasAdb || !_hasValidAndroid) {
|
||||
_logging.warning('Unable to run on Android.');
|
||||
logging.warning('Unable to run on Android.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,11 +590,11 @@ class AndroidDevice extends Device {
|
||||
path.join(androidHomeDir, 'sdk', 'platform-tools'))) {
|
||||
return path.join(androidHomeDir, 'sdk');
|
||||
} else {
|
||||
_logging.warning('Android SDK not found at $androidHomeDir');
|
||||
logging.warning('Android SDK not found at $androidHomeDir');
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
_logging.warning('Android SDK not found. The ANDROID_HOME variable must be set.');
|
||||
logging.warning('Android SDK not found. The ANDROID_HOME variable must be set.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -612,7 +610,7 @@ class AndroidDevice extends Device {
|
||||
} else if (FileSystemEntity.isFileSync(adbPath2)) {
|
||||
return adbPath2;
|
||||
} else {
|
||||
_logging.info('"adb" not found at\n "$adbPath1" or\n "$adbPath2"\n' +
|
||||
logging.info('"adb" not found at\n "$adbPath1" or\n "$adbPath2"\n' +
|
||||
'using default path "$_ADB_PATH"');
|
||||
return _ADB_PATH;
|
||||
}
|
||||
@ -649,7 +647,7 @@ class AndroidDevice extends Device {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_logging.warning(
|
||||
logging.warning(
|
||||
'Unrecognized adb version string $adbVersion. Skipping version check.');
|
||||
return true;
|
||||
}
|
||||
@ -662,16 +660,16 @@ class AndroidDevice extends Device {
|
||||
}
|
||||
|
||||
String locatedAdbPath = runCheckedSync(['which', 'adb']);
|
||||
_logging.severe('"$locatedAdbPath" is too old. '
|
||||
logging.severe('"$locatedAdbPath" is too old. '
|
||||
'Please install version 1.0.32 or later.\n'
|
||||
'Try setting ANDROID_HOME to the path to your Android SDK install. '
|
||||
'Android builds are unavailable.');
|
||||
} catch (e, stack) {
|
||||
_logging.severe('"adb" not found in \$PATH. '
|
||||
logging.severe('"adb" not found in \$PATH. '
|
||||
'Please install the Android SDK or set ANDROID_HOME '
|
||||
'to the path of your Android SDK install.');
|
||||
_logging.info(e);
|
||||
_logging.info(stack);
|
||||
logging.info(e);
|
||||
logging.info(stack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -686,7 +684,7 @@ class AndroidDevice extends Device {
|
||||
|
||||
String ready = runSync(adbCommandForDevice(['shell', 'echo', 'ready']));
|
||||
if (ready.trim() != 'ready') {
|
||||
_logging.info('Android device not found.');
|
||||
logging.info('Android device not found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -698,17 +696,17 @@ class AndroidDevice extends Device {
|
||||
int sdkVersionParsed =
|
||||
int.parse(sdkVersion, onError: (String source) => null);
|
||||
if (sdkVersionParsed == null) {
|
||||
_logging.severe('Unexpected response from getprop: "$sdkVersion"');
|
||||
logging.severe('Unexpected response from getprop: "$sdkVersion"');
|
||||
return false;
|
||||
}
|
||||
if (sdkVersionParsed < 16) {
|
||||
_logging.severe('The Android version ($sdkVersion) on the target device '
|
||||
logging.severe('The Android version ($sdkVersion) on the target device '
|
||||
'is too old. Please use a Jelly Bean (version 16 / 4.1.x) device or later.');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
_logging.severe('Unexpected failure from adb: ', e);
|
||||
logging.severe('Unexpected failure from adb: ', e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -735,12 +733,12 @@ class AndroidDevice extends Device {
|
||||
}
|
||||
if (runCheckedSync(adbCommandForDevice(['shell', 'pm', 'path', app.id])) ==
|
||||
'') {
|
||||
_logging.info(
|
||||
logging.info(
|
||||
'TODO(iansf): move this log to the caller. ${app.name} is not on the device. Installing now...');
|
||||
return false;
|
||||
}
|
||||
if (_getDeviceApkSha1(app) != _getSourceSha1(app)) {
|
||||
_logging.info(
|
||||
logging.info(
|
||||
'TODO(iansf): move this log to the caller. ${app.name} is out of date. Installing now...');
|
||||
return false;
|
||||
}
|
||||
@ -750,11 +748,11 @@ class AndroidDevice extends Device {
|
||||
@override
|
||||
bool installApp(ApplicationPackage app) {
|
||||
if (!isConnected()) {
|
||||
_logging.info('Android device not connected. Not installing.');
|
||||
logging.info('Android device not connected. Not installing.');
|
||||
return false;
|
||||
}
|
||||
if (!FileSystemEntity.isFileSync(app.localPath)) {
|
||||
_logging.severe('"${app.localPath}" does not exist.');
|
||||
logging.severe('"${app.localPath}" does not exist.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -775,10 +773,10 @@ class AndroidDevice extends Device {
|
||||
bool checked,
|
||||
String route
|
||||
}) {
|
||||
_logging.fine('$this startBundle');
|
||||
logging.fine('$this startBundle');
|
||||
|
||||
if (!FileSystemEntity.isFileSync(bundlePath)) {
|
||||
_logging.severe('Cannot find $bundlePath');
|
||||
logging.severe('Cannot find $bundlePath');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -882,7 +880,7 @@ class AndroidDevice extends Device {
|
||||
runSync(adbCommandForDevice(['shell', 'rm', tracePath]));
|
||||
return path.basename(tracePath);
|
||||
}
|
||||
_logging.warning('No trace file detected. '
|
||||
logging.warning('No trace file detected. '
|
||||
'Did you remember to start the trace before stopping it?');
|
||||
return null;
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/logging.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../process.dart';
|
||||
|
||||
final Logger _logging = new Logger('flutter_tools.flutter_command_runner');
|
||||
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)
|
||||
@ -45,7 +45,7 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
help: 'Path to your packages directory.$packagesHelp');
|
||||
argParser.addOption('flutter-root',
|
||||
help: 'The root directory of the Flutter repository. Defaults to \$$kFlutterRootEnvironmentVariableName if set,\n'
|
||||
'otherwise defaults to a value derived from the location of this tool.', defaultsTo: defaultFlutterRoot);
|
||||
'otherwise defaults to a value derived from the location of this tool.', defaultsTo: _defaultFlutterRoot);
|
||||
|
||||
argParser.addOption('android-device-id',
|
||||
help: 'Serial number of the target Android device.');
|
||||
@ -128,10 +128,10 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
|
||||
ArgResults _globalResults;
|
||||
|
||||
String get defaultFlutterRoot {
|
||||
String script = Platform.script.toFilePath();
|
||||
String get _defaultFlutterRoot {
|
||||
if (Platform.environment.containsKey(kFlutterRootEnvironmentVariableName))
|
||||
return Platform.environment[kFlutterRootEnvironmentVariableName];
|
||||
String script = Platform.script.toFilePath();
|
||||
if (path.basename(script) == kSnapshotFileName)
|
||||
return path.dirname(path.dirname(path.dirname(script)));
|
||||
if (path.basename(script) == kFlutterToolsScriptFileName)
|
||||
@ -151,33 +151,14 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
if (globalResults.wasParsed('package-root'))
|
||||
ArtifactStore.packageRoot = globalResults['package-root'];
|
||||
|
||||
if (globalResults['version'])
|
||||
return _printVersion();
|
||||
if (globalResults['version']) {
|
||||
print(getVersion(ArtifactStore.flutterRoot));
|
||||
return new Future<int>.value(0);
|
||||
}
|
||||
|
||||
return super.runCommand(globalResults);
|
||||
}
|
||||
|
||||
Future<int> _printVersion() async {
|
||||
String upstream = runSync([
|
||||
'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}'
|
||||
], workingDirectory: ArtifactStore.flutterRoot).trim();
|
||||
String repository = '<unknown>';
|
||||
int slash = upstream.indexOf('/');
|
||||
if (slash != -1) {
|
||||
String remote = upstream.substring(0, slash);
|
||||
repository = runSync([
|
||||
'git', 'ls-remote', '--get-url', remote
|
||||
], workingDirectory: ArtifactStore.flutterRoot).trim();
|
||||
upstream = upstream.substring(slash + 1);
|
||||
}
|
||||
String revision = runSync([
|
||||
'git', 'log', '-n', '1', '--pretty=format:%H (%ar)'
|
||||
], workingDirectory: ArtifactStore.flutterRoot).trim();
|
||||
|
||||
print('Flutter\nRepository: $repository\nBranch: $upstream\nRevision: $revision');
|
||||
return 0;
|
||||
}
|
||||
|
||||
String _tryEnginePath(String enginePath) {
|
||||
if (FileSystemEntity.isDirectorySync(path.join(enginePath, 'out')))
|
||||
return enginePath;
|
||||
@ -239,7 +220,7 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
));
|
||||
} else {
|
||||
if (!FileSystemEntity.isDirectorySync(enginePath))
|
||||
_logging.warning('$enginePath is not a valid directory');
|
||||
logging.warning('$enginePath is not a valid directory');
|
||||
|
||||
if (!isDebug && !isRelease)
|
||||
isDebug = true;
|
24
packages/flutter_tools/lib/src/runner/version.dart
Normal file
24
packages/flutter_tools/lib/src/runner/version.dart
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../base/process.dart';
|
||||
|
||||
String getVersion(String flutterRoot) {
|
||||
String upstream = runSync([
|
||||
'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}'
|
||||
], workingDirectory: flutterRoot).trim();
|
||||
String repository = '<unknown>';
|
||||
int slash = upstream.indexOf('/');
|
||||
if (slash != -1) {
|
||||
String remote = upstream.substring(0, slash);
|
||||
repository = runSync([
|
||||
'git', 'ls-remote', '--get-url', remote
|
||||
], workingDirectory: flutterRoot).trim();
|
||||
upstream = upstream.substring(slash + 1);
|
||||
}
|
||||
String revision = runSync([
|
||||
'git', 'log', '-n', '1', '--pretty=format:%H (%ar)'
|
||||
], workingDirectory: flutterRoot).trim();
|
||||
return 'Flutter\nRepository: $repository\nBranch: $upstream\nRevision: $revision';
|
||||
}
|
@ -9,7 +9,7 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
import 'artifacts.dart';
|
||||
import 'build_configuration.dart';
|
||||
import 'process.dart';
|
||||
import 'base/process.dart';
|
||||
|
||||
class Compiler {
|
||||
Compiler(this._path);
|
||||
|
@ -8,7 +8,7 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/commands/init.dart';
|
||||
import 'package:flutter_tools/src/process.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() => defineTests();
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_tools/src/os_utils.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@ -25,7 +25,7 @@ defineTests() {
|
||||
test('makeExecutable', () {
|
||||
File file = new File(path.join(temp.path, 'foo.script'));
|
||||
file.writeAsStringSync('hello world');
|
||||
osUtils.makeExecutable(file);
|
||||
os.makeExecutable(file);
|
||||
|
||||
// Skip this test on windows.
|
||||
if (!Platform.isWindows) {
|
||||
|
@ -2,12 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:flutter_tools/src/application_package.dart';
|
||||
import 'package:flutter_tools/src/build_configuration.dart';
|
||||
import 'package:flutter_tools/src/commands/flutter_command.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:flutter_tools/src/toolchain.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
class MockApplicationPackageStore extends ApplicationPackageStore {
|
||||
MockApplicationPackageStore() : super(
|
||||
|
Loading…
Reference in New Issue
Block a user