Add missing pieces for 'driver' support on macOS (#34376)
- Adds desktop projects to ApplicationPackageStore - Plumbs target overrides through the macOS build
This commit is contained in:
@@ -395,6 +395,9 @@ class ApplicationPackageStore {
|
||||
AndroidApk android;
|
||||
IOSApp iOS;
|
||||
FuchsiaApp fuchsia;
|
||||
LinuxApp linux;
|
||||
MacOSApp macOS;
|
||||
WindowsApp windows;
|
||||
|
||||
Future<ApplicationPackage> getPackageForPlatform(TargetPlatform platform) async {
|
||||
switch (platform) {
|
||||
@@ -411,8 +414,14 @@ class ApplicationPackageStore {
|
||||
fuchsia ??= FuchsiaApp.fromFuchsiaProject(FlutterProject.current().fuchsia);
|
||||
return fuchsia;
|
||||
case TargetPlatform.darwin_x64:
|
||||
macOS ??= MacOSApp.fromMacOSProject(FlutterProject.current().macos);
|
||||
return macOS;
|
||||
case TargetPlatform.linux_x64:
|
||||
linux ??= LinuxApp.fromLinuxProject(FlutterProject.current().linux);
|
||||
return linux;
|
||||
case TargetPlatform.windows_x64:
|
||||
windows ??= WindowsApp.fromWindowsProject(FlutterProject.current().windows);
|
||||
return windows;
|
||||
case TargetPlatform.tester:
|
||||
case TargetPlatform.web_javascript:
|
||||
return null;
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'build.dart';
|
||||
/// A command to build a macos desktop target through a build shell script.
|
||||
class BuildMacosCommand extends BuildSubCommand {
|
||||
BuildMacosCommand() {
|
||||
usesTargetOption();
|
||||
argParser.addFlag('debug',
|
||||
negatable: false,
|
||||
help: 'Build a debug version of your app.',
|
||||
@@ -59,7 +60,11 @@ class BuildMacosCommand extends BuildSubCommand {
|
||||
if (!flutterProject.macos.existsSync()) {
|
||||
throwToolExit('No macOS desktop project configured.');
|
||||
}
|
||||
await buildMacOS(flutterProject, buildInfo);
|
||||
await buildMacOS(
|
||||
flutterProject: flutterProject,
|
||||
buildInfo: buildInfo,
|
||||
targetOverride: targetFile,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,13 @@ import '../project.dart';
|
||||
import '../usage.dart';
|
||||
import 'cocoapod_utils.dart';
|
||||
|
||||
/// Builds the macOS project through xcode build.
|
||||
// TODO(jonahwilliams): support target option.
|
||||
/// Builds the macOS project through xcodebuild.
|
||||
// TODO(jonahwilliams): refactor to share code with the existing iOS code.
|
||||
Future<void> buildMacOS(FlutterProject flutterProject, BuildInfo buildInfo) async {
|
||||
Future<void> buildMacOS({
|
||||
FlutterProject flutterProject,
|
||||
BuildInfo buildInfo,
|
||||
String targetOverride,
|
||||
}) async {
|
||||
final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory());
|
||||
if (!flutterBuildDir.existsSync()) {
|
||||
flutterBuildDir.createSync(recursive: true);
|
||||
@@ -27,6 +30,7 @@ Future<void> buildMacOS(FlutterProject flutterProject, BuildInfo buildInfo) asyn
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: flutterProject,
|
||||
buildInfo: buildInfo,
|
||||
targetOverride: targetOverride,
|
||||
useMacOSConfig: true,
|
||||
setSymroot: false,
|
||||
);
|
||||
|
||||
@@ -75,7 +75,11 @@ class MacOSDevice extends Device {
|
||||
// Stop any running applications with the same executable.
|
||||
if (!prebuiltApplication) {
|
||||
Cache.releaseLockEarly();
|
||||
await buildMacOS(FlutterProject.current(), debuggingOptions?.buildInfo);
|
||||
await buildMacOS(
|
||||
flutterProject: FlutterProject.current(),
|
||||
buildInfo: debuggingOptions?.buildInfo,
|
||||
targetOverride: mainPath,
|
||||
);
|
||||
}
|
||||
|
||||
// Ensure that the executable is locatable.
|
||||
|
||||
@@ -63,6 +63,7 @@ void main() {
|
||||
applyMocksToCommand(command);
|
||||
fs.file('pubspec.yaml').createSync();
|
||||
fs.file('.packages').createSync();
|
||||
fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'macos']
|
||||
@@ -78,6 +79,7 @@ void main() {
|
||||
fs.directory('macos').createSync();
|
||||
fs.file('pubspec.yaml').createSync();
|
||||
fs.file('.packages').createSync();
|
||||
fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||
final FlutterProject flutterProject = FlutterProject.fromDirectory(fs.currentDirectory);
|
||||
final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user