Add Xcode build script for macOS target (#31329)
This commit is contained in:
@@ -3,22 +3,46 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/process_manager.dart';
|
||||
import '../build_info.dart';
|
||||
import '../cache.dart';
|
||||
import '../convert.dart';
|
||||
import '../globals.dart';
|
||||
import '../ios/xcodeproj.dart';
|
||||
import '../project.dart';
|
||||
|
||||
/// Builds the macOS project through the project shell script.
|
||||
/// Builds the macOS project through xcode build.
|
||||
// TODO(jonahwilliams): support target option.
|
||||
// TODO(jonahwilliams): refactor to share code with the existing iOS code.
|
||||
Future<void> buildMacOS(FlutterProject flutterProject, BuildInfo buildInfo) async {
|
||||
// Write configuration to an xconfig file in a standard location.
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: flutterProject,
|
||||
buildInfo: buildInfo,
|
||||
useMacOSConfig: true,
|
||||
);
|
||||
// Set debug or release mode.
|
||||
String config = 'Debug';
|
||||
if (buildInfo.isRelease) {
|
||||
config = 'Release';
|
||||
}
|
||||
final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory());
|
||||
if (!flutterBuildDir.existsSync()) {
|
||||
flutterBuildDir.createSync(recursive: true);
|
||||
}
|
||||
// Run build script provided by application.
|
||||
final Process process = await processManager.start(<String>[
|
||||
flutterProject.macos.buildScript.path,
|
||||
Cache.flutterRoot,
|
||||
buildInfo?.isDebug == true ? 'debug' : 'release',
|
||||
buildInfo?.trackWidgetCreation == true ? 'track-widget-creation' : 'no-track-widget-creation',
|
||||
'/usr/bin/env',
|
||||
'xcrun',
|
||||
'xcodebuild',
|
||||
'-project', flutterProject.macos.xcodeProjectFile.path,
|
||||
'-configuration', '$config',
|
||||
'-scheme', 'Runner',
|
||||
'-derivedDataPath', flutterBuildDir.absolute.path,
|
||||
'OBJROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
|
||||
'SYMROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
|
||||
], runInShell: true);
|
||||
final Status status = logger.startProgress(
|
||||
'Building macOS application...',
|
||||
|
||||
Reference in New Issue
Block a user