linux_device.dart 1.76 KB
Newer Older
1 2 3 4 5 6
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../base/platform.dart';
import '../build_info.dart';
7
import '../desktop_device.dart';
8
import '../device.dart';
9 10 11
import '../project.dart';
import 'application_package.dart';
import 'build_linux.dart';
12 13 14
import 'linux_workflow.dart';

/// A device that represents a desktop Linux target.
15
class LinuxDevice extends DesktopDevice {
16 17 18 19 20
  LinuxDevice() : super(
      'Linux',
      platformType: PlatformType.linux,
      ephemeral: false,
  );
21 22 23 24 25 26 27 28

  @override
  bool isSupported() => true;

  @override
  String get name => 'Linux';

  @override
29
  Future<TargetPlatform> get targetPlatform async => TargetPlatform.linux_x64;
30 31

  @override
32 33 34
  bool isSupportedForProject(FlutterProject flutterProject) {
    return flutterProject.linux.existsSync();
  }
35 36

  @override
37
  Future<void> buildForDevice(
38
    covariant LinuxApp package, {
39
    String mainPath,
40
    BuildInfo buildInfo,
41
  }) async {
42 43 44 45 46
    await buildLinux(
      FlutterProject.current().linux,
      buildInfo,
      target: mainPath,
    );
47 48 49
  }

  @override
50 51
  String executablePathForDevice(covariant LinuxApp package, BuildMode buildMode) {
    return package.executable(buildMode);
52
  }
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
}

class LinuxDevices extends PollingDeviceDiscovery {
  LinuxDevices() : super('linux devices');

  @override
  bool get supportsPlatform => platform.isLinux;

  @override
  bool get canListAnything => linuxWorkflow.canListDevices;

  @override
  Future<List<Device>> pollingGetDevices() async {
    if (!canListAnything) {
      return const <Device>[];
    }
    return <Device>[
70
      LinuxDevice(),
71 72 73 74 75 76
    ];
  }

  @override
  Future<List<String>> getDiagnostics() async => const <String>[];
}