Skip to content

Commit

Permalink
Update for flutter 3.10.0 (#182)
Browse files Browse the repository at this point in the history
Signed-off-by: Hidenori Matsubayashi <[email protected]>
  • Loading branch information
HidenoriMatsubayashi authored May 19, 2023
1 parent de7b47e commit 070d039
Show file tree
Hide file tree
Showing 22 changed files with 336 additions and 392 deletions.
4 changes: 1 addition & 3 deletions bin/flutter_elinux.dart
Original file line number Diff line number Diff line change
@@ -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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:flutter_elinux/executable.dart' as executable;

void main(List<String> args) {
Expand Down
2 changes: 1 addition & 1 deletion bin/internal/engine.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1a65d409c7a1438a34d21b60bf30a6fd5db59314
d44b5a94c976fbb65815374f61ab5392a220b084
2 changes: 1 addition & 1 deletion bin/internal/flutter.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
84a1e904f44f9b0e9c4510138010edcc653163f8
18 changes: 11 additions & 7 deletions lib/commands/analyze.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
// 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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:flutter_tools/src/commands/analyze.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project_validator.dart';

import '../elinux_plugins.dart';

class ELinuxAnalyzeCommand extends AnalyzeCommand with ELinuxExtension {
ELinuxAnalyzeCommand({bool verboseHelp = false})
ELinuxAnalyzeCommand({super.verboseHelp})
: super(
verboseHelp: verboseHelp,
fileSystem: globals.fs,
platform: globals.platform,
processManager: globals.processManager,
logger: globals.logger,
terminal: globals.terminal,
artifacts: globals.artifacts,
artifacts: globals.artifacts!,
// new ProjectValidators should be added here for the --suggestions to run
allProjectValidators: <ProjectValidator>[
GeneralInfoProjectValidator()
GeneralInfoProjectValidator(),
VariableDumpMachineProjectValidator(
logger: globals.logger,
fileSystem: globals.fs,
platform: globals.platform,
),
],
suppressAnalytics: globals.flutterUsage.suppressAnalytics,
);
}
14 changes: 4 additions & 10 deletions lib/commands/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

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/common.dart';
Expand Down Expand Up @@ -57,7 +55,6 @@ class BuildPackageCommand extends BuildSubCommand
);
argParser.addOption(
'target-compiler-triple',
defaultsTo: null,
help: 'Target compiler triple for which the app is compiled. '
'e.g. aarch64-linux-gnu',
);
Expand All @@ -70,20 +67,17 @@ class BuildPackageCommand extends BuildSubCommand
);
argParser.addOption(
'target-toolchain',
defaultsTo: null,
help: 'The toolchain path for Clang.',
);
argParser.addOption(
'system-include-directories',
defaultsTo: null,
help:
'The additional system include paths to cross-compile for target platform. '
'This option is valid only '
'if the current host and target architectures are different.',
);
argParser.addOption(
'target-compiler-flags',
defaultsTo: null,
help: 'The extra compile flags to be applied to C and C++ compiler',
);
}
Expand Down Expand Up @@ -118,7 +112,7 @@ class BuildPackageCommand extends BuildSubCommand
@override
Future<FlutterCommandResult> runCommand() async {
// Not supported cross-building for x64 on arm64.
final String targetArch = stringArg('target-arch');
final String? targetArch = stringArg('target-arch');
final String hostArch = _getCurrentHostPlatformArchName();
if (hostArch != targetArch && hostArch == 'arm64') {
globals.logger
Expand All @@ -129,10 +123,10 @@ class BuildPackageCommand extends BuildSubCommand
final BuildInfo buildInfo = await getBuildInfo();
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(
buildInfo,
targetArch: targetArch,
targetBackendType: stringArg('target-backend-type'),
targetArch: targetArch!,
targetBackendType: stringArg('target-backend-type')!,
targetCompilerTriple: stringArg('target-compiler-triple'),
targetSysroot: stringArg('target-sysroot'),
targetSysroot: stringArg('target-sysroot')!,
targetCompilerFlags: stringArg('target-compiler-flags'),
targetToolchain: stringArg('target-toolchain'),
systemIncludeDirectories: stringArg('system-include-directories'),
Expand Down
8 changes: 3 additions & 5 deletions lib/commands/clean.dart
Original file line number Diff line number Diff line change
@@ -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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:file/file.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/commands/clean.dart';
Expand All @@ -16,7 +14,7 @@ import 'package:path/path.dart';
import '../elinux_cmake_project.dart';

class ELinuxCleanCommand extends CleanCommand {
ELinuxCleanCommand({bool verbose = false}) : super(verbose: verbose);
ELinuxCleanCommand({super.verbose});

/// See: [CleanCommand.runCommand] in `clean.dart`
@override
Expand Down Expand Up @@ -48,7 +46,7 @@ class ELinuxCleanCommand extends CleanCommand {
} on FileSystemException catch (error) {
globals.printError('Failed to remove $path: $error');
} finally {
status?.stop();
status.stop();
}
}
}
23 changes: 10 additions & 13 deletions lib/commands/create.dart
Original file line number Diff line number Diff line change
@@ -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 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'dart:io';

import 'package:flutter_tools/src/base/common.dart';
Expand All @@ -30,11 +28,10 @@ const List<String> _kAvailablePlatforms = <String>[
];

class ELinuxCreateCommand extends CreateCommand {
ELinuxCreateCommand({bool verboseHelp = false})
: super(verboseHelp: verboseHelp);
ELinuxCreateCommand({super.verboseHelp});

@override
void addPlatformsOptions({String customHelp}) {
void addPlatformsOptions({String? customHelp}) {
argParser.addMultiOption(
'platforms',
help: customHelp,
Expand All @@ -47,7 +44,7 @@ class ELinuxCreateCommand extends CreateCommand {
Future<int> renderTemplate(
String templateName,
Directory directory,
Map<String, Object> context, {
Map<String, Object?> context, {
bool overwrite = false,
bool printStatusWhenWriting = true,
}) async {
Expand All @@ -67,7 +64,7 @@ class ELinuxCreateCommand extends CreateCommand {
Future<int> renderMerged(
List<String> names,
Directory directory,
Map<String, Object> context, {
Map<String, Object?> context, {
bool overwrite = false,
bool printStatusWhenWriting = true,
}) async {
Expand All @@ -79,14 +76,14 @@ class ELinuxCreateCommand extends CreateCommand {
fileSystem: globals.fs,
logger: globals.logger,
templateRenderer: globals.templateRenderer,
templateManifest: null,
templateManifest: <Uri>{},
);
return template.render(directory, context, overwriteExisting: overwrite);
}

/// See: [CreateCommand._getProjectType] in `create.dart`
bool get _shouldGeneratePlugin {
if (argResults['template'] != null) {
if (argResults!['template'] != null) {
return stringArg('template') == 'plugin';
} else if (projectDir.existsSync() && projectDir.listSync().isNotEmpty) {
return determineTemplateType() == FlutterProjectType.plugin;
Expand Down Expand Up @@ -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.
final String titleCaseProjectName = snakeCaseToTitleCase(projectName);

final Map<String, Object> templateContext = createTemplateContext(
final Map<String, Object?> templateContext = createTemplateContext(
organization: '',
projectName: projectName,
flutterRoot: '',
Expand All @@ -140,12 +137,12 @@ class ELinuxCreateCommand extends CreateCommand {
/// - [Template.render] in `template.dart`
@override
Future<FlutterCommandResult> runCommand() async {
if (argResults.rest.isEmpty) {
if (argResults!.rest.isEmpty) {
return super.runCommand();
}
final List<String> platforms = stringsArg('platforms');
bool shouldRenderELinuxTemplate = platforms.contains('elinux');
if (_shouldGeneratePlugin && !argResults.wasParsed('platforms')) {
if (_shouldGeneratePlugin && !argResults!.wasParsed('platforms')) {
shouldRenderELinuxTemplate = false;
}
if (!shouldRenderELinuxTemplate) {
Expand Down
5 changes: 1 addition & 4 deletions lib/commands/drive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:flutter_tools/src/commands/drive.dart';
import 'package:flutter_tools/src/globals.dart' as globals;

Expand All @@ -13,9 +11,8 @@ import '../elinux_plugins.dart';

class ELinuxDriveCommand extends DriveCommand
with ELinuxExtension, ELinuxRequiredArtifacts {
ELinuxDriveCommand({bool verboseHelp = false})
ELinuxDriveCommand({super.verboseHelp})
: super(
verboseHelp: verboseHelp,
fileSystem: globals.fs,
logger: globals.logger,
platform: globals.platform,
Expand Down
41 changes: 20 additions & 21 deletions lib/commands/packages.dart
Original file line number Diff line number Diff line change
@@ -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 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:flutter_tools/src/base/os.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/project.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
Expand All @@ -21,13 +20,18 @@ import '../elinux_plugins.dart';
/// Source: [PackagesCommand] in `packages.dart`
class ELinuxPackagesCommand extends FlutterCommand {
ELinuxPackagesCommand() {
addSubcommand(ELinuxPackagesGetCommand('get', false));
addSubcommand(ELinuxPackagesInteractiveGetCommand('upgrade',
"Upgrade the current package's dependencies to latest versions."));
addSubcommand(ELinuxPackagesInteractiveGetCommand(
'add', 'Add a dependency to pubspec.yaml.'));
addSubcommand(ELinuxPackagesInteractiveGetCommand(
'remove', 'Removes a dependency from the current package.'));
addSubcommand(ELinuxPackagesGetCommand(
'get', "Get the current package's dependencies.", PubContext.pubGet));
addSubcommand(ELinuxPackagesGetCommand(
'upgrade',
"Upgrade the current package's dependencies to latest versions.",
PubContext.pubUpgrade));
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(PackagesForwardCommand(
'publish', 'Publish the current package to pub.dartlang.org',
Expand Down Expand Up @@ -65,18 +69,13 @@ class ELinuxPackagesCommand extends FlutterCommand {
final String description = 'Commands for managing Flutter packages.';

@override
Future<FlutterCommandResult> runCommand() async => null;
Future<FlutterCommandResult> runCommand() async =>
FlutterCommandResult.fail();
}

class ELinuxPackagesGetCommand extends PackagesGetCommand
with _PostRunPluginInjection {
ELinuxPackagesGetCommand(String name, bool upgrade) : super(name, upgrade);
}

class ELinuxPackagesInteractiveGetCommand extends PackagesInteractiveGetCommand
with _PostRunPluginInjection {
ELinuxPackagesInteractiveGetCommand(String commandName, String description)
: super(commandName, description);
ELinuxPackagesGetCommand(super.commandName, super.description, super.context);
}

mixin _PostRunPluginInjection on FlutterCommand {
Expand All @@ -86,9 +85,9 @@ mixin _PostRunPluginInjection on FlutterCommand {
final FlutterCommandResult result = await super.runCommand();

if (result == FlutterCommandResult.success()) {
final String workingDirectory =
argResults.rest.isNotEmpty ? argResults.rest[0] : null;
final String target = findProjectRoot(globals.fs, workingDirectory);
final String? workingDirectory =
argResults!.rest.isNotEmpty ? argResults!.rest[0] : null;
final String? target = findProjectRoot(globals.fs, workingDirectory);
if (target == null) {
return result;
}
Expand Down
33 changes: 9 additions & 24 deletions lib/commands/precache.dart
Original file line number Diff line number Diff line change
@@ -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.
// Use of this source code is governed by a BSD-style license that can be
// 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/cache.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:meta/meta.dart';

import '../elinux_cache.dart';

class ELinuxPrecacheCommand extends PrecacheCommand {
ELinuxPrecacheCommand({
bool verboseHelp = false,
@required Cache cache,
@required Platform platform,
@required Logger logger,
@required FeatureFlags featureFlags,
super.verboseHelp,
required super.cache,
required super.platform,
required super.logger,
required super.featureFlags,
}) : _cache = cache,
_platform = platform,
super(
verboseHelp: verboseHelp,
cache: cache,
platform: platform,
logger: logger,
featureFlags: featureFlags,
) {
_platform = platform {
argParser.addFlag(
'elinux',
negatable: true,
defaultsTo: false,
help: 'Precache artifacts for Embedded Linux development.',
);
}
Expand All @@ -46,7 +31,7 @@ class ELinuxPrecacheCommand extends PrecacheCommand {
bool get _includeOtherPlatforms =>
boolArg('android') ||
DevelopmentArtifact.values.any((DevelopmentArtifact artifact) =>
boolArg(artifact.name) && argResults.wasParsed(artifact.name));
boolArg(artifact.name) && argResults!.wasParsed(artifact.name));

@override
Future<FlutterCommandResult> runCommand() async {
Expand All @@ -73,7 +58,7 @@ class ELinuxPrecacheCommand extends PrecacheCommand {
if (includeAllPlatforms || includeDefaults || _includeOtherPlatforms) {
// If the '--force' option is used, the super.runCommand() will delete
// 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();
if (elinuxStamp != null) {
_cache.setStampFor(elinuxStampName, elinuxStamp);
Expand Down
Loading

0 comments on commit 070d039

Please sign in to comment.