Unverified Commit cc541e67 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Add missing pieces for 'driver' support on macOS (#34376)

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