Switch gen_snapshot from Android's one to elinux's one (#82)
This commit is contained in:
committed by
GitHub
parent
122afc884c
commit
3050096d46
@@ -27,7 +27,8 @@ class ELinuxBuildCommand extends BuildCommand {
|
||||
}
|
||||
}
|
||||
|
||||
class BuildPackageCommand extends BuildSubCommand with ELinuxExtension {
|
||||
class BuildPackageCommand extends BuildSubCommand
|
||||
with ELinuxExtension, ELinuxRequiredArtifacts {
|
||||
/// See: [BuildApkCommand] in `build_apk.dart`
|
||||
BuildPackageCommand({bool verboseHelp = false})
|
||||
: super(verboseHelp: verboseHelp) {
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
import 'package:flutter_tools/src/commands/drive.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
|
||||
import '../elinux_cache.dart';
|
||||
import '../elinux_plugins.dart';
|
||||
|
||||
class ELinuxDriveCommand extends DriveCommand with ELinuxExtension {
|
||||
class ELinuxDriveCommand extends DriveCommand
|
||||
with ELinuxExtension, ELinuxRequiredArtifacts {
|
||||
ELinuxDriveCommand({bool verboseHelp = false})
|
||||
: super(
|
||||
verboseHelp: verboseHelp,
|
||||
|
||||
@@ -13,7 +13,8 @@ import 'package:flutter_tools/src/commands/run.dart';
|
||||
import '../elinux_cache.dart';
|
||||
import '../elinux_plugins.dart';
|
||||
|
||||
class ELinuxRunCommand extends RunCommand with ELinuxExtension {
|
||||
class ELinuxRunCommand extends RunCommand
|
||||
with ELinuxExtension, ELinuxRequiredArtifacts {
|
||||
ELinuxRunCommand({bool verboseHelp = false})
|
||||
: super(verboseHelp: verboseHelp);
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
|
||||
class ELinuxArtifacts extends CachedArtifacts {
|
||||
ELinuxArtifacts({
|
||||
required FileSystem fileSystem,
|
||||
required Platform platform,
|
||||
required Cache cache,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
}) : _cache = cache,
|
||||
super(
|
||||
fileSystem: fileSystem,
|
||||
platform: platform,
|
||||
cache: cache,
|
||||
operatingSystemUtils: operatingSystemUtils,
|
||||
);
|
||||
|
||||
final Cache _cache;
|
||||
|
||||
/// See: [CachedArtifacts._getEngineArtifactsPath]
|
||||
Directory _getEngineArtifactsDirectory(String arch, BuildMode mode) {
|
||||
return _cache
|
||||
.getArtifactDirectory('engine')
|
||||
.childDirectory('elinux-$arch-${mode.name}');
|
||||
}
|
||||
|
||||
/// See: [CachedArtifacts._getAndroidArtifactPath] in `artifacts.dart`
|
||||
@override
|
||||
String getArtifactPath(
|
||||
Artifact artifact, {
|
||||
TargetPlatform? platform,
|
||||
BuildMode? mode,
|
||||
EnvironmentType? environmentType,
|
||||
}) {
|
||||
if (artifact == Artifact.genSnapshot &&
|
||||
platform != null &&
|
||||
getNameForTargetPlatform(platform).startsWith('android')) {
|
||||
assert(mode != null, 'Need to specify a build mode.');
|
||||
assert(mode != BuildMode.debug,
|
||||
'Artifact $artifact only available in non-debug mode.');
|
||||
final String arch = _getArchForTargetPlatform(platform);
|
||||
final HostPlatform hostPlatform = getCurrentHostPlatform();
|
||||
assert(hostPlatform != HostPlatform.linux_arm64,
|
||||
'Artifact $artifact not available on Linux arm64.');
|
||||
return _getEngineArtifactsDirectory(arch, mode!)
|
||||
// TODO(hidenori): Remove this comment out.
|
||||
// See: https://github.com/sony/flutter-elinux/issues/81
|
||||
//.childDirectory(getNameForHostPlatform(hostPlatform))
|
||||
.childFile('gen_snapshot')
|
||||
.path;
|
||||
}
|
||||
return super.getArtifactPath(artifact, platform: platform, mode: mode);
|
||||
}
|
||||
|
||||
String _getArchForTargetPlatform(TargetPlatform platform) {
|
||||
if (platform == TargetPlatform.android_arm64) {
|
||||
return 'arm64';
|
||||
} else {
|
||||
return 'x64';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,16 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/flutter_cache.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
|
||||
mixin ELinuxRequiredArtifacts on FlutterCommand {
|
||||
@override
|
||||
Future<Set<DevelopmentArtifact>> get requiredArtifacts async =>
|
||||
<DevelopmentArtifact>{
|
||||
...await super.requiredArtifacts,
|
||||
ELinuxDevelopmentArtifact.elinux,
|
||||
};
|
||||
}
|
||||
|
||||
/// See: [DevelopmentArtifact] in `cache.dart`
|
||||
class ELinuxDevelopmentArtifact implements DevelopmentArtifact {
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'dart:io';
|
||||
import 'package:flutter_tools/executable.dart' as flutter;
|
||||
import 'package:flutter_tools/runner.dart' as runner;
|
||||
import 'package:flutter_tools/src/application_package.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/template.dart';
|
||||
@@ -48,6 +49,7 @@ import 'elinux_cache.dart';
|
||||
import 'elinux_device_discovery.dart';
|
||||
import 'elinux_doctor.dart';
|
||||
import 'elinux_package.dart';
|
||||
import 'elinux_artifacts.dart';
|
||||
|
||||
/// Main entry point for commands.
|
||||
///
|
||||
@@ -127,6 +129,12 @@ Future<void> main(List<String> args) async {
|
||||
),
|
||||
TemplateRenderer: () => const MustacheTemplateRenderer(),
|
||||
ApplicationPackageFactory: () => ELinuxApplicationPackageFactory(),
|
||||
Artifacts: () => ELinuxArtifacts(
|
||||
fileSystem: globals.fs,
|
||||
cache: globals.cache,
|
||||
platform: globals.platform,
|
||||
operatingSystemUtils: globals.os,
|
||||
),
|
||||
DeviceManager: () => ELinuxDeviceManager(),
|
||||
DoctorValidatorsProvider: () => ELinuxDoctorValidatorsProvider(),
|
||||
ELinuxWorkflow: () => ELinuxWorkflow(
|
||||
|
||||
Reference in New Issue
Block a user