Switch gen_snapshot from Android's one to elinux's one (#82)
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user