Commit 66fee3a6 authored by Chinmay Garde's avatar Chinmay Garde

Wire up ios-profile and ios-release. Switching between debug, profile and...

Wire up ios-profile and ios-release. Switching between debug, profile and release starts the build process from scratch. (#4063)
parent 65bed961
...@@ -325,7 +325,8 @@ class AndroidDevice extends Device { ...@@ -325,7 +325,8 @@ class AndroidDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage package,
BuildMode mode, {
String mainPath, String mainPath,
String route, String route,
DebuggingOptions debuggingOptions, DebuggingOptions debuggingOptions,
......
...@@ -60,7 +60,7 @@ String getNameForTargetPlatform(TargetPlatform platform) { ...@@ -60,7 +60,7 @@ String getNameForTargetPlatform(TargetPlatform platform) {
case TargetPlatform.android_x86: case TargetPlatform.android_x86:
return 'android-x86'; return 'android-x86';
case TargetPlatform.ios: case TargetPlatform.ios:
return 'ios_release'; return 'ios';
case TargetPlatform.darwin_x64: case TargetPlatform.darwin_x64:
return 'darwin-x64'; return 'darwin-x64';
case TargetPlatform.linux_x64: case TargetPlatform.linux_x64:
......
...@@ -210,7 +210,7 @@ class FlutterEngine { ...@@ -210,7 +210,7 @@ class FlutterEngine {
]; ];
if (Platform.isMacOS) if (Platform.isMacOS)
dirs.add('ios_release'); dirs.addAll(<String>['ios', 'ios-profile', 'ios-release']);
else if (Platform.isLinux) else if (Platform.isLinux)
dirs.add('linux-x64'); dirs.add('linux-x64');
......
...@@ -12,6 +12,7 @@ import '../runner/flutter_command.dart'; ...@@ -12,6 +12,7 @@ import '../runner/flutter_command.dart';
class BuildIOSCommand extends FlutterCommand { class BuildIOSCommand extends FlutterCommand {
BuildIOSCommand() { BuildIOSCommand() {
addBuildModeFlags();
argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device.'); argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device.');
argParser.addFlag('codesign', negatable: true, defaultsTo: true, argParser.addFlag('codesign', negatable: true, defaultsTo: true,
help: 'Codesign the application bundle (only available on device builds).'); help: 'Codesign the application bundle (only available on device builds).');
...@@ -49,8 +50,9 @@ class BuildIOSCommand extends FlutterCommand { ...@@ -49,8 +50,9 @@ class BuildIOSCommand extends FlutterCommand {
printStatus('Building $app for $logTarget...'); printStatus('Building $app for $logTarget...');
bool result = await buildIOSXcodeProject(app, bool result = await buildIOSXcodeProject(app, getBuildMode(),
buildForDevice: !forSimulator, codesign: shouldCodesign); buildForDevice: !forSimulator,
codesign: shouldCodesign);
if (!result) { if (!result) {
printError('Encountered error while building for $logTarget.'); printError('Encountered error while building for $logTarget.');
......
...@@ -266,6 +266,7 @@ Future<int> startApp(DriveCommand command, BuildMode buildMode) async { ...@@ -266,6 +266,7 @@ Future<int> startApp(DriveCommand command, BuildMode buildMode) async {
printTrace('Starting application.'); printTrace('Starting application.');
LaunchResult result = await command.device.startApp( LaunchResult result = await command.device.startApp(
package, package,
buildMode,
mainPath: mainPath, mainPath: mainPath,
route: command.route, route: command.route,
debuggingOptions: new DebuggingOptions.enabled( debuggingOptions: new DebuggingOptions.enabled(
......
...@@ -215,6 +215,7 @@ Future<int> startApp( ...@@ -215,6 +215,7 @@ Future<int> startApp(
LaunchResult result = await device.startApp( LaunchResult result = await device.startApp(
package, package,
buildMode,
mainPath: mainPath, mainPath: mainPath,
route: route, route: route,
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
...@@ -359,6 +360,7 @@ class _RunAndStayResident { ...@@ -359,6 +360,7 @@ class _RunAndStayResident {
LaunchResult result = await device.startApp( LaunchResult result = await device.startApp(
package, package,
buildMode,
mainPath: mainPath, mainPath: mainPath,
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
platformArgs: platformArgs platformArgs: platformArgs
......
...@@ -175,9 +175,10 @@ abstract class Device { ...@@ -175,9 +175,10 @@ abstract class Device {
/// Start an app package on the current device. /// Start an app package on the current device.
/// ///
/// [platformArgs] allows callers to pass platform-specific arguments to the /// [platformArgs] allows callers to pass platform-specific arguments to the
/// start call. /// start call. The build mode is not used by all platforms.
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage package,
BuildMode mode, {
String mainPath, String mainPath,
String route, String route,
DebuggingOptions debuggingOptions, DebuggingOptions debuggingOptions,
......
...@@ -153,7 +153,8 @@ class IOSDevice extends Device { ...@@ -153,7 +153,8 @@ class IOSDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage app, { ApplicationPackage app,
BuildMode mode, {
String mainPath, String mainPath,
String route, String route,
DebuggingOptions debuggingOptions, DebuggingOptions debuggingOptions,
...@@ -163,8 +164,8 @@ class IOSDevice extends Device { ...@@ -163,8 +164,8 @@ class IOSDevice extends Device {
// TODO(devoncarew): Handle startPaused, debugPort. // TODO(devoncarew): Handle startPaused, debugPort.
printTrace('Building ${app.name} for $id'); printTrace('Building ${app.name} for $id');
// Step 1: Install the precompiled application if necessary. // Step 1: Install the precompiled/DBC application if necessary.
bool buildResult = await buildIOSXcodeProject(app, buildForDevice: true); bool buildResult = await buildIOSXcodeProject(app, mode, buildForDevice: true);
if (!buildResult) { if (!buildResult) {
printError('Could not build the precompiled application for the device.'); printError('Could not build the precompiled application for the device.');
return new LaunchResult.failed(); return new LaunchResult.failed();
......
...@@ -11,6 +11,7 @@ import 'package:path/path.dart' as path; ...@@ -11,6 +11,7 @@ import 'package:path/path.dart' as path;
import '../application_package.dart'; import '../application_package.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart'; import '../globals.dart';
import '../services.dart'; import '../services.dart';
...@@ -96,13 +97,13 @@ bool _xcodeVersionCheckValid(int major, int minor) { ...@@ -96,13 +97,13 @@ bool _xcodeVersionCheckValid(int major, int minor) {
return false; return false;
} }
Future<bool> buildIOSXcodeProject(ApplicationPackage app, Future<bool> buildIOSXcodeProject(ApplicationPackage app, BuildMode mode,
{ bool buildForDevice, bool codesign: true }) async { { bool buildForDevice, bool codesign: true }) async {
String flutterProjectPath = Directory.current.path; String flutterProjectPath = Directory.current.path;
if (xcodeProjectRequiresUpdate()) { if (xcodeProjectRequiresUpdate(mode)) {
printTrace('Initializing the Xcode project.'); printTrace('Initializing the Xcode project.');
if ((await setupXcodeProjectHarness(flutterProjectPath)) != 0) { if ((await setupXcodeProjectHarness(flutterProjectPath, mode)) != 0) {
printError('Could not initialize the Xcode project.'); printError('Could not initialize the Xcode project.');
return false; return false;
} }
...@@ -200,7 +201,9 @@ bool _validateEngineRevision(ApplicationPackage app) { ...@@ -200,7 +201,9 @@ bool _validateEngineRevision(ApplicationPackage app) {
String _getIOSEngineRevision(ApplicationPackage app) { String _getIOSEngineRevision(ApplicationPackage app) {
File revisionFile = new File(path.join(app.localPath, 'REVISION')); File revisionFile = new File(path.join(app.localPath, 'REVISION'));
if (revisionFile.existsSync()) { if (revisionFile.existsSync()) {
return revisionFile.readAsStringSync().trim(); // The format is 'REVISION-mode'. We only need the revision.
String revisionStamp = revisionFile.readAsStringSync().trim();
return revisionStamp.split('-')[0];
} else { } else {
return null; return null;
} }
......
...@@ -75,7 +75,7 @@ void updateXcodeLocalProperties(String projectPath) { ...@@ -75,7 +75,7 @@ void updateXcodeLocalProperties(String projectPath) {
localsFile.writeAsStringSync(localsBuffer.toString()); localsFile.writeAsStringSync(localsBuffer.toString());
} }
bool xcodeProjectRequiresUpdate() { bool xcodeProjectRequiresUpdate(BuildMode mode) {
File revisionFile = new File(path.join(Directory.current.path, 'ios', '.generated', 'REVISION')); File revisionFile = new File(path.join(Directory.current.path, 'ios', '.generated', 'REVISION'));
// If the revision stamp does not exist, the Xcode project definitely requires // If the revision stamp does not exist, the Xcode project definitely requires
...@@ -85,8 +85,9 @@ bool xcodeProjectRequiresUpdate() { ...@@ -85,8 +85,9 @@ bool xcodeProjectRequiresUpdate() {
return true; return true;
} }
if (revisionFile.readAsStringSync() != Cache.engineRevision) { if (revisionFile.readAsStringSync() != '${Cache.engineRevision}-${getModeName(mode)}') {
printTrace("The revision stamp and the Flutter engine revision differ. Project needs to be updated."); printTrace("The revision stamp and the Flutter engine revision differ or the build mode has changed.");
printTrace("Project needs to be updated.");
return true; return true;
} }
...@@ -94,12 +95,12 @@ bool xcodeProjectRequiresUpdate() { ...@@ -94,12 +95,12 @@ bool xcodeProjectRequiresUpdate() {
return false; return false;
} }
Future<int> setupXcodeProjectHarness(String flutterProjectPath) async { Future<int> setupXcodeProjectHarness(String flutterProjectPath, BuildMode mode) async {
// Step 1: Fetch the archive from the cloud // Step 1: Fetch the archive from the cloud
String iosFilesPath = path.join(flutterProjectPath, 'ios'); String iosFilesPath = path.join(flutterProjectPath, 'ios');
String xcodeprojPath = path.join(iosFilesPath, '.generated'); String xcodeprojPath = path.join(iosFilesPath, '.generated');
Directory toolDir = tools.getEngineArtifactsDirectory(TargetPlatform.ios, BuildMode.debug); Directory toolDir = tools.getEngineArtifactsDirectory(TargetPlatform.ios, mode);
File archiveFile = new File(path.join(toolDir.path, 'FlutterXcode.zip')); File archiveFile = new File(path.join(toolDir.path, 'FlutterXcode.zip'));
List<int> archiveBytes = archiveFile.readAsBytesSync(); List<int> archiveBytes = archiveFile.readAsBytesSync();
...@@ -121,7 +122,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath) async { ...@@ -121,7 +122,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath) async {
// Step 4: Write the REVISION file // Step 4: Write the REVISION file
File revisionFile = new File(path.join(xcodeprojPath, 'REVISION')); File revisionFile = new File(path.join(xcodeprojPath, 'REVISION'));
revisionFile.createSync(); revisionFile.createSync();
revisionFile.writeAsStringSync(Cache.engineRevision); revisionFile.writeAsStringSync('${Cache.engineRevision}-${getModeName(mode)}');
// Step 5: Tell the user the location of the generated project. // Step 5: Tell the user the location of the generated project.
printStatus('Xcode project created in $iosFilesPath/.'); printStatus('Xcode project created in $iosFilesPath/.');
......
...@@ -433,7 +433,8 @@ class IOSSimulator extends Device { ...@@ -433,7 +433,8 @@ class IOSSimulator extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage app, { ApplicationPackage app,
BuildMode mode, {
String mainPath, String mainPath,
String route, String route,
DebuggingOptions debuggingOptions, DebuggingOptions debuggingOptions,
...@@ -531,7 +532,8 @@ class IOSSimulator extends Device { ...@@ -531,7 +532,8 @@ class IOSSimulator extends Device {
Future<bool> _buildAndInstallApplicationBundle(ApplicationPackage app) async { Future<bool> _buildAndInstallApplicationBundle(ApplicationPackage app) async {
// Step 1: Build the Xcode project. // Step 1: Build the Xcode project.
bool buildResult = await buildIOSXcodeProject(app, buildForDevice: false); // The build mode for the simulator is always debug.
bool buildResult = await buildIOSXcodeProject(app, BuildMode.debug, buildForDevice: false);
if (!buildResult) { if (!buildResult) {
printError('Could not build the application for the simulator.'); printError('Could not build the application for the simulator.');
return false; return false;
......
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