Migrate fuchsia sdk and dependencies to null safety (#88920)
This commit is contained in:
parent
fec0e19d93
commit
0cb6d5983c
@ -2,9 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
import 'package:file/file.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
@ -25,16 +23,15 @@ import 'fuchsia_sdk.dart';
|
|||||||
/// A simple wrapper for the Fuchsia SDK's 'device-finder' tool.
|
/// A simple wrapper for the Fuchsia SDK's 'device-finder' tool.
|
||||||
class FuchsiaDevFinder {
|
class FuchsiaDevFinder {
|
||||||
FuchsiaDevFinder({
|
FuchsiaDevFinder({
|
||||||
@required FuchsiaArtifacts fuchsiaArtifacts,
|
required FuchsiaArtifacts? fuchsiaArtifacts,
|
||||||
@required Logger logger,
|
required Logger logger,
|
||||||
@required ProcessManager processManager,
|
required ProcessManager processManager,
|
||||||
})
|
})
|
||||||
: _fuchsiaArtifacts = fuchsiaArtifacts,
|
: _fuchsiaArtifacts = fuchsiaArtifacts,
|
||||||
_logger = logger,
|
_logger = logger,
|
||||||
_processUtils = ProcessUtils(logger: logger, processManager: processManager);
|
_processUtils = ProcessUtils(logger: logger, processManager: processManager);
|
||||||
|
|
||||||
|
final FuchsiaArtifacts? _fuchsiaArtifacts;
|
||||||
final FuchsiaArtifacts _fuchsiaArtifacts;
|
|
||||||
final Logger _logger;
|
final Logger _logger;
|
||||||
final ProcessUtils _processUtils;
|
final ProcessUtils _processUtils;
|
||||||
|
|
||||||
@ -42,13 +39,13 @@ class FuchsiaDevFinder {
|
|||||||
/// formatted as follows:
|
/// formatted as follows:
|
||||||
///
|
///
|
||||||
/// 192.168.42.172 scare-cable-skip-joy
|
/// 192.168.42.172 scare-cable-skip-joy
|
||||||
Future<List<String>> list({ Duration timeout }) async {
|
Future<List<String>?> list({ Duration? timeout }) async {
|
||||||
if (_fuchsiaArtifacts.devFinder == null ||
|
final File? devFinder = _fuchsiaArtifacts?.devFinder;
|
||||||
!_fuchsiaArtifacts.devFinder.existsSync()) {
|
if (devFinder == null || !devFinder.existsSync()) {
|
||||||
throwToolExit('Fuchsia device-finder tool not found.');
|
throwToolExit('Fuchsia device-finder tool not found.');
|
||||||
}
|
}
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
_fuchsiaArtifacts.devFinder.path,
|
devFinder.path,
|
||||||
'list',
|
'list',
|
||||||
'-full',
|
'-full',
|
||||||
if (timeout != null)
|
if (timeout != null)
|
||||||
@ -70,13 +67,13 @@ class FuchsiaDevFinder {
|
|||||||
///
|
///
|
||||||
/// The string [deviceName] should be the name of the device from the
|
/// The string [deviceName] should be the name of the device from the
|
||||||
/// 'list' command, e.g. 'scare-cable-skip-joy'.
|
/// 'list' command, e.g. 'scare-cable-skip-joy'.
|
||||||
Future<String> resolve(String deviceName) async {
|
Future<String?> resolve(String deviceName) async {
|
||||||
if (_fuchsiaArtifacts.devFinder == null ||
|
final File? devFinder = _fuchsiaArtifacts?.devFinder;
|
||||||
!_fuchsiaArtifacts.devFinder.existsSync()) {
|
if (devFinder == null || !devFinder.existsSync()) {
|
||||||
throwToolExit('Fuchsia device-finder tool not found.');
|
throwToolExit('Fuchsia device-finder tool not found.');
|
||||||
}
|
}
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
_fuchsiaArtifacts.devFinder.path,
|
devFinder.path,
|
||||||
'resolve',
|
'resolve',
|
||||||
'-device-limit', '1',
|
'-device-limit', '1',
|
||||||
deviceName,
|
deviceName,
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
import 'package:file/file.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
@ -32,15 +30,15 @@ import 'fuchsia_sdk.dart';
|
|||||||
/// A simple wrapper for the Fuchsia SDK's 'ffx' tool.
|
/// A simple wrapper for the Fuchsia SDK's 'ffx' tool.
|
||||||
class FuchsiaFfx {
|
class FuchsiaFfx {
|
||||||
FuchsiaFfx({
|
FuchsiaFfx({
|
||||||
@required FuchsiaArtifacts fuchsiaArtifacts,
|
required FuchsiaArtifacts? fuchsiaArtifacts,
|
||||||
@required Logger logger,
|
required Logger logger,
|
||||||
@required ProcessManager processManager,
|
required ProcessManager processManager,
|
||||||
}) : _fuchsiaArtifacts = fuchsiaArtifacts,
|
}) : _fuchsiaArtifacts = fuchsiaArtifacts,
|
||||||
_logger = logger,
|
_logger = logger,
|
||||||
_processUtils =
|
_processUtils =
|
||||||
ProcessUtils(logger: logger, processManager: processManager);
|
ProcessUtils(logger: logger, processManager: processManager);
|
||||||
|
|
||||||
final FuchsiaArtifacts _fuchsiaArtifacts;
|
final FuchsiaArtifacts? _fuchsiaArtifacts;
|
||||||
final Logger _logger;
|
final Logger _logger;
|
||||||
final ProcessUtils _processUtils;
|
final ProcessUtils _processUtils;
|
||||||
|
|
||||||
@ -48,12 +46,13 @@ class FuchsiaFfx {
|
|||||||
/// formatted as follows:
|
/// formatted as follows:
|
||||||
///
|
///
|
||||||
/// abcd::abcd:abc:abcd:abcd%qemu scare-cable-skip-joy
|
/// abcd::abcd:abc:abcd:abcd%qemu scare-cable-skip-joy
|
||||||
Future<List<String>> list({Duration timeout}) async {
|
Future<List<String>?> list({Duration? timeout}) async {
|
||||||
if (_fuchsiaArtifacts.ffx == null || !_fuchsiaArtifacts.ffx.existsSync()) {
|
final File? ffx = _fuchsiaArtifacts?.ffx;
|
||||||
|
if (ffx == null || !ffx.existsSync()) {
|
||||||
throwToolExit('Fuchsia ffx tool not found.');
|
throwToolExit('Fuchsia ffx tool not found.');
|
||||||
}
|
}
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
_fuchsiaArtifacts.ffx.path,
|
ffx.path,
|
||||||
if (timeout != null)
|
if (timeout != null)
|
||||||
...<String>['-T', '${timeout.inSeconds}'],
|
...<String>['-T', '${timeout.inSeconds}'],
|
||||||
'target',
|
'target',
|
||||||
@ -76,12 +75,13 @@ class FuchsiaFfx {
|
|||||||
///
|
///
|
||||||
/// The string [deviceName] should be the name of the device from the
|
/// The string [deviceName] should be the name of the device from the
|
||||||
/// 'list' command, e.g. 'scare-cable-skip-joy'.
|
/// 'list' command, e.g. 'scare-cable-skip-joy'.
|
||||||
Future<String> resolve(String deviceName) async {
|
Future<String?> resolve(String deviceName) async {
|
||||||
if (_fuchsiaArtifacts.ffx == null || !_fuchsiaArtifacts.ffx.existsSync()) {
|
final File? ffx = _fuchsiaArtifacts?.ffx;
|
||||||
|
if (ffx == null || !ffx.existsSync()) {
|
||||||
throwToolExit('Fuchsia ffx tool not found.');
|
throwToolExit('Fuchsia ffx tool not found.');
|
||||||
}
|
}
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
_fuchsiaArtifacts.ffx.path,
|
ffx.path,
|
||||||
'target',
|
'target',
|
||||||
'list',
|
'list',
|
||||||
'--format',
|
'--format',
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
import '../artifacts.dart';
|
import '../artifacts.dart';
|
||||||
@ -21,8 +19,8 @@ class FuchsiaKernelCompiler {
|
|||||||
/// the Flutter tool should make no use of that fact), and a manifest that
|
/// the Flutter tool should make no use of that fact), and a manifest that
|
||||||
/// refers to them.
|
/// refers to them.
|
||||||
Future<void> build({
|
Future<void> build({
|
||||||
@required FuchsiaProject fuchsiaProject,
|
required FuchsiaProject fuchsiaProject,
|
||||||
@required String target, // E.g., lib/main.dart
|
required String target, // E.g., lib/main.dart
|
||||||
BuildInfo buildInfo = BuildInfo.debug,
|
BuildInfo buildInfo = BuildInfo.debug,
|
||||||
}) async {
|
}) async {
|
||||||
// TODO(zanderso): Use filesystem root and scheme information from buildInfo.
|
// TODO(zanderso): Use filesystem root and scheme information from buildInfo.
|
||||||
@ -33,20 +31,20 @@ class FuchsiaKernelCompiler {
|
|||||||
final String fsRoot = fuchsiaProject.project.directory.path;
|
final String fsRoot = fuchsiaProject.project.directory.path;
|
||||||
final String relativePackagesFile = globals.fs.path.relative(packagesFile, from: fsRoot);
|
final String relativePackagesFile = globals.fs.path.relative(packagesFile, from: fsRoot);
|
||||||
final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest');
|
final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest');
|
||||||
final String kernelCompiler = globals.artifacts.getArtifactPath(
|
final String? kernelCompiler = globals.artifacts?.getArtifactPath(
|
||||||
Artifact.fuchsiaKernelCompiler,
|
Artifact.fuchsiaKernelCompiler,
|
||||||
platform: TargetPlatform.fuchsia_arm64, // This file is not arch-specific.
|
platform: TargetPlatform.fuchsia_arm64, // This file is not arch-specific.
|
||||||
mode: buildInfo.mode,
|
mode: buildInfo.mode,
|
||||||
);
|
);
|
||||||
if (!globals.fs.isFileSync(kernelCompiler)) {
|
if (kernelCompiler == null || !globals.fs.isFileSync(kernelCompiler)) {
|
||||||
throwToolExit('Fuchsia kernel compiler not found at "$kernelCompiler"');
|
throwToolExit('Fuchsia kernel compiler not found at "$kernelCompiler"');
|
||||||
}
|
}
|
||||||
final String platformDill = globals.artifacts.getArtifactPath(
|
final String? platformDill = globals.artifacts?.getArtifactPath(
|
||||||
Artifact.platformKernelDill,
|
Artifact.platformKernelDill,
|
||||||
platform: TargetPlatform.fuchsia_arm64, // This file is not arch-specific.
|
platform: TargetPlatform.fuchsia_arm64, // This file is not arch-specific.
|
||||||
mode: buildInfo.mode,
|
mode: buildInfo.mode,
|
||||||
);
|
);
|
||||||
if (!globals.fs.isFileSync(platformDill)) {
|
if (platformDill == null || !globals.fs.isFileSync(platformDill)) {
|
||||||
throwToolExit('Fuchsia platform file not found at "$platformDill"');
|
throwToolExit('Fuchsia platform file not found at "$platformDill"');
|
||||||
}
|
}
|
||||||
List<String> flags = <String>[
|
List<String> flags = <String>[
|
||||||
@ -64,8 +62,12 @@ class FuchsiaKernelCompiler {
|
|||||||
'$multiRootScheme:///$target',
|
'$multiRootScheme:///$target',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
final String? engineDartBinaryPath = globals.artifacts?.getHostArtifact(HostArtifact.engineDartBinary).path;
|
||||||
|
if (engineDartBinaryPath == null) {
|
||||||
|
throwToolExit('Engine dart binary not found at "$engineDartBinaryPath"');
|
||||||
|
}
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
engineDartBinaryPath,
|
||||||
'--disable-dart-dev',
|
'--disable-dart-dev',
|
||||||
kernelCompiler,
|
kernelCompiler,
|
||||||
...flags,
|
...flags,
|
||||||
@ -87,8 +89,8 @@ class FuchsiaKernelCompiler {
|
|||||||
/// Provide flags that are affected by [BuildInfo]
|
/// Provide flags that are affected by [BuildInfo]
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static List<String> getBuildInfoFlags({
|
static List<String> getBuildInfoFlags({
|
||||||
@required BuildInfo buildInfo,
|
required BuildInfo buildInfo,
|
||||||
@required String manifestPath,
|
required String manifestPath,
|
||||||
}) {
|
}) {
|
||||||
return <String>[
|
return <String>[
|
||||||
// AOT/JIT:
|
// AOT/JIT:
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
import '../base/io.dart';
|
import '../base/io.dart';
|
||||||
import '../base/net.dart';
|
import '../base/net.dart';
|
||||||
import '../base/process.dart';
|
import '../base/process.dart';
|
||||||
import '../convert.dart';
|
import '../convert.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals_null_migrated.dart' as globals;
|
||||||
|
|
||||||
import 'fuchsia_sdk.dart';
|
import 'fuchsia_sdk.dart';
|
||||||
|
|
||||||
@ -92,14 +90,15 @@ class FuchsiaPM {
|
|||||||
/// [FuchsiaDevFinder.resolve] or [FuchsiaFfx.resolve] and [port] should be an unused port for the
|
/// [FuchsiaDevFinder.resolve] or [FuchsiaFfx.resolve] and [port] should be an unused port for the
|
||||||
/// http server to bind.
|
/// http server to bind.
|
||||||
Future<Process> serve(String repoPath, String host, int port) async {
|
Future<Process> serve(String repoPath, String host, int port) async {
|
||||||
if (globals.fuchsiaArtifacts.pm == null) {
|
final File? pm = globals.fuchsiaArtifacts?.pm;
|
||||||
|
if (pm == null) {
|
||||||
throwToolExit('Fuchsia pm tool not found');
|
throwToolExit('Fuchsia pm tool not found');
|
||||||
}
|
}
|
||||||
if (isIPv6Address(host.split('%').first)) {
|
if (isIPv6Address(host.split('%').first)) {
|
||||||
host = '[$host]';
|
host = '[$host]';
|
||||||
}
|
}
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
globals.fuchsiaArtifacts.pm.path,
|
pm.path,
|
||||||
'serve',
|
'serve',
|
||||||
'-repo',
|
'-repo',
|
||||||
repoPath,
|
repoPath,
|
||||||
@ -136,10 +135,11 @@ class FuchsiaPM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _runPMCommand(List<String> args) async {
|
Future<bool> _runPMCommand(List<String> args) async {
|
||||||
if (globals.fuchsiaArtifacts.pm == null) {
|
final File? pm = globals.fuchsiaArtifacts?.pm;
|
||||||
|
if (pm == null) {
|
||||||
throwToolExit('Fuchsia pm tool not found');
|
throwToolExit('Fuchsia pm tool not found');
|
||||||
}
|
}
|
||||||
final List<String> command = <String>[globals.fuchsiaArtifacts.pm.path, ...args];
|
final List<String> command = <String>[pm.path, ...args];
|
||||||
final RunResult result = await globals.processUtils.run(command);
|
final RunResult result = await globals.processUtils.run(command);
|
||||||
return result.exitCode == 0;
|
return result.exitCode == 0;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ class FuchsiaPackageServer {
|
|||||||
final String _host;
|
final String _host;
|
||||||
final int _port;
|
final int _port;
|
||||||
|
|
||||||
Process _process;
|
Process? _process;
|
||||||
|
|
||||||
// The name used to reference the server by fuchsia-pkg:// urls.
|
// The name used to reference the server by fuchsia-pkg:// urls.
|
||||||
final String name;
|
final String name;
|
||||||
@ -196,13 +196,14 @@ class FuchsiaPackageServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// initialize a new repo.
|
// initialize a new repo.
|
||||||
if (!await fuchsiaSdk.fuchsiaPM.newrepo(_repo)) {
|
final FuchsiaPM? fuchsiaPM = fuchsiaSdk?.fuchsiaPM;
|
||||||
|
if (fuchsiaPM == null || !await fuchsiaPM.newrepo(_repo)) {
|
||||||
globals.printError('Failed to create a new package server repo');
|
globals.printError('Failed to create a new package server repo');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_process = await fuchsiaSdk.fuchsiaPM.serve(_repo, _host, _port);
|
_process = await fuchsiaPM.serve(_repo, _host, _port);
|
||||||
// Put a completer on _process.exitCode to watch for error.
|
// Put a completer on _process.exitCode to watch for error.
|
||||||
unawaited(_process.exitCode.whenComplete(() {
|
unawaited(_process?.exitCode.whenComplete(() {
|
||||||
// If _process is null, then the server was stopped deliberately.
|
// If _process is null, then the server was stopped deliberately.
|
||||||
if (_process != null) {
|
if (_process != null) {
|
||||||
globals.printError('Error running Fuchsia pm tool "serve" command');
|
globals.printError('Error running Fuchsia pm tool "serve" command');
|
||||||
@ -214,7 +215,7 @@ class FuchsiaPackageServer {
|
|||||||
/// Forcefully stops the package server process by sending it SIGTERM.
|
/// Forcefully stops the package server process by sending it SIGTERM.
|
||||||
void stop() {
|
void stop() {
|
||||||
if (_process != null) {
|
if (_process != null) {
|
||||||
_process.kill();
|
_process?.kill();
|
||||||
_process = null;
|
_process = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,12 +229,12 @@ class FuchsiaPackageServer {
|
|||||||
if (_process == null) {
|
if (_process == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return fuchsiaSdk.fuchsiaPM.publish(_repo, package.path);
|
return (await fuchsiaSdk?.fuchsiaPM.publish(_repo, package.path)) == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
final String p = (_process == null) ? 'stopped' : 'running ${_process.pid}';
|
final String p = (_process == null) ? 'stopped' : 'running ${_process?.pid}';
|
||||||
return 'FuchsiaPackageServer at $_host:$_port ($p)';
|
return 'FuchsiaPackageServer at $_host:$_port ($p)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../base/context.dart';
|
import '../base/context.dart';
|
||||||
@ -11,7 +9,7 @@ import '../base/file_system.dart';
|
|||||||
import '../base/io.dart';
|
import '../base/io.dart';
|
||||||
import '../base/platform.dart';
|
import '../base/platform.dart';
|
||||||
import '../convert.dart';
|
import '../convert.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals_null_migrated.dart' as globals;
|
||||||
|
|
||||||
import 'fuchsia_dev_finder.dart';
|
import 'fuchsia_dev_finder.dart';
|
||||||
import 'fuchsia_ffx.dart';
|
import 'fuchsia_ffx.dart';
|
||||||
@ -19,7 +17,7 @@ import 'fuchsia_kernel_compiler.dart';
|
|||||||
import 'fuchsia_pm.dart';
|
import 'fuchsia_pm.dart';
|
||||||
|
|
||||||
/// The [FuchsiaSdk] instance.
|
/// The [FuchsiaSdk] instance.
|
||||||
FuchsiaSdk get fuchsiaSdk => context.get<FuchsiaSdk>();
|
FuchsiaSdk? get fuchsiaSdk => context.get<FuchsiaSdk>();
|
||||||
|
|
||||||
/// Returns [true] if the current platform supports Fuchsia targets.
|
/// Returns [true] if the current platform supports Fuchsia targets.
|
||||||
bool isFuchsiaSupportedPlatform(Platform platform) {
|
bool isFuchsiaSupportedPlatform(Platform platform) {
|
||||||
@ -32,26 +30,20 @@ bool isFuchsiaSupportedPlatform(Platform platform) {
|
|||||||
/// including a working fx command-line tool in the user's PATH.
|
/// including a working fx command-line tool in the user's PATH.
|
||||||
class FuchsiaSdk {
|
class FuchsiaSdk {
|
||||||
/// Interface to the 'pm' tool.
|
/// Interface to the 'pm' tool.
|
||||||
FuchsiaPM get fuchsiaPM => _fuchsiaPM ??= FuchsiaPM();
|
late final FuchsiaPM fuchsiaPM = FuchsiaPM();
|
||||||
FuchsiaPM _fuchsiaPM;
|
|
||||||
|
|
||||||
/// Interface to the 'device-finder' tool.
|
/// Interface to the 'device-finder' tool.
|
||||||
FuchsiaDevFinder _fuchsiaDevFinder;
|
late final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder(
|
||||||
FuchsiaDevFinder get fuchsiaDevFinder =>
|
|
||||||
_fuchsiaDevFinder ??= FuchsiaDevFinder(
|
|
||||||
fuchsiaArtifacts: globals.fuchsiaArtifacts,
|
fuchsiaArtifacts: globals.fuchsiaArtifacts,
|
||||||
logger: globals.logger,
|
logger: globals.logger,
|
||||||
processManager: globals.processManager
|
processManager: globals.processManager
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Interface to the 'kernel_compiler' tool.
|
/// Interface to the 'kernel_compiler' tool.
|
||||||
FuchsiaKernelCompiler _fuchsiaKernelCompiler;
|
late final FuchsiaKernelCompiler fuchsiaKernelCompiler = FuchsiaKernelCompiler();
|
||||||
FuchsiaKernelCompiler get fuchsiaKernelCompiler =>
|
|
||||||
_fuchsiaKernelCompiler ??= FuchsiaKernelCompiler();
|
|
||||||
|
|
||||||
/// Interface to the 'ffx' tool.
|
/// Interface to the 'ffx' tool.
|
||||||
FuchsiaFfx _fuchsiaFfx;
|
late final FuchsiaFfx fuchsiaFfx = FuchsiaFfx(
|
||||||
FuchsiaFfx get fuchsiaFfx => _fuchsiaFfx ??= FuchsiaFfx(
|
|
||||||
fuchsiaArtifacts: globals.fuchsiaArtifacts,
|
fuchsiaArtifacts: globals.fuchsiaArtifacts,
|
||||||
logger: globals.logger,
|
logger: globals.logger,
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
@ -60,17 +52,17 @@ class FuchsiaSdk {
|
|||||||
/// Returns any attached devices is a newline-denominated String.
|
/// Returns any attached devices is a newline-denominated String.
|
||||||
///
|
///
|
||||||
/// Example output: abcd::abcd:abc:abcd:abcd%qemu scare-cable-skip-joy
|
/// Example output: abcd::abcd:abc:abcd:abcd%qemu scare-cable-skip-joy
|
||||||
Future<String> listDevices({Duration timeout, bool useDeviceFinder = false}) async {
|
Future<String?> listDevices({Duration? timeout, bool useDeviceFinder = false}) async {
|
||||||
List<String> devices;
|
List<String>? devices;
|
||||||
if (useDeviceFinder) {
|
if (useDeviceFinder) {
|
||||||
if (globals.fuchsiaArtifacts.devFinder == null ||
|
final File? devFinder = globals.fuchsiaArtifacts?.devFinder;
|
||||||
!globals.fuchsiaArtifacts.devFinder.existsSync()) {
|
if (devFinder == null || !devFinder.existsSync()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
devices = await fuchsiaDevFinder.list(timeout: timeout);
|
devices = await fuchsiaDevFinder.list(timeout: timeout);
|
||||||
} else {
|
} else {
|
||||||
if (globals.fuchsiaArtifacts.ffx == null ||
|
final File? ffx = globals.fuchsiaArtifacts?.ffx;
|
||||||
!globals.fuchsiaArtifacts.ffx.existsSync()) {
|
if (ffx == null || !ffx.existsSync()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
devices = await fuchsiaFfx.list(timeout: timeout);
|
devices = await fuchsiaFfx.list(timeout: timeout);
|
||||||
@ -83,14 +75,14 @@ class FuchsiaSdk {
|
|||||||
|
|
||||||
/// Returns the fuchsia system logs for an attached device where
|
/// Returns the fuchsia system logs for an attached device where
|
||||||
/// [id] is the IP address of the device.
|
/// [id] is the IP address of the device.
|
||||||
Stream<String> syslogs(String id) {
|
Stream<String>? syslogs(String id) {
|
||||||
Process process;
|
Process? process;
|
||||||
try {
|
try {
|
||||||
final StreamController<String> controller = StreamController<String>(onCancel: () {
|
final StreamController<String> controller = StreamController<String>(onCancel: () {
|
||||||
process.kill();
|
process?.kill();
|
||||||
});
|
});
|
||||||
if (globals.fuchsiaArtifacts.sshConfig == null ||
|
final File? sshConfig = globals.fuchsiaArtifacts?.sshConfig;
|
||||||
!globals.fuchsiaArtifacts.sshConfig.existsSync()) {
|
if (sshConfig == null || !sshConfig.existsSync()) {
|
||||||
globals.printError('Cannot read device logs: No ssh config.');
|
globals.printError('Cannot read device logs: No ssh config.');
|
||||||
globals.printError('Have you set FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR?');
|
globals.printError('Have you set FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR?');
|
||||||
return null;
|
return null;
|
||||||
@ -99,7 +91,7 @@ class FuchsiaSdk {
|
|||||||
final List<String> cmd = <String>[
|
final List<String> cmd = <String>[
|
||||||
'ssh',
|
'ssh',
|
||||||
'-F',
|
'-F',
|
||||||
globals.fuchsiaArtifacts.sshConfig.absolute.path,
|
sshConfig.absolute.path,
|
||||||
id, // The device's IP.
|
id, // The device's IP.
|
||||||
remoteCommand,
|
remoteCommand,
|
||||||
];
|
];
|
||||||
@ -108,8 +100,8 @@ class FuchsiaSdk {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
process = newProcess;
|
process = newProcess;
|
||||||
process.exitCode.whenComplete(controller.close);
|
process?.exitCode.whenComplete(controller.close);
|
||||||
controller.addStream(process.stdout
|
controller.addStream(process!.stdout
|
||||||
.transform(utf8.decoder)
|
.transform(utf8.decoder)
|
||||||
.transform(const LineSplitter()));
|
.transform(const LineSplitter()));
|
||||||
});
|
});
|
||||||
@ -145,10 +137,10 @@ class FuchsiaArtifacts {
|
|||||||
// If FUCHSIA_BUILD_DIR is defined, then look for the ssh_config dir
|
// If FUCHSIA_BUILD_DIR is defined, then look for the ssh_config dir
|
||||||
// relative to it. Next, if FUCHSIA_SSH_CONFIG is defined, then use it.
|
// relative to it. Next, if FUCHSIA_SSH_CONFIG is defined, then use it.
|
||||||
// TODO(zanderso): Consider passing the ssh config path in with a flag.
|
// TODO(zanderso): Consider passing the ssh config path in with a flag.
|
||||||
File sshConfig;
|
File? sshConfig;
|
||||||
if (globals.platform.environment.containsKey(_kFuchsiaBuildDir)) {
|
if (globals.platform.environment.containsKey(_kFuchsiaBuildDir)) {
|
||||||
sshConfig = globals.fs.file(globals.fs.path.join(
|
sshConfig = globals.fs.file(globals.fs.path.join(
|
||||||
globals.platform.environment[_kFuchsiaBuildDir], 'ssh-keys', 'ssh_config'));
|
globals.platform.environment[_kFuchsiaBuildDir]!, 'ssh-keys', 'ssh_config'));
|
||||||
} else if (globals.platform.environment.containsKey(_kFuchsiaSshConfig)) {
|
} else if (globals.platform.environment.containsKey(_kFuchsiaSshConfig)) {
|
||||||
sshConfig = globals.fs.file(globals.platform.environment[_kFuchsiaSshConfig]);
|
sshConfig = globals.fs.file(globals.platform.environment[_kFuchsiaSshConfig]);
|
||||||
}
|
}
|
||||||
@ -172,19 +164,19 @@ class FuchsiaArtifacts {
|
|||||||
|
|
||||||
/// The location of the SSH configuration file used to interact with a
|
/// The location of the SSH configuration file used to interact with a
|
||||||
/// Fuchsia device.
|
/// Fuchsia device.
|
||||||
final File sshConfig;
|
final File? sshConfig;
|
||||||
|
|
||||||
/// The location of the dev finder tool used to locate connected
|
/// The location of the dev finder tool used to locate connected
|
||||||
/// Fuchsia devices.
|
/// Fuchsia devices.
|
||||||
final File devFinder;
|
final File? devFinder;
|
||||||
|
|
||||||
/// The location of the ffx tool used to locate connected
|
/// The location of the ffx tool used to locate connected
|
||||||
/// Fuchsia devices.
|
/// Fuchsia devices.
|
||||||
final File ffx;
|
final File? ffx;
|
||||||
|
|
||||||
/// The pm tool.
|
/// The pm tool.
|
||||||
final File pm;
|
final File? pm;
|
||||||
|
|
||||||
/// Returns true if the [sshConfig] file is not null and exists.
|
/// Returns true if the [sshConfig] file is not null and exists.
|
||||||
bool get hasSshConfig => sshConfig != null && sshConfig.existsSync();
|
bool get hasSshConfig => sshConfig != null && sshConfig!.existsSync();
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
import '../base/context.dart';
|
import '../base/context.dart';
|
||||||
import '../base/platform.dart';
|
import '../base/platform.dart';
|
||||||
import '../doctor_validator.dart';
|
import '../doctor_validator.dart';
|
||||||
@ -13,7 +9,7 @@ import '../features.dart';
|
|||||||
import 'fuchsia_sdk.dart';
|
import 'fuchsia_sdk.dart';
|
||||||
|
|
||||||
/// The [FuchsiaWorkflow] instance.
|
/// The [FuchsiaWorkflow] instance.
|
||||||
FuchsiaWorkflow get fuchsiaWorkflow => context.get<FuchsiaWorkflow>();
|
FuchsiaWorkflow? get fuchsiaWorkflow => context.get<FuchsiaWorkflow>();
|
||||||
|
|
||||||
/// The Fuchsia-specific implementation of a [Workflow].
|
/// The Fuchsia-specific implementation of a [Workflow].
|
||||||
///
|
///
|
||||||
@ -21,9 +17,9 @@ FuchsiaWorkflow get fuchsiaWorkflow => context.get<FuchsiaWorkflow>();
|
|||||||
/// including a working fx command-line tool in the user's PATH.
|
/// including a working fx command-line tool in the user's PATH.
|
||||||
class FuchsiaWorkflow implements Workflow {
|
class FuchsiaWorkflow implements Workflow {
|
||||||
FuchsiaWorkflow({
|
FuchsiaWorkflow({
|
||||||
@required Platform platform,
|
required Platform platform,
|
||||||
@required FeatureFlags featureFlags,
|
required FeatureFlags featureFlags,
|
||||||
@required FuchsiaArtifacts fuchsiaArtifacts,
|
required FuchsiaArtifacts fuchsiaArtifacts,
|
||||||
}) : _platform = platform,
|
}) : _platform = platform,
|
||||||
_featureFlags = featureFlags,
|
_featureFlags = featureFlags,
|
||||||
_fuchsiaArtifacts = fuchsiaArtifacts;
|
_fuchsiaArtifacts = fuchsiaArtifacts;
|
||||||
@ -36,7 +32,7 @@ class FuchsiaWorkflow implements Workflow {
|
|||||||
bool get appliesToHostPlatform => _featureFlags.isFuchsiaEnabled && (_platform.isLinux || _platform.isMacOS);
|
bool get appliesToHostPlatform => _featureFlags.isFuchsiaEnabled && (_platform.isLinux || _platform.isMacOS);
|
||||||
|
|
||||||
bool get shouldUseDeviceFinder {
|
bool get shouldUseDeviceFinder {
|
||||||
final String useDeviceFinder = _platform.environment.containsKey('FUCHSIA_DISABLED_ffx_discovery')
|
final String? useDeviceFinder = _platform.environment.containsKey('FUCHSIA_DISABLED_ffx_discovery')
|
||||||
? _platform.environment['FUCHSIA_DISABLED_ffx_discovery'] : '0';
|
? _platform.environment['FUCHSIA_DISABLED_ffx_discovery'] : '0';
|
||||||
if (useDeviceFinder == '1') {
|
if (useDeviceFinder == '1') {
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
import 'base/context.dart';
|
import 'base/context.dart';
|
||||||
import 'device.dart';
|
import 'device.dart';
|
||||||
import 'doctor.dart';
|
import 'doctor.dart';
|
||||||
import 'fuchsia/fuchsia_sdk.dart';
|
|
||||||
import 'ios/simulators.dart';
|
import 'ios/simulators.dart';
|
||||||
import 'macos/xcdevice.dart';
|
import 'macos/xcdevice.dart';
|
||||||
import 'reporting/crash_reporting.dart';
|
import 'reporting/crash_reporting.dart';
|
||||||
@ -17,7 +16,6 @@ export 'globals_null_migrated.dart';
|
|||||||
CrashReporter get crashReporter => context.get<CrashReporter>();
|
CrashReporter get crashReporter => context.get<CrashReporter>();
|
||||||
Doctor get doctor => context.get<Doctor>();
|
Doctor get doctor => context.get<Doctor>();
|
||||||
DeviceManager get deviceManager => context.get<DeviceManager>();
|
DeviceManager get deviceManager => context.get<DeviceManager>();
|
||||||
FuchsiaArtifacts get fuchsiaArtifacts => context.get<FuchsiaArtifacts>();
|
|
||||||
IOSSimulatorUtils get iosSimulatorUtils => context.get<IOSSimulatorUtils>();
|
IOSSimulatorUtils get iosSimulatorUtils => context.get<IOSSimulatorUtils>();
|
||||||
|
|
||||||
XCDevice get xcdevice => context.get<XCDevice>();
|
XCDevice get xcdevice => context.get<XCDevice>();
|
||||||
|
@ -27,6 +27,7 @@ import 'base/user_messages.dart';
|
|||||||
import 'build_system/build_system.dart';
|
import 'build_system/build_system.dart';
|
||||||
import 'cache.dart';
|
import 'cache.dart';
|
||||||
import 'custom_devices/custom_devices_config.dart';
|
import 'custom_devices/custom_devices_config.dart';
|
||||||
|
import 'fuchsia/fuchsia_sdk.dart';
|
||||||
import 'ios/ios_workflow.dart';
|
import 'ios/ios_workflow.dart';
|
||||||
import 'ios/plist_parser.dart';
|
import 'ios/plist_parser.dart';
|
||||||
import 'ios/xcodeproj.dart';
|
import 'ios/xcodeproj.dart';
|
||||||
@ -54,6 +55,7 @@ Signals get signals => context.get<Signals>() ?? LocalSignals.instance;
|
|||||||
AndroidStudio? get androidStudio => context.get<AndroidStudio>();
|
AndroidStudio? get androidStudio => context.get<AndroidStudio>();
|
||||||
AndroidSdk? get androidSdk => context.get<AndroidSdk>();
|
AndroidSdk? get androidSdk => context.get<AndroidSdk>();
|
||||||
FlutterVersion get flutterVersion => context.get<FlutterVersion>()!;
|
FlutterVersion get flutterVersion => context.get<FlutterVersion>()!;
|
||||||
|
FuchsiaArtifacts? get fuchsiaArtifacts => context.get<FuchsiaArtifacts>();
|
||||||
Usage get flutterUsage => context.get<Usage>()!;
|
Usage get flutterUsage => context.get<Usage>()!;
|
||||||
XcodeProjectInterpreter? get xcodeProjectInterpreter => context.get<XcodeProjectInterpreter>();
|
XcodeProjectInterpreter? get xcodeProjectInterpreter => context.get<XcodeProjectInterpreter>();
|
||||||
Xcode? get xcode => context.get<Xcode>();
|
Xcode? get xcode => context.get<Xcode>();
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
@ -16,10 +14,10 @@ import '../../src/common.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
FakeFuchsiaArtifacts fuchsiaArtifacts;
|
late FakeFuchsiaArtifacts fuchsiaArtifacts;
|
||||||
BufferLogger logger;
|
late BufferLogger logger;
|
||||||
MemoryFileSystem memoryFileSystem;
|
late MemoryFileSystem memoryFileSystem;
|
||||||
File deviceFinder;
|
late File deviceFinder;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
fuchsiaArtifacts = FakeFuchsiaArtifacts();
|
fuchsiaArtifacts = FakeFuchsiaArtifacts();
|
||||||
@ -134,5 +132,5 @@ void main() {
|
|||||||
|
|
||||||
class FakeFuchsiaArtifacts extends Fake implements FuchsiaArtifacts {
|
class FakeFuchsiaArtifacts extends Fake implements FuchsiaArtifacts {
|
||||||
@override
|
@override
|
||||||
File devFinder;
|
File? devFinder;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
@ -16,10 +14,10 @@ import '../../src/common.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
|
late FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
|
||||||
BufferLogger logger;
|
late BufferLogger logger;
|
||||||
MemoryFileSystem memoryFileSystem;
|
late MemoryFileSystem memoryFileSystem;
|
||||||
File ffx;
|
late File ffx;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
fakeFuchsiaArtifacts = FakeFuchsiaArtifacts();
|
fakeFuchsiaArtifacts = FakeFuchsiaArtifacts();
|
||||||
@ -212,5 +210,5 @@ void main() {
|
|||||||
|
|
||||||
class FakeFuchsiaArtifacts extends Fake implements FuchsiaArtifacts {
|
class FakeFuchsiaArtifacts extends Fake implements FuchsiaArtifacts {
|
||||||
@override
|
@override
|
||||||
File ffx;
|
File? ffx;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_tools/src/build_info.dart';
|
import 'package:flutter_tools/src/build_info.dart';
|
||||||
import 'package:flutter_tools/src/fuchsia/fuchsia_kernel_compiler.dart';
|
import 'package:flutter_tools/src/fuchsia/fuchsia_kernel_compiler.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/platform.dart';
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user