
Moves the checks that projects have been configured for desktop to a lower level, where they will cover more codepaths (e.g., 'run'), and improves them to check for native build projects, rather than just directories, to catch cases where the directory exists (e.g., due to accidental creation of generated files). Also adds links to the error messages pointing to instructions on adding desktop support to a project. Fixes #47145
53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
// 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.
|
|
|
|
import 'dart:async';
|
|
|
|
import '../base/common.dart';
|
|
import '../build_info.dart';
|
|
import '../cache.dart';
|
|
import '../features.dart';
|
|
import '../globals.dart' as globals;
|
|
import '../linux/build_linux.dart';
|
|
import '../project.dart';
|
|
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
|
import 'build.dart';
|
|
|
|
/// A command to build a linux desktop target through a build shell script.
|
|
class BuildLinuxCommand extends BuildSubCommand {
|
|
BuildLinuxCommand() {
|
|
addBuildModeFlags();
|
|
usesTargetOption();
|
|
}
|
|
|
|
@override
|
|
final String name = 'linux';
|
|
|
|
@override
|
|
bool get hidden => !featureFlags.isLinuxEnabled || !globals.platform.isLinux;
|
|
|
|
@override
|
|
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
|
|
DevelopmentArtifact.linux,
|
|
};
|
|
|
|
@override
|
|
String get description => 'build the Linux desktop target.';
|
|
|
|
@override
|
|
Future<FlutterCommandResult> runCommand() async {
|
|
Cache.releaseLockEarly();
|
|
final BuildInfo buildInfo = getBuildInfo();
|
|
final FlutterProject flutterProject = FlutterProject.current();
|
|
if (!featureFlags.isLinuxEnabled) {
|
|
throwToolExit('"build linux" is not currently supported.');
|
|
}
|
|
if (!globals.platform.isLinux) {
|
|
throwToolExit('"build linux" only supported on Linux hosts.');
|
|
}
|
|
await buildLinux(flutterProject.linux, buildInfo, target: targetFile);
|
|
return null;
|
|
}
|
|
}
|