Update for flutter 3.10.0 (#182)

Signed-off-by: Hidenori Matsubayashi <hidenori.matsubayashi@gmail.com>
This commit is contained in:
Hidenori Matsubayashi
2023-05-20 04:58:32 +09:00
committed by GitHub
parent de7b47e54f
commit 070d039f2d
22 changed files with 336 additions and 392 deletions
+1 -3
View File
@@ -1,10 +1,8 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// 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_elinux/executable.dart' as executable; import 'package:flutter_elinux/executable.dart' as executable;
void main(List<String> args) { void main(List<String> args) {
+1 -1
View File
@@ -1 +1 @@
1a65d409c7a1438a34d21b60bf30a6fd5db59314 d44b5a94c976fbb65815374f61ab5392a220b084
+1 -1
View File
@@ -1 +1 @@
4d9e56e694b656610ab87fcf2efbcd226e0ed8cf 84a1e904f44f9b0e9c4510138010edcc653163f8
+11 -7
View File
@@ -1,10 +1,8 @@
// Copyright 2022 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// 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/commands/analyze.dart'; import 'package:flutter_tools/src/commands/analyze.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project_validator.dart'; import 'package:flutter_tools/src/project_validator.dart';
@@ -12,17 +10,23 @@ import 'package:flutter_tools/src/project_validator.dart';
import '../elinux_plugins.dart'; import '../elinux_plugins.dart';
class ELinuxAnalyzeCommand extends AnalyzeCommand with ELinuxExtension { class ELinuxAnalyzeCommand extends AnalyzeCommand with ELinuxExtension {
ELinuxAnalyzeCommand({bool verboseHelp = false}) ELinuxAnalyzeCommand({super.verboseHelp})
: super( : super(
verboseHelp: verboseHelp,
fileSystem: globals.fs, fileSystem: globals.fs,
platform: globals.platform, platform: globals.platform,
processManager: globals.processManager, processManager: globals.processManager,
logger: globals.logger, logger: globals.logger,
terminal: globals.terminal, terminal: globals.terminal,
artifacts: globals.artifacts, artifacts: globals.artifacts!,
// new ProjectValidators should be added here for the --suggestions to run
allProjectValidators: <ProjectValidator>[ allProjectValidators: <ProjectValidator>[
GeneralInfoProjectValidator() GeneralInfoProjectValidator(),
VariableDumpMachineProjectValidator(
logger: globals.logger,
fileSystem: globals.fs,
platform: globals.platform,
),
], ],
suppressAnalytics: globals.flutterUsage.suppressAnalytics,
); );
} }
+4 -10
View File
@@ -3,8 +3,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/android/build_validation.dart' as android; import 'package:flutter_tools/src/android/build_validation.dart' as android;
import 'package:flutter_tools/src/base/analyze_size.dart'; import 'package:flutter_tools/src/base/analyze_size.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
@@ -57,7 +55,6 @@ class BuildPackageCommand extends BuildSubCommand
); );
argParser.addOption( argParser.addOption(
'target-compiler-triple', 'target-compiler-triple',
defaultsTo: null,
help: 'Target compiler triple for which the app is compiled. ' help: 'Target compiler triple for which the app is compiled. '
'e.g. aarch64-linux-gnu', 'e.g. aarch64-linux-gnu',
); );
@@ -70,12 +67,10 @@ class BuildPackageCommand extends BuildSubCommand
); );
argParser.addOption( argParser.addOption(
'target-toolchain', 'target-toolchain',
defaultsTo: null,
help: 'The toolchain path for Clang.', help: 'The toolchain path for Clang.',
); );
argParser.addOption( argParser.addOption(
'system-include-directories', 'system-include-directories',
defaultsTo: null,
help: help:
'The additional system include paths to cross-compile for target platform. ' 'The additional system include paths to cross-compile for target platform. '
'This option is valid only ' 'This option is valid only '
@@ -83,7 +78,6 @@ class BuildPackageCommand extends BuildSubCommand
); );
argParser.addOption( argParser.addOption(
'target-compiler-flags', 'target-compiler-flags',
defaultsTo: null,
help: 'The extra compile flags to be applied to C and C++ compiler', help: 'The extra compile flags to be applied to C and C++ compiler',
); );
} }
@@ -118,7 +112,7 @@ class BuildPackageCommand extends BuildSubCommand
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
// Not supported cross-building for x64 on arm64. // Not supported cross-building for x64 on arm64.
final String targetArch = stringArg('target-arch'); final String? targetArch = stringArg('target-arch');
final String hostArch = _getCurrentHostPlatformArchName(); final String hostArch = _getCurrentHostPlatformArchName();
if (hostArch != targetArch && hostArch == 'arm64') { if (hostArch != targetArch && hostArch == 'arm64') {
globals.logger globals.logger
@@ -129,10 +123,10 @@ class BuildPackageCommand extends BuildSubCommand
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo( final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(
buildInfo, buildInfo,
targetArch: targetArch, targetArch: targetArch!,
targetBackendType: stringArg('target-backend-type'), targetBackendType: stringArg('target-backend-type')!,
targetCompilerTriple: stringArg('target-compiler-triple'), targetCompilerTriple: stringArg('target-compiler-triple'),
targetSysroot: stringArg('target-sysroot'), targetSysroot: stringArg('target-sysroot')!,
targetCompilerFlags: stringArg('target-compiler-flags'), targetCompilerFlags: stringArg('target-compiler-flags'),
targetToolchain: stringArg('target-toolchain'), targetToolchain: stringArg('target-toolchain'),
systemIncludeDirectories: stringArg('system-include-directories'), systemIncludeDirectories: stringArg('system-include-directories'),
+3 -5
View File
@@ -1,10 +1,8 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// 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:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/commands/clean.dart'; import 'package:flutter_tools/src/commands/clean.dart';
@@ -16,7 +14,7 @@ import 'package:path/path.dart';
import '../elinux_cmake_project.dart'; import '../elinux_cmake_project.dart';
class ELinuxCleanCommand extends CleanCommand { class ELinuxCleanCommand extends CleanCommand {
ELinuxCleanCommand({bool verbose = false}) : super(verbose: verbose); ELinuxCleanCommand({super.verbose});
/// See: [CleanCommand.runCommand] in `clean.dart` /// See: [CleanCommand.runCommand] in `clean.dart`
@override @override
@@ -48,7 +46,7 @@ class ELinuxCleanCommand extends CleanCommand {
} on FileSystemException catch (error) { } on FileSystemException catch (error) {
globals.printError('Failed to remove $path: $error'); globals.printError('Failed to remove $path: $error');
} finally { } finally {
status?.stop(); status.stop();
} }
} }
} }
+10 -13
View File
@@ -1,11 +1,9 @@
// Copyright 2022 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved.
// 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:io'; import 'dart:io';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
@@ -30,11 +28,10 @@ const List<String> _kAvailablePlatforms = <String>[
]; ];
class ELinuxCreateCommand extends CreateCommand { class ELinuxCreateCommand extends CreateCommand {
ELinuxCreateCommand({bool verboseHelp = false}) ELinuxCreateCommand({super.verboseHelp});
: super(verboseHelp: verboseHelp);
@override @override
void addPlatformsOptions({String customHelp}) { void addPlatformsOptions({String? customHelp}) {
argParser.addMultiOption( argParser.addMultiOption(
'platforms', 'platforms',
help: customHelp, help: customHelp,
@@ -47,7 +44,7 @@ class ELinuxCreateCommand extends CreateCommand {
Future<int> renderTemplate( Future<int> renderTemplate(
String templateName, String templateName,
Directory directory, Directory directory,
Map<String, Object> context, { Map<String, Object?> context, {
bool overwrite = false, bool overwrite = false,
bool printStatusWhenWriting = true, bool printStatusWhenWriting = true,
}) async { }) async {
@@ -67,7 +64,7 @@ class ELinuxCreateCommand extends CreateCommand {
Future<int> renderMerged( Future<int> renderMerged(
List<String> names, List<String> names,
Directory directory, Directory directory,
Map<String, Object> context, { Map<String, Object?> context, {
bool overwrite = false, bool overwrite = false,
bool printStatusWhenWriting = true, bool printStatusWhenWriting = true,
}) async { }) async {
@@ -79,14 +76,14 @@ class ELinuxCreateCommand extends CreateCommand {
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
templateRenderer: globals.templateRenderer, templateRenderer: globals.templateRenderer,
templateManifest: null, templateManifest: <Uri>{},
); );
return template.render(directory, context, overwriteExisting: overwrite); return template.render(directory, context, overwriteExisting: overwrite);
} }
/// See: [CreateCommand._getProjectType] in `create.dart` /// See: [CreateCommand._getProjectType] in `create.dart`
bool get _shouldGeneratePlugin { bool get _shouldGeneratePlugin {
if (argResults['template'] != null) { if (argResults!['template'] != null) {
return stringArg('template') == 'plugin'; return stringArg('template') == 'plugin';
} else if (projectDir.existsSync() && projectDir.listSync().isNotEmpty) { } else if (projectDir.existsSync() && projectDir.listSync().isNotEmpty) {
return determineTemplateType() == FlutterProjectType.plugin; return determineTemplateType() == FlutterProjectType.plugin;
@@ -114,7 +111,7 @@ class ELinuxCreateCommand extends CreateCommand {
// The dart project_name is in snake_case, this variable is the Title Case of the Project Name. // The dart project_name is in snake_case, this variable is the Title Case of the Project Name.
final String titleCaseProjectName = snakeCaseToTitleCase(projectName); final String titleCaseProjectName = snakeCaseToTitleCase(projectName);
final Map<String, Object> templateContext = createTemplateContext( final Map<String, Object?> templateContext = createTemplateContext(
organization: '', organization: '',
projectName: projectName, projectName: projectName,
flutterRoot: '', flutterRoot: '',
@@ -140,12 +137,12 @@ class ELinuxCreateCommand extends CreateCommand {
/// - [Template.render] in `template.dart` /// - [Template.render] in `template.dart`
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
if (argResults.rest.isEmpty) { if (argResults!.rest.isEmpty) {
return super.runCommand(); return super.runCommand();
} }
final List<String> platforms = stringsArg('platforms'); final List<String> platforms = stringsArg('platforms');
bool shouldRenderELinuxTemplate = platforms.contains('elinux'); bool shouldRenderELinuxTemplate = platforms.contains('elinux');
if (_shouldGeneratePlugin && !argResults.wasParsed('platforms')) { if (_shouldGeneratePlugin && !argResults!.wasParsed('platforms')) {
shouldRenderELinuxTemplate = false; shouldRenderELinuxTemplate = false;
} }
if (!shouldRenderELinuxTemplate) { if (!shouldRenderELinuxTemplate) {
+1 -4
View File
@@ -3,8 +3,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/commands/drive.dart'; import 'package:flutter_tools/src/commands/drive.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
@@ -13,9 +11,8 @@ import '../elinux_plugins.dart';
class ELinuxDriveCommand extends DriveCommand class ELinuxDriveCommand extends DriveCommand
with ELinuxExtension, ELinuxRequiredArtifacts { with ELinuxExtension, ELinuxRequiredArtifacts {
ELinuxDriveCommand({bool verboseHelp = false}) ELinuxDriveCommand({super.verboseHelp})
: super( : super(
verboseHelp: verboseHelp,
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
platform: globals.platform, platform: globals.platform,
+20 -21
View File
@@ -1,13 +1,12 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved.
// 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/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/commands/packages.dart'; import 'package:flutter_tools/src/commands/packages.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart';
@@ -21,13 +20,18 @@ import '../elinux_plugins.dart';
/// Source: [PackagesCommand] in `packages.dart` /// Source: [PackagesCommand] in `packages.dart`
class ELinuxPackagesCommand extends FlutterCommand { class ELinuxPackagesCommand extends FlutterCommand {
ELinuxPackagesCommand() { ELinuxPackagesCommand() {
addSubcommand(ELinuxPackagesGetCommand('get', false)); addSubcommand(ELinuxPackagesGetCommand(
addSubcommand(ELinuxPackagesInteractiveGetCommand('upgrade', 'get', "Get the current package's dependencies.", PubContext.pubGet));
"Upgrade the current package's dependencies to latest versions.")); addSubcommand(ELinuxPackagesGetCommand(
addSubcommand(ELinuxPackagesInteractiveGetCommand( 'upgrade',
'add', 'Add a dependency to pubspec.yaml.')); "Upgrade the current package's dependencies to latest versions.",
addSubcommand(ELinuxPackagesInteractiveGetCommand( PubContext.pubUpgrade));
'remove', 'Removes a dependency from the current package.')); addSubcommand(ELinuxPackagesGetCommand(
'add', 'Add a dependency to pubspec.yaml.', PubContext.pubAdd));
addSubcommand(ELinuxPackagesGetCommand(
'remove',
'Removes a dependency from the current package.',
PubContext.pubRemove));
addSubcommand(PackagesTestCommand()); addSubcommand(PackagesTestCommand());
addSubcommand(PackagesForwardCommand( addSubcommand(PackagesForwardCommand(
'publish', 'Publish the current package to pub.dartlang.org', 'publish', 'Publish the current package to pub.dartlang.org',
@@ -65,18 +69,13 @@ class ELinuxPackagesCommand extends FlutterCommand {
final String description = 'Commands for managing Flutter packages.'; final String description = 'Commands for managing Flutter packages.';
@override @override
Future<FlutterCommandResult> runCommand() async => null; Future<FlutterCommandResult> runCommand() async =>
FlutterCommandResult.fail();
} }
class ELinuxPackagesGetCommand extends PackagesGetCommand class ELinuxPackagesGetCommand extends PackagesGetCommand
with _PostRunPluginInjection { with _PostRunPluginInjection {
ELinuxPackagesGetCommand(String name, bool upgrade) : super(name, upgrade); ELinuxPackagesGetCommand(super.commandName, super.description, super.context);
}
class ELinuxPackagesInteractiveGetCommand extends PackagesInteractiveGetCommand
with _PostRunPluginInjection {
ELinuxPackagesInteractiveGetCommand(String commandName, String description)
: super(commandName, description);
} }
mixin _PostRunPluginInjection on FlutterCommand { mixin _PostRunPluginInjection on FlutterCommand {
@@ -86,9 +85,9 @@ mixin _PostRunPluginInjection on FlutterCommand {
final FlutterCommandResult result = await super.runCommand(); final FlutterCommandResult result = await super.runCommand();
if (result == FlutterCommandResult.success()) { if (result == FlutterCommandResult.success()) {
final String workingDirectory = final String? workingDirectory =
argResults.rest.isNotEmpty ? argResults.rest[0] : null; argResults!.rest.isNotEmpty ? argResults!.rest[0] : null;
final String target = findProjectRoot(globals.fs, workingDirectory); final String? target = findProjectRoot(globals.fs, workingDirectory);
if (target == null) { if (target == null) {
return result; return result;
} }
+9 -24
View File
@@ -1,41 +1,26 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved.
// 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/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/precache.dart'; import 'package:flutter_tools/src/commands/precache.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:meta/meta.dart';
import '../elinux_cache.dart'; import '../elinux_cache.dart';
class ELinuxPrecacheCommand extends PrecacheCommand { class ELinuxPrecacheCommand extends PrecacheCommand {
ELinuxPrecacheCommand({ ELinuxPrecacheCommand({
bool verboseHelp = false, super.verboseHelp,
@required Cache cache, required super.cache,
@required Platform platform, required super.platform,
@required Logger logger, required super.logger,
@required FeatureFlags featureFlags, required super.featureFlags,
}) : _cache = cache, }) : _cache = cache,
_platform = platform, _platform = platform {
super(
verboseHelp: verboseHelp,
cache: cache,
platform: platform,
logger: logger,
featureFlags: featureFlags,
) {
argParser.addFlag( argParser.addFlag(
'elinux', 'elinux',
negatable: true,
defaultsTo: false,
help: 'Precache artifacts for Embedded Linux development.', help: 'Precache artifacts for Embedded Linux development.',
); );
} }
@@ -46,7 +31,7 @@ class ELinuxPrecacheCommand extends PrecacheCommand {
bool get _includeOtherPlatforms => bool get _includeOtherPlatforms =>
boolArg('android') || boolArg('android') ||
DevelopmentArtifact.values.any((DevelopmentArtifact artifact) => DevelopmentArtifact.values.any((DevelopmentArtifact artifact) =>
boolArg(artifact.name) && argResults.wasParsed(artifact.name)); boolArg(artifact.name) && argResults!.wasParsed(artifact.name));
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
@@ -73,7 +58,7 @@ class ELinuxPrecacheCommand extends PrecacheCommand {
if (includeAllPlatforms || includeDefaults || _includeOtherPlatforms) { if (includeAllPlatforms || includeDefaults || _includeOtherPlatforms) {
// If the '--force' option is used, the super.runCommand() will delete // If the '--force' option is used, the super.runCommand() will delete
// the elinux's stamp file. It should be restored. // the elinux's stamp file. It should be restored.
final String elinuxStamp = _cache.getStampFor(elinuxStampName); final String? elinuxStamp = _cache.getStampFor(elinuxStampName);
final FlutterCommandResult result = await super.runCommand(); final FlutterCommandResult result = await super.runCommand();
if (elinuxStamp != null) { if (elinuxStamp != null) {
_cache.setStampFor(elinuxStampName, elinuxStamp); _cache.setStampFor(elinuxStampName, elinuxStamp);
+2 -5
View File
@@ -1,10 +1,8 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// 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/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
@@ -15,8 +13,7 @@ import '../elinux_plugins.dart';
class ELinuxRunCommand extends RunCommand class ELinuxRunCommand extends RunCommand
with ELinuxExtension, ELinuxRequiredArtifacts { with ELinuxExtension, ELinuxRequiredArtifacts {
ELinuxRunCommand({bool verboseHelp = false}) ELinuxRunCommand({super.verboseHelp});
: super(verboseHelp: verboseHelp);
@override @override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => Future<Set<DevelopmentArtifact>> get requiredArtifacts async =>
+2 -5
View File
@@ -1,15 +1,12 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved.
// 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/commands/test.dart'; import 'package:flutter_tools/src/commands/test.dart';
import '../elinux_plugins.dart'; import '../elinux_plugins.dart';
class ELinuxTestCommand extends TestCommand with ELinuxExtension { class ELinuxTestCommand extends TestCommand with ELinuxExtension {
ELinuxTestCommand({bool verboseHelp = false}) ELinuxTestCommand({super.verboseHelp});
: super(verboseHelp: verboseHelp);
} }
+21 -23
View File
@@ -3,8 +3,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:convert'; import 'dart:convert';
import 'dart:core'; import 'dart:core';
@@ -24,8 +22,8 @@ import 'package:meta/meta.dart';
/// Source: [UpgradeCommand] in `upgrade.dart` /// Source: [UpgradeCommand] in `upgrade.dart`
class ELinuxUpgradeCommand extends UpgradeCommand { class ELinuxUpgradeCommand extends UpgradeCommand {
ELinuxUpgradeCommand({ ELinuxUpgradeCommand({
@required bool verboseHelp, required super.verboseHelp,
}) : super(verboseHelp: verboseHelp); });
@override @override
Future<FlutterCommandResult> runCommand() { Future<FlutterCommandResult> runCommand() {
@@ -50,25 +48,25 @@ class ELinuxGitTagVersion {
); );
/// The git hash (or an abbreviation thereof) for this commit. /// The git hash (or an abbreviation thereof) for this commit.
final String hash; final String? hash;
/// The git short hash (or an abbreviation thereof) for this commit. /// The git short hash (or an abbreviation thereof) for this commit.
final String hashShort; final String hashShort;
/// The git tag that is this version's closest ancestor. /// The git tag that is this version's closest ancestor.
final String gitTag; final String? gitTag;
} }
/// Source: [UpgradeCommandRunner] in `upgrade.dart` /// Source: [UpgradeCommandRunner] in `upgrade.dart`
@visibleForTesting @visibleForTesting
class ELinuxUpgradeCommandRunner { class ELinuxUpgradeCommandRunner {
String workingDirectory; String? workingDirectory;
Future<FlutterCommandResult> runCommand({ Future<FlutterCommandResult> runCommand({
@required bool force, required bool force,
@required bool continueFlow, required bool continueFlow,
@required bool testFlow, required bool testFlow,
@required bool verifyOnly, required bool verifyOnly,
}) async { }) async {
if (!continueFlow) { if (!continueFlow) {
await runCommandFirstHalf( await runCommandFirstHalf(
@@ -83,9 +81,9 @@ class ELinuxUpgradeCommandRunner {
} }
Future<void> runCommandFirstHalf({ Future<void> runCommandFirstHalf({
@required bool force, required bool force,
@required bool testFlow, required bool testFlow,
@required bool verifyOnly, required bool verifyOnly,
}) async { }) async {
ELinuxGitTagVersion upstreamVersion = await fetchTaggedLatestVersion(); ELinuxGitTagVersion upstreamVersion = await fetchTaggedLatestVersion();
final ELinuxGitTagVersion currentVersion = await fetchCurrentVersion(); final ELinuxGitTagVersion currentVersion = await fetchCurrentVersion();
@@ -98,7 +96,7 @@ class ELinuxUpgradeCommandRunner {
if (currentVersion.hash == upstreamVersion.hash) { if (currentVersion.hash == upstreamVersion.hash) {
globals.printStatus('flutter-elinux is already up to date'); globals.printStatus('flutter-elinux is already up to date');
globals.printStatus(upstreamVersion.gitTag); globals.printStatus(upstreamVersion.gitTag!);
return; return;
} }
@@ -206,8 +204,8 @@ class ELinuxUpgradeCommandRunner {
} }
Future<ELinuxGitTagVersion> fetchCurrentVersion() async { Future<ELinuxGitTagVersion> fetchCurrentVersion() async {
String tag; String? tag;
String latestRevision; String? latestRevision;
try { try {
RunResult result = await globals.processUtils.run( RunResult result = await globals.processUtils.run(
<String>['git', 'rev-parse', '--verify', 'HEAD'], <String>['git', 'rev-parse', '--verify', 'HEAD'],
@@ -243,14 +241,14 @@ class ELinuxUpgradeCommandRunner {
} }
} }
return ELinuxGitTagVersion( return ELinuxGitTagVersion(
latestRevision, latestRevision.substring(0, 10), tag); latestRevision, latestRevision!.substring(0, 10), tag);
} }
/// Source: [attemptReset] in `upgrade.dart` (exact copy) /// Source: [attemptReset] in `upgrade.dart` (exact copy)
Future<void> attemptReset(String newRevision) async { Future<void> attemptReset(String? newRevision) async {
try { try {
await globals.processUtils.run( await globals.processUtils.run(
<String>['git', 'reset', '--hard', newRevision], <String>['git', 'reset', '--hard', newRevision!],
throwOnError: true, throwOnError: true,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
); );
@@ -280,12 +278,12 @@ class ELinuxUpgradeCommandRunner {
/// Source: [runCommandSecondHalf] in `upgrade.dart` /// Source: [runCommandSecondHalf] in `upgrade.dart`
Future<void> runCommandSecondHalf() async { Future<void> runCommandSecondHalf() async {
// Make sure the welcome message re-display is delayed until the end. // Make sure the welcome message re-display is delayed until the end.
globals.persistentToolState.setShouldRedisplayWelcomeMessage(false); globals.persistentToolState?.setShouldRedisplayWelcomeMessage(false);
await precacheArtifacts(); await precacheArtifacts();
await updatePackages(); await updatePackages();
await runDoctor(); await runDoctor();
// Force the welcome message to re-display following the upgrade. // Force the welcome message to re-display following the upgrade.
globals.persistentToolState.setShouldRedisplayWelcomeMessage(true); globals.persistentToolState?.setShouldRedisplayWelcomeMessage(true);
} }
/// Source: [precacheArtifacts] in `upgrade.dart` /// Source: [precacheArtifacts] in `upgrade.dart`
@@ -311,7 +309,7 @@ class ELinuxUpgradeCommandRunner {
/// Source: [updatePackages] in `upgrade.dart` /// Source: [updatePackages] in `upgrade.dart`
Future<void> updatePackages() async { Future<void> updatePackages() async {
globals.printStatus(''); globals.printStatus('');
final String projectRoot = findProjectRoot(globals.fs); final String? projectRoot = findProjectRoot(globals.fs);
if (projectRoot != null) { if (projectRoot != null) {
globals.printStatus(''); globals.printStatus('');
await pub.get( await pub.get(
+53 -53
View File
@@ -1,11 +1,9 @@
// Copyright 2022 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved.
// 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:io'; import 'dart:io';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
@@ -29,7 +27,6 @@ import 'package:flutter_tools/src/project.dart';
import 'elinux_builder.dart'; import 'elinux_builder.dart';
import 'elinux_cmake_project.dart'; import 'elinux_cmake_project.dart';
import 'elinux_plugins.dart';
/// Prepares the pre-built flutter bundle. /// Prepares the pre-built flutter bundle.
/// ///
@@ -67,7 +64,7 @@ abstract class ELinuxAssetBundle extends Target {
throw MissingDefineException(kBuildMode, name); throw MissingDefineException(kBuildMode, name);
} }
final BuildMode buildMode = final BuildMode buildMode =
getBuildModeForName(environment.defines[kBuildMode]); getBuildModeForName(environment.defines[kBuildMode]!);
final Directory outputDirectory = environment.outputDir final Directory outputDirectory = environment.outputDir
.childDirectory('flutter_assets') .childDirectory('flutter_assets')
..createSync(recursive: true); ..createSync(recursive: true);
@@ -111,7 +108,7 @@ abstract class ELinuxAssetBundle extends Target {
/// Source: [DebugAndroidApplication] in `android.dart` /// Source: [DebugAndroidApplication] in `android.dart`
class DebugELinuxApplication extends ELinuxAssetBundle { class DebugELinuxApplication extends ELinuxAssetBundle {
DebugELinuxApplication(ELinuxBuildInfo buildInfo) : super(buildInfo); DebugELinuxApplication(super.buildInfo);
@override @override
String get name => 'debug_elinux_application'; String get name => 'debug_elinux_application';
@@ -142,7 +139,7 @@ class DebugELinuxApplication extends ELinuxAssetBundle {
/// See: [ReleaseAndroidApplication] in `android.dart` /// See: [ReleaseAndroidApplication] in `android.dart`
class ReleaseELinuxApplication extends ELinuxAssetBundle { class ReleaseELinuxApplication extends ELinuxAssetBundle {
ReleaseELinuxApplication(ELinuxBuildInfo buildInfo) : super(buildInfo); ReleaseELinuxApplication(super.buildInfo);
@override @override
String get name => 'release_elinux_application'; String get name => 'release_elinux_application';
@@ -150,7 +147,9 @@ class ReleaseELinuxApplication extends ELinuxAssetBundle {
@override @override
List<Target> get dependencies => <Target>[ List<Target> get dependencies => <Target>[
...super.dependencies, ...super.dependencies,
ELinuxAotElf(), ELinuxAotElf(buildInfo.targetArch == 'arm64'
? TargetPlatform.linux_arm64
: TargetPlatform.linux_x64),
ELinuxPlugins(buildInfo), ELinuxPlugins(buildInfo),
]; ];
} }
@@ -191,20 +190,23 @@ class ELinuxPlugins extends Target {
/// ///
/// Source: [AotElfRelease] in `common.dart` /// Source: [AotElfRelease] in `common.dart`
class ELinuxAotElf extends AotElfBase { class ELinuxAotElf extends AotElfBase {
ELinuxAotElf(); const ELinuxAotElf(this.targetPlatform);
@override @override
String get name => 'elinux_aot_elf'; String get name => 'elinux_aot_elf';
@override @override
List<Source> get inputs => <Source>[ List<Source> get inputs => <Source>[
const Source.pattern(
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'),
const Source.pattern('{BUILD_DIR}/app.dill'), const Source.pattern('{BUILD_DIR}/app.dill'),
const Source.hostArtifact(HostArtifact.engineDartBinary), const Source.artifact(Artifact.engineDartBinary),
const Source.artifact(Artifact.skyEnginePath), const Source.artifact(Artifact.skyEnginePath),
// Any type of gen_snapshot is applicable here because engine artifacts Source.artifact(
// are assumed to be updated at once, not one by one for each platform Artifact.genSnapshot,
// or build mode. platform: targetPlatform,
const Source.artifact(Artifact.genSnapshot, mode: BuildMode.release), mode: BuildMode.release,
),
]; ];
@override @override
@@ -216,13 +218,15 @@ class ELinuxAotElf extends AotElfBase {
List<Target> get dependencies => const <Target>[ List<Target> get dependencies => const <Target>[
KernelSnapshot(), KernelSnapshot(),
]; ];
final TargetPlatform targetPlatform;
} }
class NativeBundle { class NativeBundle {
NativeBundle(this.buildInfo, this.targetFile); NativeBundle(this.buildInfo, this.targetFile);
final ELinuxBuildInfo buildInfo; final ELinuxBuildInfo? buildInfo;
final String targetFile; final String? targetFile;
final ProcessUtils _processUtils = ProcessUtils( final ProcessUtils _processUtils = ProcessUtils(
logger: globals.logger, processManager: globals.processManager); logger: globals.logger, processManager: globals.processManager);
@@ -234,9 +238,9 @@ class NativeBundle {
// Clean up the intermediate and output directories. // Clean up the intermediate and output directories.
final Directory eLinuxDir = eLinuxProject.editableDirectory; final Directory eLinuxDir = eLinuxProject.editableDirectory;
final BuildMode buildMode = buildInfo.buildInfo.mode; final BuildMode buildMode = buildInfo!.buildInfo.mode;
final Directory outputDir = environment.outputDir final Directory outputDir = environment.outputDir
.childDirectory(buildInfo.targetArch) .childDirectory(buildInfo!.targetArch)
.childDirectory(buildMode.toString()); .childDirectory(buildMode.toString());
if (outputDir.existsSync()) { if (outputDir.existsSync()) {
outputDir.deleteSync(recursive: true); outputDir.deleteSync(recursive: true);
@@ -264,20 +268,20 @@ class NativeBundle {
// Copy necessary files // Copy necessary files
final Directory engineDir = final Directory engineDir =
_getEngineArtifactsDirectory(buildInfo.targetArch, buildMode); _getEngineArtifactsDirectory(buildInfo!.targetArch, buildMode);
final Directory commonDir = final Directory commonDir =
engineDir.parent.childDirectory('elinux-common'); engineDir.parent.childDirectory('elinux-common');
final File engineBinary = engineDir.childFile('libflutter_engine.so'); final File engineBinary = engineDir.childFile('libflutter_engine.so');
// libflutter_elinux_*.so in profile mode is under the debug mode's directory. // libflutter_elinux_*.so in profile mode is under the debug mode's directory.
final Directory embedderDir = _getEngineArtifactsDirectory( final Directory embedderDir = _getEngineArtifactsDirectory(
buildInfo.targetArch, buildInfo!.targetArch,
buildMode.isRelease ? buildMode : BuildMode.fromName('debug')); buildMode.isRelease ? buildMode : BuildMode.fromName('debug'));
final File embedder = final File embedder =
embedderDir.childFile(buildInfo.targetBackendType == 'gbm' embedderDir.childFile(buildInfo!.targetBackendType == 'gbm'
? 'libflutter_elinux_gbm.so' ? 'libflutter_elinux_gbm.so'
: buildInfo.targetBackendType == 'eglstream' : buildInfo!.targetBackendType == 'eglstream'
? 'libflutter_elinux_eglstream.so' ? 'libflutter_elinux_eglstream.so'
: buildInfo.targetBackendType == 'x11' : buildInfo!.targetBackendType == 'x11'
? 'libflutter_elinux_x11.so' ? 'libflutter_elinux_x11.so'
: 'libflutter_elinux_wayland.so'); : 'libflutter_elinux_wayland.so');
final Directory clientWrapperDir = final Directory clientWrapperDir =
@@ -302,9 +306,6 @@ class NativeBundle {
// Copy necessary files. // Copy necessary files.
{ {
if (flutterEphemeralDir.existsSync()) {
flutterEphemeralDir.deleteSync(recursive: true);
}
flutterEphemeralDir.createSync(recursive: true); flutterEphemeralDir.createSync(recursive: true);
flutterEphemeralDir flutterEphemeralDir
.childDirectory('cpp_client_wrapper') .childDirectory('cpp_client_wrapper')
@@ -335,41 +336,40 @@ class NativeBundle {
// Build the environment that needs to be set for the re-entrant flutter build // Build the environment that needs to be set for the re-entrant flutter build
// step. // step.
{ {
final Map<String, String> environment = <String, String>{ final Map<String, String> environmentConfig =
if (targetFile != null) 'FLUTTER_TARGET': targetFile, buildInfo!.buildInfo.toEnvironmentConfig();
...buildInfo.buildInfo.toEnvironmentConfig(), environmentConfig['FLUTTER_TARGET'] = targetFile!;
}; final LocalEngineInfo? localEngineInfo =
if (globals.artifacts is LocalEngineArtifacts) { globals.artifacts?.localEngineInfo;
final LocalEngineArtifacts localEngineArtifacts = if (localEngineInfo != null) {
globals.artifacts as LocalEngineArtifacts; final String engineOutPath = localEngineInfo.engineOutPath;
final String engineOutPath = localEngineArtifacts.engineOutPath; environmentConfig['FLUTTER_ENGINE'] =
environment['FLUTTER_ENGINE'] =
globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath)); globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
environment['LOCAL_ENGINE'] = globals.fs.path.basename(engineOutPath); environmentConfig['LOCAL_ENGINE'] = localEngineInfo.localEngineName;
} }
writeGeneratedCmakeConfig( writeGeneratedCmakeConfig(Cache.flutterRoot!, eLinuxProject,
Cache.flutterRoot, eLinuxProject, buildInfo.buildInfo, environment); buildInfo!.buildInfo, environmentConfig);
await refreshELinuxPluginsList(eLinuxProject.parent);
} }
// Run the native build. // Run the native build.
final String cmakeBuildType = buildMode.isPrecompiled ? 'Release' : 'Debug'; final String cmakeBuildType = buildMode.isPrecompiled ? 'Release' : 'Debug';
final String targetArch = final String targetArch =
buildInfo.targetArch == 'arm64' ? 'aarch64' : 'x86_64'; buildInfo!.targetArch == 'arm64' ? 'aarch64' : 'x86_64';
final String hostArch = _getCurrentHostPlatformArchName(); final String hostArch = _getCurrentHostPlatformArchName();
final String targetCompilerTriple = buildInfo.targetCompilerTriple; final String? targetCompilerTriple = buildInfo!.targetCompilerTriple;
final String targetSysroot = buildInfo.targetSysroot; final String targetSysroot = buildInfo!.targetSysroot;
final String targetCompilerFlags = buildInfo.targetCompilerFlags; final String? targetCompilerFlags = buildInfo!.targetCompilerFlags;
final String targetToolchain = buildInfo.targetToolchain; final String? targetToolchain = buildInfo!.targetToolchain;
final String systemIncludeDirectories = buildInfo.systemIncludeDirectories; final String? systemIncludeDirectories =
buildInfo!.systemIncludeDirectories;
RunResult result = await _processUtils.run( RunResult result = await _processUtils.run(
<String>[ <String>[
'cmake', 'cmake',
'-DCMAKE_BUILD_TYPE=$cmakeBuildType', '-DCMAKE_BUILD_TYPE=$cmakeBuildType',
'-DFLUTTER_TARGET_BACKEND_TYPE=${buildInfo.targetBackendType}', '-DFLUTTER_TARGET_BACKEND_TYPE=${buildInfo!.targetBackendType}',
'-DFLUTTER_TARGET_PLATFORM=elinux-${buildInfo.targetArch}', '-DFLUTTER_TARGET_PLATFORM=elinux-${buildInfo!.targetArch}',
if (targetSysroot != '/') '-DCMAKE_SYSROOT=$targetSysroot', if (targetSysroot != '/') '-DCMAKE_SYSROOT=$targetSysroot',
if (buildInfo.targetArch != hostArch) if (buildInfo!.targetArch != hostArch)
'-DCMAKE_SYSTEM_PROCESSOR=$targetArch', '-DCMAKE_SYSTEM_PROCESSOR=$targetArch',
if (systemIncludeDirectories != null) if (systemIncludeDirectories != null)
'-DFLUTTER_SYSTEM_INCLUDE_DIRECTORIES=$systemIncludeDirectories', '-DFLUTTER_SYSTEM_INCLUDE_DIRECTORIES=$systemIncludeDirectories',
@@ -394,9 +394,9 @@ class NativeBundle {
throwToolExit('Failed to cmake:\n$result'); throwToolExit('Failed to cmake:\n$result');
} }
final procResult = await Process.run('nproc', []); final ProcessResult procResult = await Process.run('nproc', []);
final numProc = procResult.stdout.toString().trim(); final String numProc = procResult.stdout.toString().trim();
result = await _processUtils.run( result = await _processUtils.run(
<String>[ <String>[
@@ -470,13 +470,13 @@ String getUnixPath(String path) {
/// On Windows, appends the msys2 executables directory to PATH and returns. /// On Windows, appends the msys2 executables directory to PATH and returns.
String getDefaultPathVariable() { String getDefaultPathVariable() {
final Map<String, String> variables = globals.platform.environment; final Map<String, String> variables = globals.platform.environment;
return variables.containsKey('PATH') ? variables['PATH'] : ''; return variables.containsKey('PATH') ? variables['PATH']! : '';
} }
/// See: [CachedArtifacts._getEngineArtifactsPath] /// See: [CachedArtifacts._getEngineArtifactsPath]
Directory _getEngineArtifactsDirectory(String arch, BuildMode mode) { Directory _getEngineArtifactsDirectory(String arch, BuildMode? mode) {
assert(mode != null, 'Need to specify a build mode.'); assert(mode != null, 'Need to specify a build mode.');
return globals.cache return globals.cache
.getArtifactDirectory('engine') .getArtifactDirectory('engine')
.childDirectory('elinux-$arch-${mode.name}'); .childDirectory('elinux-$arch-${mode!.name}');
} }
+21 -26
View File
@@ -1,11 +1,9 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved.
// 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:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/commands/build_ios_framework.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/linux/build_linux.dart'; import 'package:flutter_tools/src/linux/build_linux.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'elinux_build_target.dart'; import 'elinux_build_target.dart';
import 'elinux_cmake_project.dart'; import 'elinux_cmake_project.dart';
@@ -35,24 +32,23 @@ const String kTargetBackendType = 'TargetBackendType';
class ELinuxBuildInfo { class ELinuxBuildInfo {
const ELinuxBuildInfo( const ELinuxBuildInfo(
this.buildInfo, { this.buildInfo, {
@required this.targetArch, required this.targetArch,
@required this.targetBackendType, required this.targetBackendType,
@required this.targetCompilerTriple, required this.targetCompilerTriple,
@required this.targetSysroot, required this.targetSysroot,
@required this.targetCompilerFlags, required this.targetCompilerFlags,
@required this.targetToolchain, required this.targetToolchain,
@required this.systemIncludeDirectories, required this.systemIncludeDirectories,
}) : assert(targetArch != null), });
assert(targetBackendType != null);
final BuildInfo buildInfo; final BuildInfo buildInfo;
final String targetArch; final String targetArch;
final String targetBackendType; final String targetBackendType;
final String targetCompilerTriple; final String? targetCompilerTriple;
final String targetSysroot; final String targetSysroot;
final String targetCompilerFlags; final String? targetCompilerFlags;
final String targetToolchain; final String? targetToolchain;
final String systemIncludeDirectories; final String? systemIncludeDirectories;
} }
// ignore: avoid_classes_with_only_static_members // ignore: avoid_classes_with_only_static_members
@@ -64,10 +60,10 @@ class ELinuxBuildInfo {
/// - [buildLinux] in `build_linux.dart` (code size) /// - [buildLinux] in `build_linux.dart` (code size)
class ELinuxBuilder { class ELinuxBuilder {
static Future<void> buildBundle({ static Future<void> buildBundle({
@required FlutterProject project, required FlutterProject project,
@required ELinuxBuildInfo eLinuxBuildInfo, required ELinuxBuildInfo eLinuxBuildInfo,
@required String targetFile, required String targetFile,
SizeAnalyzer sizeAnalyzer, SizeAnalyzer? sizeAnalyzer,
}) async { }) async {
final ELinuxProject elinuxProject = ELinuxProject.fromFlutter(project); final ELinuxProject elinuxProject = ELinuxProject.fromFlutter(project);
if (!elinuxProject.existsSync()) { if (!elinuxProject.existsSync()) {
@@ -100,14 +96,12 @@ class ELinuxBuilder {
...buildInfo.toBuildSystemEnvironment(), ...buildInfo.toBuildSystemEnvironment(),
kTargetBackendType: eLinuxBuildInfo.targetBackendType, kTargetBackendType: eLinuxBuildInfo.targetBackendType,
}, },
inputs: <String, String>{ artifacts: globals.artifacts!,
kBundleSkSLPath: buildInfo.bundleSkSLPath,
},
artifacts: globals.artifacts,
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
processManager: globals.processManager, processManager: globals.processManager,
platform: globals.platform, platform: globals.platform,
usage: globals.flutterUsage,
); );
final Target target = buildInfo.isDebug final Target target = buildInfo.isDebug
@@ -151,7 +145,7 @@ class ELinuxBuilder {
final File precompilerTrace = globals.fs final File precompilerTrace = globals.fs
.directory(buildInfo.codeSizeDirectory) .directory(buildInfo.codeSizeDirectory)
.childFile('trace.$genSnapshotPlatform.json'); .childFile('trace.$genSnapshotPlatform.json');
final Map<String, Object> output = await sizeAnalyzer.analyzeAotSnapshot( final Map<String, Object?> output = await sizeAnalyzer.analyzeAotSnapshot(
aotSnapshot: codeSizeFile, aotSnapshot: codeSizeFile,
// This analysis is only supported for release builds. // This analysis is only supported for release builds.
outputDirectory: globals.fs.directory( outputDirectory: globals.fs.directory(
@@ -212,6 +206,7 @@ String _getTargetPlatformPlatformName(TargetPlatform targetPlatform) {
return 'linux-x64'; return 'linux-x64';
case TargetPlatform.android_arm64: case TargetPlatform.android_arm64:
return 'android-arm64'; return 'android-arm64';
// ignore: no_default_cases
default: default:
return 'android-x64'; return 'android-x64';
} }
-2
View File
@@ -3,8 +3,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/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
+69 -68
View File
@@ -3,8 +3,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 'dart:io'; import 'dart:io';
@@ -20,7 +18,6 @@ import 'package:flutter_tools/src/device_port_forwarder.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/protocol_discovery.dart'; import 'package:flutter_tools/src/protocol_discovery.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'elinux_builder.dart'; import 'elinux_builder.dart';
@@ -32,15 +29,15 @@ import 'elinux_remote_device_config.dart';
/// See: [DesktopDevice] in `desktop_device.dart` /// See: [DesktopDevice] in `desktop_device.dart`
class ELinuxDevice extends Device { class ELinuxDevice extends Device {
ELinuxDevice( ELinuxDevice(
String id, { super.id, {
@required ELinuxRemoteDeviceConfig config, required ELinuxRemoteDeviceConfig? config,
@required bool desktop, required bool desktop,
@required String backendType, required String backendType,
@required String targetArch, required String targetArch,
String sdkNameAndVersion = '', String sdkNameAndVersion = '',
@required Logger logger, required Logger logger,
@required ProcessManager processManager, required ProcessManager processManager,
@required OperatingSystemUtils operatingSystemUtils, required OperatingSystemUtils operatingSystemUtils,
}) : _config = config, }) : _config = config,
_desktop = desktop, _desktop = desktop,
_backendType = backendType, _backendType = backendType,
@@ -54,18 +51,18 @@ class ELinuxDevice extends Device {
portForwarder = config != null && config.usesPortForwarding portForwarder = config != null && config.usesPortForwarding
? CustomDevicePortForwarder( ? CustomDevicePortForwarder(
deviceName: config.label, deviceName: config.label,
forwardPortCommand: config.forwardPortCommand, forwardPortCommand: config.forwardPortCommand!,
forwardPortSuccessRegex: config.forwardPortSuccessRegex, forwardPortSuccessRegex: config.forwardPortSuccessRegex!,
processManager: processManager, processManager: processManager,
logger: logger, logger: logger,
) )
: const NoOpDevicePortForwarder(), : const NoOpDevicePortForwarder(),
super(id, super(
category: desktop ? Category.desktop : Category.mobile, category: desktop ? Category.desktop : Category.mobile,
platformType: PlatformType.custom, platformType: PlatformType.custom,
ephemeral: true); ephemeral: true);
final ELinuxRemoteDeviceConfig _config; final ELinuxRemoteDeviceConfig? _config;
final bool _desktop; final bool _desktop;
final String _backendType; final String _backendType;
final String _targetArch; final String _targetArch;
@@ -77,14 +74,14 @@ class ELinuxDevice extends Device {
final Set<Process> _runningProcesses = <Process>{}; final Set<Process> _runningProcesses = <Process>{};
final ELinuxLogReader _logReader = ELinuxLogReader(); final ELinuxLogReader _logReader = ELinuxLogReader();
int _forwardedHostPort; int? _forwardedHostPort;
BuildMode _buildMode = BuildMode.debug; BuildMode _buildMode = BuildMode.debug;
@override @override
Future<bool> get isLocalEmulator async => false; Future<bool> get isLocalEmulator async => false;
@override @override
Future<String> get emulatorId async => null; Future<String?> get emulatorId async => null;
@override @override
Future<TargetPlatform> get targetPlatform async { Future<TargetPlatform> get targetPlatform async {
@@ -108,44 +105,47 @@ class ELinuxDevice extends Device {
String get name => 'eLinux'; String get name => 'eLinux';
@override @override
Future<bool> isAppInstalled(ELinuxApp app, {String userIdentifier}) async { Future<bool> isAppInstalled(covariant ELinuxApp app,
{String? userIdentifier}) async {
return false; return false;
} }
@override @override
Future<bool> isLatestBuildInstalled(ELinuxApp app) async { Future<bool> isLatestBuildInstalled(covariant ELinuxApp app) async {
return false; return false;
} }
@override @override
Future<bool> installApp(ELinuxApp app, {String userIdentifier}) async { Future<bool> installApp(covariant ELinuxApp app,
if (!await tryUninstall(appName: app.name)) { {String? userIdentifier}) async {
if (!await tryUninstall(appName: app.name!)) {
return false; return false;
} }
final String bundlePath = app.outputDirectory(_buildMode, _targetArch); final String bundlePath = app.outputDirectory(_buildMode, _targetArch);
final bool result = final bool result =
await tryInstall(localPath: bundlePath, appName: app.name); await tryInstall(localPath: bundlePath, appName: app.name!);
return result; return result;
} }
@override @override
Future<bool> uninstallApp(ELinuxApp app, {String userIdentifier}) async { Future<bool> uninstallApp(covariant ELinuxApp app,
return tryUninstall(appName: app.name); {String? userIdentifier}) async {
return tryUninstall(appName: app.name!);
} }
/// Source: [AndroidDevice.startApp] in `android_device.dart` /// Source: [AndroidDevice.startApp] in `android_device.dart`
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ELinuxApp package, { ELinuxApp package, {
String mainPath, String? mainPath,
String route, String? route,
DebuggingOptions debuggingOptions, DebuggingOptions? debuggingOptions,
Map<String, dynamic> platformArgs, Map<String, Object?> platformArgs = const <String, Object>{},
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String? userIdentifier,
}) async { }) async {
if (!_desktop) { if (!_desktop) {
if (!await installApp(package)) { if (!await installApp(package)) {
@@ -153,15 +153,15 @@ class ELinuxDevice extends Device {
} }
final List<String> interpolated = interpolateCommand( final List<String> interpolated = interpolateCommand(
_config.runDebugCommand, _config!.runDebugCommand,
<String, String>{'remotePath': '/tmp/', 'appName': package.name}); <String, String>{'remotePath': '/tmp/', 'appName': package.name!});
_logger.printStatus('Launch $package.name on ${_config.id}'); _logger.printStatus('Launch $package.name on ${_config!.id}');
final Process process = await _processManager.start(interpolated); final Process process = await _processManager.start(interpolated);
final ProtocolDiscovery discovery = ProtocolDiscovery.observatory( final ProtocolDiscovery discovery = ProtocolDiscovery.vmService(
_logReader, _logReader,
portForwarder: _config.usesPortForwarding ? portForwarder : null, portForwarder: _config!.usesPortForwarding ? portForwarder : null,
hostPort: debuggingOptions?.hostVmServicePort, hostPort: debuggingOptions?.hostVmServicePort,
devicePort: debuggingOptions?.deviceVmServicePort, devicePort: debuggingOptions?.deviceVmServicePort,
logger: _logger, logger: _logger,
@@ -170,11 +170,11 @@ class ELinuxDevice extends Device {
_logReader.initializeProcess(process); _logReader.initializeProcess(process);
final Uri observatoryUri = await discovery.uri; final Uri? observatoryUri = await discovery.uri;
await discovery.cancel(); await discovery.cancel();
if (_config.usesPortForwarding) { if (_config!.usesPortForwarding) {
_forwardedHostPort = observatoryUri.port; _forwardedHostPort = observatoryUri!.port;
} }
return LaunchResult.succeeded(observatoryUri: observatoryUri); return LaunchResult.succeeded(observatoryUri: observatoryUri);
@@ -185,27 +185,27 @@ class ELinuxDevice extends Device {
_logger.printTrace('Building app'); _logger.printTrace('Building app');
await buildForDevice( await buildForDevice(
package, package,
buildInfo: debuggingOptions.buildInfo, buildInfo: debuggingOptions!.buildInfo,
mainPath: mainPath, mainPath: mainPath,
); );
} }
// Ensure that the executable is locatable. // Ensure that the executable is locatable.
final BuildMode buildMode = debuggingOptions?.buildInfo?.mode; final BuildMode buildMode = debuggingOptions!.buildInfo.mode;
final bool traceStartup = platformArgs['trace-startup'] as bool ?? false; final bool traceStartup = platformArgs['trace-startup'] as bool? ?? false;
final String executable = executablePathForDevice(package, buildMode); final String executable = executablePathForDevice(package, buildMode);
const String executableOptions = '--bundle=./'; const String executableOptions = '--bundle=./';
if (executable == null) { //if (executable == null) {
_logger.printError('Unable to find executable to run'); // _logger.printError('Unable to find executable to run');
return LaunchResult.failed(); // return LaunchResult.failed();
} //}
final Process process = await _processManager.start( final Process process = await _processManager.start(
<String>[ <String>[
executable, executable,
executableOptions, executableOptions,
if (_desktop && _backendType == 'wayland') '-d', if (_desktop && _backendType == 'wayland') '-d',
...?debuggingOptions?.dartEntrypointArgs, ...debuggingOptions.dartEntrypointArgs,
], ],
environment: _computeEnvironment(debuggingOptions, traceStartup, route), environment: _computeEnvironment(debuggingOptions, traceStartup, route),
); );
@@ -213,19 +213,18 @@ class ELinuxDevice extends Device {
unawaited(process.exitCode.then((_) => _runningProcesses.remove(process))); unawaited(process.exitCode.then((_) => _runningProcesses.remove(process)));
_logReader.initializeProcess(process); _logReader.initializeProcess(process);
if (debuggingOptions?.buildInfo?.isRelease == true) { if (debuggingOptions.buildInfo.isRelease == true) {
return LaunchResult.succeeded(); return LaunchResult.succeeded();
} }
final ProtocolDiscovery observatoryDiscovery = final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.vmService(
ProtocolDiscovery.observatory(
_logReader, _logReader,
devicePort: debuggingOptions?.deviceVmServicePort, devicePort: debuggingOptions.deviceVmServicePort,
hostPort: debuggingOptions?.hostVmServicePort, hostPort: debuggingOptions.hostVmServicePort,
ipv6: ipv6, ipv6: ipv6,
logger: _logger, logger: _logger,
); );
try { try {
final Uri observatoryUri = await observatoryDiscovery.uri; final Uri? observatoryUri = await observatoryDiscovery.uri;
if (observatoryUri != null) { if (observatoryUri != null) {
onAttached(package, buildMode, process); onAttached(package, buildMode, process);
return LaunchResult.succeeded(observatoryUri: observatoryUri); return LaunchResult.succeeded(observatoryUri: observatoryUri);
@@ -243,7 +242,8 @@ class ELinuxDevice extends Device {
} }
@override @override
Future<bool> stopApp(ELinuxApp app, {String userIdentifier}) async { Future<bool> stopApp(covariant ELinuxApp? app,
{String? userIdentifier}) async {
_maybeUnforwardPort(); _maybeUnforwardPort();
bool succeeded = true; bool succeeded = true;
@@ -260,7 +260,7 @@ class ELinuxDevice extends Device {
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
ELinuxApp app, covariant ELinuxApp? app,
bool includePastLogs = false, bool includePastLogs = false,
}) => }) =>
_logReader; _logReader;
@@ -285,14 +285,14 @@ class ELinuxDevice extends Device {
Future<void> buildForDevice( Future<void> buildForDevice(
ELinuxApp package, { ELinuxApp package, {
String mainPath, String? mainPath,
BuildInfo buildInfo, BuildInfo? buildInfo,
}) async { }) async {
final FlutterProject project = FlutterProject.current(); final FlutterProject project = FlutterProject.current();
// TODO(hidenori): change the fixed values (|targetSysroot|, |systemIncludeDirectories| and |targetCompilerTriple|) // TODO(hidenori): change the fixed values (|targetSysroot|, |systemIncludeDirectories| and |targetCompilerTriple|)
// to the values from user-specified custom-devices feilds. // to the values from user-specified custom-devices feilds.
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo( final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(
buildInfo, buildInfo!,
targetArch: _targetArch, targetArch: _targetArch,
targetBackendType: _backendType, targetBackendType: _backendType,
targetCompilerTriple: null, targetCompilerTriple: null,
@@ -303,7 +303,7 @@ class ELinuxDevice extends Device {
); );
await ELinuxBuilder.buildBundle( await ELinuxBuilder.buildBundle(
project: project, project: project,
targetFile: mainPath, targetFile: mainPath!,
eLinuxBuildInfo: eLinuxBuildInfo, eLinuxBuildInfo: eLinuxBuildInfo,
); );
package = ELinuxApp.fromELinuxProject(project); package = ELinuxApp.fromELinuxProject(project);
@@ -317,7 +317,7 @@ class ELinuxDevice extends Device {
/// Source: [DesktopDevice._computeEnvironment] in `desktop_device.dart` /// Source: [DesktopDevice._computeEnvironment] in `desktop_device.dart`
Map<String, String> _computeEnvironment( Map<String, String> _computeEnvironment(
DebuggingOptions debuggingOptions, bool traceStartup, String route) { DebuggingOptions debuggingOptions, bool traceStartup, String? route) {
int flags = 0; int flags = 0;
final Map<String, String> environment = <String, String>{}; final Map<String, String> environment = <String, String>{};
@@ -401,22 +401,22 @@ class ELinuxDevice extends Device {
/// Source: [tryUninstall] in `custom_device.dart` /// Source: [tryUninstall] in `custom_device.dart`
Future<bool> tryUninstall( Future<bool> tryUninstall(
{@required String appName, {required String appName,
Duration timeout, Duration? timeout,
Map<String, String> additionalReplacementValues = Map<String, String> additionalReplacementValues =
const <String, String>{}}) async { const <String, String>{}}) async {
if (_config == null || _config.uninstallCommand == null) { if (_config == null || _config!.uninstallCommand.isEmpty) {
// do nothing if uninstall command is not defined. // do nothing if uninstall command is not defined.
_logger.printTrace('uninstall command is not defined.'); _logger.printTrace('uninstall command is not defined.');
return true; return true;
} }
final List<String> interpolated = interpolateCommand( final List<String> interpolated = interpolateCommand(
_config.uninstallCommand, <String, String>{'appName': appName}, _config!.uninstallCommand, <String, String>{'appName': appName},
additionalReplacementValues: additionalReplacementValues); additionalReplacementValues: additionalReplacementValues);
try { try {
_logger.printStatus('Uninstall $appName from ${_config.id}.'); _logger.printStatus('Uninstall $appName from ${_config!.id}.');
await _processUtils.run(interpolated, await _processUtils.run(interpolated,
throwOnError: true, timeout: timeout); throwOnError: true, timeout: timeout);
_logger.printStatus('Uninstallation Success'); _logger.printStatus('Uninstallation Success');
@@ -430,17 +430,18 @@ class ELinuxDevice extends Device {
/// Source: [tryInstall] in `custom_device.dart` /// Source: [tryInstall] in `custom_device.dart`
Future<bool> tryInstall( Future<bool> tryInstall(
{@required String localPath, {required String localPath,
@required String appName, required String appName,
Duration timeout, Duration? timeout,
Map<String, String> additionalReplacementValues = Map<String, String> additionalReplacementValues =
const <String, String>{}}) async { const <String, String>{}}) async {
final List<String> interpolated = interpolateCommand(_config.installCommand, final List<String> interpolated = interpolateCommand(
_config!.installCommand,
<String, String>{'localPath': localPath, 'appName': appName}, <String, String>{'localPath': localPath, 'appName': appName},
additionalReplacementValues: additionalReplacementValues); additionalReplacementValues: additionalReplacementValues);
try { try {
_logger.printStatus('Install $appName ($localPath) to ${_config.id}'); _logger.printStatus('Install $appName ($localPath) to ${_config!.id}');
await _processUtils.run(interpolated, await _processUtils.run(interpolated,
throwOnError: true, timeout: timeout); throwOnError: true, timeout: timeout);
_logger.printStatus('Installation Success'); _logger.printStatus('Installation Success');
+26 -29
View File
@@ -4,8 +4,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:io'; import 'dart:io';
import 'package:flutter_tools/src/android/android_workflow.dart'; import 'package:flutter_tools/src/android/android_workflow.dart';
@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/macos/macos_workflow.dart'; import 'package:flutter_tools/src/macos/macos_workflow.dart';
import 'package:flutter_tools/src/windows/windows_workflow.dart'; import 'package:flutter_tools/src/windows/windows_workflow.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'elinux_device.dart'; import 'elinux_device.dart';
@@ -40,19 +37,19 @@ class ELinuxDeviceManager extends FlutterDeviceManager {
processManager: globals.processManager, processManager: globals.processManager,
platform: globals.platform, platform: globals.platform,
androidSdk: globals.androidSdk, androidSdk: globals.androidSdk,
iosSimulatorUtils: globals.iosSimulatorUtils, iosSimulatorUtils: globals.iosSimulatorUtils!,
featureFlags: featureFlags, featureFlags: featureFlags,
fileSystem: globals.fs, fileSystem: globals.fs,
iosWorkflow: globals.iosWorkflow, iosWorkflow: globals.iosWorkflow!,
artifacts: globals.artifacts, artifacts: globals.artifacts!,
flutterVersion: globals.flutterVersion, flutterVersion: globals.flutterVersion,
androidWorkflow: androidWorkflow, androidWorkflow: androidWorkflow!,
fuchsiaWorkflow: fuchsiaWorkflow, fuchsiaWorkflow: fuchsiaWorkflow!,
xcDevice: globals.xcdevice, xcDevice: globals.xcdevice!,
userMessages: globals.userMessages, userMessages: globals.userMessages,
windowsWorkflow: windowsWorkflow, windowsWorkflow: windowsWorkflow!,
macOSWorkflow: context.get<MacOSWorkflow>(), macOSWorkflow: context.get<MacOSWorkflow>()!,
fuchsiaSdk: globals.fuchsiaSdk, fuchsiaSdk: globals.fuchsiaSdk!,
operatingSystemUtils: globals.os, operatingSystemUtils: globals.os,
customDevicesConfig: CustomDevicesConfig( customDevicesConfig: CustomDevicesConfig(
fileSystem: globals.fs, fileSystem: globals.fs,
@@ -62,7 +59,7 @@ class ELinuxDeviceManager extends FlutterDeviceManager {
); );
final ELinuxDeviceDiscovery _eLinuxDeviceDiscovery = ELinuxDeviceDiscovery( final ELinuxDeviceDiscovery _eLinuxDeviceDiscovery = ELinuxDeviceDiscovery(
eLinuxWorkflow: eLinuxWorkflow, eLinuxWorkflow: eLinuxWorkflow!,
logger: globals.logger, logger: globals.logger,
processManager: globals.processManager, processManager: globals.processManager,
); );
@@ -77,9 +74,9 @@ class ELinuxDeviceManager extends FlutterDeviceManager {
/// Device discovery for eLinux devices. /// Device discovery for eLinux devices.
class ELinuxDeviceDiscovery extends PollingDeviceDiscovery { class ELinuxDeviceDiscovery extends PollingDeviceDiscovery {
ELinuxDeviceDiscovery({ ELinuxDeviceDiscovery({
@required ELinuxWorkflow eLinuxWorkflow, required ELinuxWorkflow eLinuxWorkflow,
@required ProcessManager processManager, required ProcessManager processManager,
@required Logger logger, required Logger logger,
}) : _eLinuxWorkflow = eLinuxWorkflow, }) : _eLinuxWorkflow = eLinuxWorkflow,
_logger = logger, _logger = logger,
_processManager = processManager, _processManager = processManager,
@@ -105,7 +102,7 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery {
bool get canListAnything => _eLinuxWorkflow.canListDevices; bool get canListAnything => _eLinuxWorkflow.canListDevices;
@override @override
Future<List<Device>> pollingGetDevices({Duration timeout}) async { Future<List<Device>> pollingGetDevices({Duration? timeout}) async {
if (!canListAnything) { if (!canListAnything) {
return const <Device>[]; return const <Device>[];
} }
@@ -119,11 +116,11 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery {
desktop: true, desktop: true,
targetArch: _getCurrentHostPlatformArchName(), targetArch: _getCurrentHostPlatformArchName(),
backendType: 'wayland', backendType: 'wayland',
logger: _logger ?? globals.logger, logger: _logger,
processManager: _processManager ?? globals.processManager, processManager: _processManager,
operatingSystemUtils: OperatingSystemUtils( operatingSystemUtils: OperatingSystemUtils(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: _logger ?? globals.logger, logger: _logger,
platform: globals.platform, platform: globals.platform,
processManager: const LocalProcessManager(), processManager: const LocalProcessManager(),
)), )),
@@ -134,11 +131,11 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery {
desktop: true, desktop: true,
targetArch: _getCurrentHostPlatformArchName(), targetArch: _getCurrentHostPlatformArchName(),
backendType: 'x11', backendType: 'x11',
logger: _logger ?? globals.logger, logger: _logger,
processManager: _processManager ?? globals.processManager, processManager: _processManager,
operatingSystemUtils: OperatingSystemUtils( operatingSystemUtils: OperatingSystemUtils(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: _logger ?? globals.logger, logger: _logger,
platform: globals.platform, platform: globals.platform,
processManager: const LocalProcessManager(), processManager: const LocalProcessManager(),
)), )),
@@ -163,18 +160,18 @@ class ELinuxDeviceDiscovery extends PollingDeviceDiscovery {
} }
if (result.exitCode == 0 && if (result.exitCode == 0 &&
stdout.contains(remoteDevice.pingSuccessRegex)) { stdout.contains(remoteDevice.pingSuccessRegex!)) {
final ELinuxDevice device = ELinuxDevice(remoteDevice.id, final ELinuxDevice device = ELinuxDevice(remoteDevice.id,
config: remoteDevice, config: remoteDevice,
desktop: false, desktop: false,
targetArch: remoteDevice.platform, targetArch: remoteDevice.platform!,
backendType: remoteDevice.backend, backendType: remoteDevice.backend!,
sdkNameAndVersion: remoteDevice.sdkNameAndVersion, sdkNameAndVersion: remoteDevice.sdkNameAndVersion,
logger: _logger ?? globals.logger, logger: _logger,
processManager: _processManager ?? globals.processManager, processManager: _processManager,
operatingSystemUtils: OperatingSystemUtils( operatingSystemUtils: OperatingSystemUtils(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: _logger ?? globals.logger, logger: _logger,
platform: globals.platform, platform: globals.platform,
processManager: const LocalProcessManager(), processManager: const LocalProcessManager(),
)); ));
+30 -29
View File
@@ -1,10 +1,8 @@
// Copyright 2022 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// 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:io'; import 'dart:io';
import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/context.dart';
@@ -13,12 +11,11 @@ import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/base/version.dart'; import 'package:flutter_tools/src/base/version.dart';
import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/doctor_validator.dart'; import 'package:flutter_tools/src/doctor_validator.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
ELinuxWorkflow get eLinuxWorkflow => context.get<ELinuxWorkflow>(); ELinuxWorkflow? get eLinuxWorkflow => context.get<ELinuxWorkflow>();
ELinuxValidator get eLinuxValidator => context.get<ELinuxValidator>(); ELinuxValidator? get eLinuxValidator => context.get<ELinuxValidator>();
/// See: [_DefaultDoctorValidatorsProvider] in `doctor.dart` /// See: [_DefaultDoctorValidatorsProvider] in `doctor.dart`
class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider { class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider {
@@ -28,7 +25,7 @@ class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider {
DoctorValidatorsProvider.defaultInstance.validators; DoctorValidatorsProvider.defaultInstance.validators;
return <DoctorValidator>[ return <DoctorValidator>[
validators.first, validators.first,
eLinuxValidator, eLinuxValidator!,
...validators.sublist(1) ...validators.sublist(1)
]; ];
} }
@@ -36,28 +33,28 @@ class ELinuxDoctorValidatorsProvider implements DoctorValidatorsProvider {
@override @override
List<Workflow> get workflows => <Workflow>[ List<Workflow> get workflows => <Workflow>[
...DoctorValidatorsProvider.defaultInstance.workflows, ...DoctorValidatorsProvider.defaultInstance.workflows,
eLinuxWorkflow, eLinuxWorkflow!,
]; ];
} }
/// See: [_VersionInfo] in `linux_doctor.dart` /// See: [_VersionInfo] in `linux_doctor.dart`
class _VersionInfo { class _VersionInfo {
_VersionInfo(this.description) { _VersionInfo(this.description) {
final String versionString = RegExp(r'[0-9]+\.[0-9]+(?:\.[0-9]+)?') final String? versionString = RegExp(r'[0-9]+\.[0-9]+(?:\.[0-9]+)?')
.firstMatch(description) .firstMatch(description)
?.group(0); ?.group(0);
number = Version.parse(versionString); number = Version.parse(versionString);
} }
String description; String description;
Version number; Version? number;
} }
/// See: [LinuxDoctorValidator] in `linux_doctor.dart` /// See: [LinuxDoctorValidator] in `linux_doctor.dart`
class ELinuxValidator extends DoctorValidator { class ELinuxValidator extends DoctorValidator {
ELinuxValidator({ ELinuxValidator({
@required ProcessManager processManager, required ProcessManager processManager,
@required UserMessages userMessages, required UserMessages userMessages,
}) : _processManager = processManager, }) : _processManager = processManager,
_userMessages = userMessages, _userMessages = userMessages,
super('eLinux toolchain - develop for embedded Linux devices'); super('eLinux toolchain - develop for embedded Linux devices');
@@ -85,10 +82,11 @@ class ELinuxValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
ValidationType validationType = ValidationType.installed; ValidationType validationType = ValidationType.success;
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
final Map<String, _VersionInfo> installedVersions = <String, _VersionInfo>{ final Map<String, _VersionInfo?> installedVersions =
<String, _VersionInfo?>{
// Sort the check to make the call order predictable for unit tests. // Sort the check to make the call order predictable for unit tests.
for (String binary in _requiredBinaryVersions.keys.toList()..sort()) for (String binary in _requiredBinaryVersions.keys.toList()..sort())
binary: await _getBinaryVersion(binary) binary: await _getBinaryVersion(binary)
@@ -96,23 +94,24 @@ class ELinuxValidator extends DoctorValidator {
// Determine overall validation level. // Determine overall validation level.
if (installedVersions.values if (installedVersions.values
.any((_VersionInfo versionInfo) => versionInfo?.number == null)) { .any((_VersionInfo? versionInfo) => versionInfo?.number == null)) {
validationType = ValidationType.missing; validationType = ValidationType.missing;
} else if (installedVersions.keys.any((String binary) => } else if (installedVersions.keys.any((String binary) =>
installedVersions[binary].number < _requiredBinaryVersions[binary])) { installedVersions[binary]!.number! <
_requiredBinaryVersions[binary]!)) {
validationType = ValidationType.partial; validationType = ValidationType.partial;
} }
// Message for Clang. // Message for Clang.
{ {
final _VersionInfo version = installedVersions[kClangBinary]; final _VersionInfo? version = installedVersions[kClangBinary];
if (version == null || version.number == null) { if (version == null || version.number == null) {
messages.add(ValidationMessage.error(_userMessages.clangMissing)); messages.add(ValidationMessage.error(_userMessages.clangMissing));
} else { } else {
assert(_requiredBinaryVersions.containsKey(kClangBinary)); assert(_requiredBinaryVersions.containsKey(kClangBinary));
messages.add(ValidationMessage(version.description)); messages.add(ValidationMessage(version.description));
final Version requiredVersion = _requiredBinaryVersions[kClangBinary]; final Version requiredVersion = _requiredBinaryVersions[kClangBinary]!;
if (version.number < requiredVersion) { if (version.number! < requiredVersion) {
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
_userMessages.clangTooOld(requiredVersion.toString()))); _userMessages.clangTooOld(requiredVersion.toString())));
} }
@@ -121,14 +120,14 @@ class ELinuxValidator extends DoctorValidator {
// Message for CMake. // Message for CMake.
{ {
final _VersionInfo version = installedVersions[kCmakeBinary]; final _VersionInfo? version = installedVersions[kCmakeBinary];
if (version == null || version.number == null) { if (version == null || version.number == null) {
messages.add(ValidationMessage.error(_userMessages.cmakeMissing)); messages.add(ValidationMessage.error(_userMessages.cmakeMissing));
} else { } else {
assert(_requiredBinaryVersions.containsKey(kCmakeBinary)); assert(_requiredBinaryVersions.containsKey(kCmakeBinary));
messages.add(ValidationMessage(version.description)); messages.add(ValidationMessage(version.description));
final Version requiredVersion = _requiredBinaryVersions[kCmakeBinary]; final Version requiredVersion = _requiredBinaryVersions[kCmakeBinary]!;
if (version.number < requiredVersion) { if (version.number! < requiredVersion) {
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
_userMessages.cmakeTooOld(requiredVersion.toString()))); _userMessages.cmakeTooOld(requiredVersion.toString())));
} }
@@ -137,7 +136,7 @@ class ELinuxValidator extends DoctorValidator {
// Message for pkg-config. // Message for pkg-config.
{ {
final _VersionInfo version = installedVersions[kPkgConfigBinary]; final _VersionInfo? version = installedVersions[kPkgConfigBinary];
if (version == null || version.number == null) { if (version == null || version.number == null) {
messages.add(ValidationMessage.error(_userMessages.pkgConfigMissing)); messages.add(ValidationMessage.error(_userMessages.pkgConfigMissing));
} else { } else {
@@ -146,8 +145,8 @@ class ELinuxValidator extends DoctorValidator {
messages.add(ValidationMessage( messages.add(ValidationMessage(
_userMessages.pkgConfigVersion(version.description))); _userMessages.pkgConfigVersion(version.description)));
final Version requiredVersion = final Version requiredVersion =
_requiredBinaryVersions[kPkgConfigBinary]; _requiredBinaryVersions[kPkgConfigBinary]!;
if (version.number < requiredVersion) { if (version.number! < requiredVersion) {
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
_userMessages.pkgConfigTooOld(requiredVersion.toString()))); _userMessages.pkgConfigTooOld(requiredVersion.toString())));
} }
@@ -174,8 +173,8 @@ class ELinuxValidator extends DoctorValidator {
} }
/// See: [_getBinaryVersion] in `linux_doctor.dart` /// See: [_getBinaryVersion] in `linux_doctor.dart`
Future<_VersionInfo> _getBinaryVersion(String binary) async { Future<_VersionInfo?> _getBinaryVersion(String binary) async {
ProcessResult result; ProcessResult? result;
try { try {
result = await _processManager.run(<String>[ result = await _processManager.run(<String>[
binary, binary,
@@ -183,6 +182,8 @@ class ELinuxValidator extends DoctorValidator {
]); ]);
} on ArgumentError { } on ArgumentError {
// ignore error. // ignore error.
} on ProcessException {
// ignore error.
} }
if (result == null || result.exitCode != 0) { if (result == null || result.exitCode != 0) {
return null; return null;
@@ -193,7 +194,7 @@ class ELinuxValidator extends DoctorValidator {
/// See: [_libraryIsPresent] in `linux_doctor.dart` /// See: [_libraryIsPresent] in `linux_doctor.dart`
Future<bool> _libraryIsPresent(String library) async { Future<bool> _libraryIsPresent(String library) async {
ProcessResult result; ProcessResult? result;
try { try {
result = await _processManager.run(<String>[ result = await _processManager.run(<String>[
'pkg-config', 'pkg-config',
@@ -212,7 +213,7 @@ class ELinuxValidator extends DoctorValidator {
/// See: [AndroidWorkflow] in `android_workflow.dart` /// See: [AndroidWorkflow] in `android_workflow.dart`
class ELinuxWorkflow extends Workflow { class ELinuxWorkflow extends Workflow {
ELinuxWorkflow({ ELinuxWorkflow({
@required OperatingSystemUtils operatingSystemUtils, required OperatingSystemUtils operatingSystemUtils,
}) : _operatingSystemUtils = operatingSystemUtils; }) : _operatingSystemUtils = operatingSystemUtils;
final OperatingSystemUtils _operatingSystemUtils; final OperatingSystemUtils _operatingSystemUtils;
+9 -12
View File
@@ -1,10 +1,8 @@
// Copyright 2021 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved.
// 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:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
@@ -13,7 +11,6 @@ import 'package:flutter_tools/src/cmake.dart';
import 'package:flutter_tools/src/flutter_application_package.dart'; import 'package:flutter_tools/src/flutter_application_package.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'elinux_cmake_project.dart'; import 'elinux_cmake_project.dart';
@@ -28,10 +25,10 @@ class ELinuxApplicationPackageFactory extends FlutterApplicationPackageFactory {
); );
@override @override
Future<ApplicationPackage> getPackageForPlatform( Future<ApplicationPackage?> getPackageForPlatform(
TargetPlatform platform, { TargetPlatform platform, {
BuildInfo buildInfo, BuildInfo? buildInfo,
File applicationBinary, File? applicationBinary,
}) async { }) async {
if (platform == TargetPlatform.tester) { if (platform == TargetPlatform.tester) {
return applicationBinary == null return applicationBinary == null
@@ -44,7 +41,7 @@ class ELinuxApplicationPackageFactory extends FlutterApplicationPackageFactory {
} }
abstract class ELinuxApp extends ApplicationPackage { abstract class ELinuxApp extends ApplicationPackage {
ELinuxApp({@required String projectBundleId}) : super(id: projectBundleId); ELinuxApp({required String projectBundleId}) : super(id: projectBundleId);
factory ELinuxApp.fromELinuxProject(FlutterProject project) { factory ELinuxApp.fromELinuxProject(FlutterProject project) {
return BuildableELinuxApp( return BuildableELinuxApp(
@@ -69,8 +66,8 @@ abstract class ELinuxApp extends ApplicationPackage {
class PrebuiltELinuxApp extends ELinuxApp { class PrebuiltELinuxApp extends ELinuxApp {
PrebuiltELinuxApp({ PrebuiltELinuxApp({
@required String executable, required String executable,
@required String outputDirectory, required String outputDirectory,
}) : _executable = executable, }) : _executable = executable,
_outputDirectory = outputDirectory, _outputDirectory = outputDirectory,
super(projectBundleId: executable); super(projectBundleId: executable);
@@ -90,14 +87,14 @@ class PrebuiltELinuxApp extends ELinuxApp {
} }
class BuildableELinuxApp extends ELinuxApp { class BuildableELinuxApp extends ELinuxApp {
BuildableELinuxApp({@required this.project}) BuildableELinuxApp({required this.project})
: super(projectBundleId: project.parent.manifest.appName); : super(projectBundleId: project.parent.manifest.appName);
final ELinuxProject project; final ELinuxProject project;
@override @override
String executable(BuildMode buildMode, String targetArch) { String executable(BuildMode buildMode, String targetArch) {
final String binaryName = getCmakeExecutableName(project); final String? binaryName = getCmakeExecutableName(project);
return globals.fs.path.join( return globals.fs.path.join(
'build/elinux/', 'build/elinux/',
targetArch, targetArch,
+40 -47
View File
@@ -1,11 +1,9 @@
// Copyright 2022 Sony Group Corporation. All rights reserved. // Copyright 2023 Sony Group Corporation. All rights reserved.
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2014 The Flutter Authors. All rights reserved.
// 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:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/plugins.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
@@ -33,8 +30,8 @@ import 'elinux_cmake_project.dart';
/// Source: [LinuxPlugin] in `platform_plugins.dart` /// Source: [LinuxPlugin] in `platform_plugins.dart`
class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin { class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
ELinuxPlugin({ ELinuxPlugin({
@required this.name, required this.name,
@required this.directory, required this.directory,
this.pluginClass, this.pluginClass,
this.dartPluginClass, this.dartPluginClass,
this.ffiPlugin, this.ffiPlugin,
@@ -49,24 +46,21 @@ class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
List<String> dependencies) { List<String> dependencies) {
assert(validate(yaml)); assert(validate(yaml));
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497. // Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
String pluginClass = yaml[kPluginClass] as String; String? pluginClass = yaml[kPluginClass] as String;
if (pluginClass == 'none') { if (pluginClass == 'none') {
pluginClass = null; pluginClass = null;
} }
return ELinuxPlugin( return ELinuxPlugin(
name: name, name: name,
directory: directory, directory: directory,
pluginClass: yaml[kPluginClass] as String, pluginClass: yaml[kPluginClass] as String?,
dartPluginClass: yaml[kDartPluginClass] as String, dartPluginClass: yaml[kDartPluginClass] as String?,
ffiPlugin: yaml[kFfiPlugin] as bool, ffiPlugin: yaml[kFfiPlugin] as bool?,
defaultPackage: yaml[kDefaultPackage] as String, defaultPackage: yaml[kDefaultPackage] as String?,
dependencies: dependencies); dependencies: dependencies);
} }
static bool validate(YamlMap yaml) { static bool validate(YamlMap yaml) {
if (yaml == null) {
return false;
}
return yaml[kPluginClass] is String || return yaml[kPluginClass] is String ||
yaml[kDartPluginClass] is String || yaml[kDartPluginClass] is String ||
yaml[kFfiPlugin] == true || yaml[kFfiPlugin] == true ||
@@ -77,11 +71,11 @@ class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
final String name; final String name;
final Directory directory; final Directory directory;
final String pluginClass; final String? pluginClass;
final String dartPluginClass; final String? dartPluginClass;
final List<String> dependencies; final List<String>? dependencies;
final bool ffiPlugin; final bool? ffiPlugin;
final String defaultPackage; final String? defaultPackage;
@override @override
bool hasMethodChannel() => pluginClass != null; bool hasMethodChannel() => pluginClass != null;
@@ -97,9 +91,9 @@ class ELinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
return <String, dynamic>{ return <String, dynamic>{
'name': name, 'name': name,
if (pluginClass != null) 'class': pluginClass, if (pluginClass != null) 'class': pluginClass,
if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass), if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass!),
if (dartPluginClass != null) 'dartPluginClass': dartPluginClass, if (dartPluginClass != null) 'dartPluginClass': dartPluginClass,
if (ffiPlugin != null && ffiPlugin) kFfiPlugin: true, if (ffiPlugin != null && ffiPlugin!) kFfiPlugin: true,
if (defaultPackage != null) kDefaultPackage: defaultPackage, if (defaultPackage != null) kDefaultPackage: defaultPackage,
}; };
} }
@@ -116,12 +110,12 @@ String _filenameForCppClass(String className) {
/// See: [FlutterCommand.verifyThenRunCommand] in `flutter_command.dart` /// See: [FlutterCommand.verifyThenRunCommand] in `flutter_command.dart`
mixin ELinuxExtension on FlutterCommand { mixin ELinuxExtension on FlutterCommand {
String _entrypoint; String? _entrypoint;
bool get _usesTargetOption => argParser.options.containsKey('target'); bool get _usesTargetOption => argParser.options.containsKey('target');
@override @override
Future<FlutterCommandResult> verifyThenRunCommand(String commandPath) async { Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
if (super.shouldRunPub) { if (super.shouldRunPub) {
// TODO(swift-kim): Should run pub get first before injecting plugins. // TODO(swift-kim): Should run pub get first before injecting plugins.
await ensureReadyForELinuxTooling(FlutterProject.current()); await ensureReadyForELinuxTooling(FlutterProject.current());
@@ -164,7 +158,7 @@ Future<String> _createEntrypoint(
final LanguageVersion languageVersion = determineLanguageVersion( final LanguageVersion languageVersion = determineLanguageVersion(
globals.fs.file(targetFile), globals.fs.file(targetFile),
packageConfig[flutterProject.manifest.appName], packageConfig[flutterProject.manifest.appName],
Cache.flutterRoot, Cache.flutterRoot!,
); );
final Uri mainUri = globals.fs.file(targetFile).absolute.uri; final Uri mainUri = globals.fs.file(targetFile).absolute.uri;
@@ -261,7 +255,7 @@ bool _writeELinuxFlutterPluginsListLegacy(
flutterPluginsBuffer flutterPluginsBuffer
.write('${plugin.name}=${globals.fsUtils.escapePath(plugin.path)}\n'); .write('${plugin.name}=${globals.fsUtils.escapePath(plugin.path)}\n');
} }
final String oldPluginFileContent = _readFileContent(pluginsFile); final String? oldPluginFileContent = _readFileContent(pluginsFile);
final String pluginFileContent = flutterPluginsBuffer.toString(); final String pluginFileContent = flutterPluginsBuffer.toString();
pluginsFile.writeAsStringSync(pluginFileContent, flush: true); pluginsFile.writeAsStringSync(pluginFileContent, flush: true);
@@ -361,7 +355,7 @@ List<Map<String, Object>> _filterELinuxPluginsByPlatform(
_kFlutterPluginsNameKey: plugin.name, _kFlutterPluginsNameKey: plugin.name,
_kFlutterPluginsPathKey: globals.fsUtils.escapePath(plugin.path), _kFlutterPluginsPathKey: globals.fsUtils.escapePath(plugin.path),
_kFlutterPluginsDependenciesKey: <String>[ _kFlutterPluginsDependenciesKey: <String>[
...plugin.dependencies.where(pluginNames.contains) ...plugin.dependencies!.where(pluginNames.contains)
], ],
}); });
} }
@@ -379,7 +373,7 @@ List<Object> _createPluginLegacyDependencyGraph(List<ELinuxPlugin> plugins) {
'name': plugin.name, 'name': plugin.name,
// Extract the plugin dependencies which happen to be plugins. // Extract the plugin dependencies which happen to be plugins.
'dependencies': <String>[ 'dependencies': <String>[
...plugin.dependencies.where(pluginNames.contains) ...plugin.dependencies!.where(pluginNames.contains)
], ],
}); });
} }
@@ -429,7 +423,7 @@ Future<List<ELinuxPlugin>> findELinuxPlugins(
); );
for (final Package package in packageConfig.packages) { for (final Package package in packageConfig.packages) {
final Uri packageRoot = package.packageUriRoot.resolve('..'); final Uri packageRoot = package.packageUriRoot.resolve('..');
final ELinuxPlugin plugin = _pluginFromPackage(package.name, packageRoot); final ELinuxPlugin? plugin = _pluginFromPackage(package.name, packageRoot);
if (plugin == null) { if (plugin == null) {
continue; continue;
} else if (nativeOnly && } else if (nativeOnly &&
@@ -444,7 +438,7 @@ Future<List<ELinuxPlugin>> findELinuxPlugins(
} }
/// Source: [_pluginFromPackage] in `plugins.dart` /// Source: [_pluginFromPackage] in `plugins.dart`
ELinuxPlugin _pluginFromPackage(String name, Uri packageRoot) { ELinuxPlugin? _pluginFromPackage(String name, Uri packageRoot) {
final String pubspecPath = final String pubspecPath =
globals.fs.path.fromUri(packageRoot.resolve('pubspec.yaml')); globals.fs.path.fromUri(packageRoot.resolve('pubspec.yaml'));
if (!globals.fs.isFileSync(pubspecPath)) { if (!globals.fs.isFileSync(pubspecPath)) {
@@ -469,11 +463,11 @@ ELinuxPlugin _pluginFromPackage(String name, Uri packageRoot) {
globals.printTrace('Found plugin $name at ${packageDir.path}'); globals.printTrace('Found plugin $name at ${packageDir.path}');
final YamlMap pluginYaml = flutterConfig['plugin'] as YamlMap; final YamlMap pluginYaml = flutterConfig['plugin'] as YamlMap;
if (pluginYaml == null || pluginYaml['platforms'] == null) { if (pluginYaml['platforms'] == null) {
return null; return null;
} }
final YamlMap platformsYaml = pluginYaml['platforms'] as YamlMap; final YamlMap platformsYaml = pluginYaml['platforms'] as YamlMap;
if (platformsYaml == null || platformsYaml[ELinuxPlugin.kConfigKey] == null) { if (platformsYaml[ELinuxPlugin.kConfigKey] == null) {
return null; return null;
} }
final YamlMap dependencies = pubspec['dependencies'] as YamlMap; final YamlMap dependencies = pubspec['dependencies'] as YamlMap;
@@ -481,9 +475,7 @@ ELinuxPlugin _pluginFromPackage(String name, Uri packageRoot) {
name, name,
packageDir.childDirectory('elinux'), packageDir.childDirectory('elinux'),
platformsYaml[ELinuxPlugin.kConfigKey] as YamlMap, platformsYaml[ELinuxPlugin.kConfigKey] as YamlMap,
dependencies == null <String>[...dependencies.keys.cast<String>()],
? <String>[]
: <String>[...dependencies.keys.cast<String>()],
); );
} }
@@ -627,29 +619,29 @@ void _renderTemplateToFile(String template, dynamic context, String filePath) {
/// Source: [createPluginSymlinks] in `flutter_plugins.dart` /// Source: [createPluginSymlinks] in `flutter_plugins.dart`
void createPluginSymlinks(FlutterProject project, {bool force = false}) { void createPluginSymlinks(FlutterProject project, {bool force = false}) {
Map<String, Object> platformPlugins; Map<String, Object?>? platformPlugins;
final String pluginFileContent = final String? pluginFileContent =
_readFileContent(project.flutterPluginsDependenciesFile); _readFileContent(project.flutterPluginsDependenciesFile);
if (pluginFileContent != null) { if (pluginFileContent != null) {
final Map<String, Object> pluginInfo = final Map<String, Object?>? pluginInfo =
json.decode(pluginFileContent) as Map<String, Object>; json.decode(pluginFileContent) as Map<String, Object?>?;
platformPlugins = platformPlugins =
pluginInfo[_kFlutterPluginsPluginListKey] as Map<String, Object>; pluginInfo?[_kFlutterPluginsPluginListKey] as Map<String, Object?>?;
} }
platformPlugins ??= <String, Object>{}; platformPlugins ??= <String, Object?>{};
final ELinuxProject eLinuxProject = ELinuxProject.fromFlutter(project); final ELinuxProject eLinuxProject = ELinuxProject.fromFlutter(project);
if (eLinuxProject.existsSync()) { if (eLinuxProject.existsSync()) {
_createPlatformPluginSymlinks( _createPlatformPluginSymlinks(
eLinuxProject.pluginSymlinkDirectory, eLinuxProject.pluginSymlinkDirectory,
platformPlugins[eLinuxProject.pluginConfigKey] as List<Object>, platformPlugins[eLinuxProject.pluginConfigKey] as List<Object?>?,
force: force, force: force,
); );
} }
} }
/// Returns the contents of [File] or [null] if that file does not exist. /// Returns the contents of [File] or [null] if that file does not exist.
String _readFileContent(File file) { String? _readFileContent(File file) {
return file.existsSync() ? file.readAsStringSync() : null; return file.existsSync() ? file.readAsStringSync() : null;
} }
@@ -657,7 +649,7 @@ String _readFileContent(File file) {
/// ///
/// If [force] is true, the directory will be created only if missing. /// If [force] is true, the directory will be created only if missing.
void _createPlatformPluginSymlinks( void _createPlatformPluginSymlinks(
Directory symlinkDirectory, List<Object> platformPlugins, Directory symlinkDirectory, List<Object?>? platformPlugins,
{bool force = false}) { {bool force = false}) {
if (force && symlinkDirectory.existsSync()) { if (force && symlinkDirectory.existsSync()) {
// Start fresh to avoid stale links. // Start fresh to avoid stale links.
@@ -667,10 +659,10 @@ void _createPlatformPluginSymlinks(
if (platformPlugins == null) { if (platformPlugins == null) {
return; return;
} }
for (final Map<String, Object> pluginInfo for (final Map<String, Object?> pluginInfo
in platformPlugins.cast<Map<String, Object>>()) { in platformPlugins.cast<Map<String, Object?>>()) {
final String name = pluginInfo[_kFlutterPluginsNameKey] as String; final String name = pluginInfo[_kFlutterPluginsNameKey]! as String;
final String path = pluginInfo[_kFlutterPluginsPathKey] as String; final String path = pluginInfo[_kFlutterPluginsPathKey]! as String;
final Link link = symlinkDirectory.childLink(name); final Link link = symlinkDirectory.childLink(name);
if (link.existsSync()) { if (link.existsSync()) {
continue; continue;
@@ -678,6 +670,7 @@ void _createPlatformPluginSymlinks(
try { try {
link.createSync(path); link.createSync(path);
} on FileSystemException catch (e) { } on FileSystemException catch (e) {
// ignore: invalid_use_of_visible_for_testing_member
handleSymlinkException(e, handleSymlinkException(e,
platform: globals.platform, platform: globals.platform,
os: globals.os, os: globals.os,
+2 -4
View File
@@ -4,8 +4,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:io'; import 'dart:io';
import 'package:flutter_tools/executable.dart' as flutter; import 'package:flutter_tools/executable.dart' as flutter;
@@ -88,11 +86,11 @@ Future<void> main(List<String> args) async {
DevicesCommand(verboseHelp: verboseHelp), DevicesCommand(verboseHelp: verboseHelp),
DoctorCommand(verbose: verbose), DoctorCommand(verbose: verbose),
EmulatorsCommand(), EmulatorsCommand(),
FormatCommand(verboseHelp: verbose), FormatCommand(),
GenerateLocalizationsCommand( GenerateLocalizationsCommand(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
artifacts: globals.artifacts, artifacts: globals.artifacts!,
processManager: globals.processManager, processManager: globals.processManager,
), ),
InstallCommand(verboseHelp: verboseHelp), InstallCommand(verboseHelp: verboseHelp),