Commit 1c0a9663 authored by Devon Carew's avatar Devon Carew

rename the --develop option to --debug (#3384)

* rename the --develop option to --debug

* fail if both --debug and --deploy are specified
parent a9eddd48
...@@ -15,15 +15,15 @@ enum BuildType { ...@@ -15,15 +15,15 @@ enum BuildType {
debug, debug,
} }
/// The type of build - `develop` or `deploy`. /// The type of build - `debug` or `deploy`.
/// ///
/// TODO(devoncarew): Add a `profile` variant. /// TODO(devoncarew): Add a `profile` mode.
enum BuildVariant { enum BuildMode {
develop, debug,
deploy deploy
} }
String getVariantName(BuildVariant variant) => getEnumName(variant); String getModeName(BuildMode mode) => getEnumName(mode);
enum HostPlatform { enum HostPlatform {
darwin_x64, darwin_x64,
......
...@@ -137,14 +137,8 @@ class ApkKeystoreInfo { ...@@ -137,14 +137,8 @@ class ApkKeystoreInfo {
class BuildApkCommand extends FlutterCommand { class BuildApkCommand extends FlutterCommand {
BuildApkCommand() { BuildApkCommand() {
argParser.addFlag('develop',
negatable: false,
help: 'Build a development version of your app (the default).');
argParser.addFlag('deploy',
negatable: false,
help: 'Build a deployable version of your app.');
usesTargetOption(); usesTargetOption();
addBuildModeFlags();
usesPubOption(); usesPubOption();
argParser.addOption('manifest', argParser.addOption('manifest',
...@@ -176,7 +170,7 @@ class BuildApkCommand extends FlutterCommand { ...@@ -176,7 +170,7 @@ class BuildApkCommand extends FlutterCommand {
@override @override
final String description = 'Build an Android APK file from your app.\n\n' final String description = 'Build an Android APK file from your app.\n\n'
'This command can build development and deployable versions of your application. \'develop\' builds\n' 'This command can build development and deployable versions of your application. \'debug\' builds\n'
'support debugging and a quick development cycle. \'deploy\' builds don\'t support debugging and are\n' 'support debugging and a quick development cycle. \'deploy\' builds don\'t support debugging and are\n'
'suitable for deploying to app stores.'; 'suitable for deploying to app stores.';
...@@ -195,16 +189,13 @@ class BuildApkCommand extends FlutterCommand { ...@@ -195,16 +189,13 @@ class BuildApkCommand extends FlutterCommand {
return 1; return 1;
} }
BuildVariant variant = BuildVariant.develop; BuildMode mode = getBuildMode();
if (argResults['deploy'])
variant = BuildVariant.deploy;
// TODO(devoncarew): This command should take an arg for the output type (arm / x64). // TODO(devoncarew): This command should take an arg for the output type (arm / x64).
return await buildAndroid( return await buildAndroid(
TargetPlatform.android_arm, TargetPlatform.android_arm,
variant, mode,
toolchain: toolchain, toolchain: toolchain,
force: true, force: true,
manifest: argResults['manifest'], manifest: argResults['manifest'],
...@@ -224,7 +215,7 @@ class BuildApkCommand extends FlutterCommand { ...@@ -224,7 +215,7 @@ class BuildApkCommand extends FlutterCommand {
Future<_ApkComponents> _findApkComponents( Future<_ApkComponents> _findApkComponents(
TargetPlatform platform, TargetPlatform platform,
BuildVariant buildVariant, BuildMode buildMode,
String manifest, String manifest,
String resources String resources
) async { ) async {
...@@ -235,7 +226,7 @@ Future<_ApkComponents> _findApkComponents( ...@@ -235,7 +226,7 @@ Future<_ApkComponents> _findApkComponents(
if (tools.isLocalEngine) { if (tools.isLocalEngine) {
String abiDir = platform == TargetPlatform.android_arm ? 'armeabi-v7a' : 'x86_64'; String abiDir = platform == TargetPlatform.android_arm ? 'armeabi-v7a' : 'x86_64';
String enginePath = tools.engineSrcPath; String enginePath = tools.engineSrcPath;
String buildDir = tools.getEngineArtifactsDirectory(platform, buildVariant).path; String buildDir = tools.getEngineArtifactsDirectory(platform, buildMode).path;
components.icuData = new File('$enginePath/third_party/icu/android/icudtl.dat'); components.icuData = new File('$enginePath/third_party/icu/android/icudtl.dat');
components.jars = <File>[ components.jars = <File>[
...@@ -244,7 +235,7 @@ Future<_ApkComponents> _findApkComponents( ...@@ -244,7 +235,7 @@ Future<_ApkComponents> _findApkComponents(
components.libSkyShell = new File('$buildDir/gen/sky/shell/shell/shell/libs/$abiDir/libsky_shell.so'); components.libSkyShell = new File('$buildDir/gen/sky/shell/shell/shell/libs/$abiDir/libsky_shell.so');
components.debugKeystore = new File('$enginePath/build/android/ant/chromium-debug.keystore'); components.debugKeystore = new File('$enginePath/build/android/ant/chromium-debug.keystore');
} else { } else {
Directory artifacts = tools.getEngineArtifactsDirectory(platform, buildVariant); Directory artifacts = tools.getEngineArtifactsDirectory(platform, buildMode);
components.icuData = new File(path.join(artifacts.path, 'icudtl.dat')); components.icuData = new File(path.join(artifacts.path, 'icudtl.dat'));
components.jars = <File>[ components.jars = <File>[
...@@ -272,18 +263,18 @@ Future<_ApkComponents> _findApkComponents( ...@@ -272,18 +263,18 @@ Future<_ApkComponents> _findApkComponents(
int _buildApk( int _buildApk(
TargetPlatform platform, TargetPlatform platform,
BuildVariant buildVariant, BuildMode buildMode,
_ApkComponents components, _ApkComponents components,
String flxPath, String flxPath,
ApkKeystoreInfo keystore, ApkKeystoreInfo keystore,
String outputFile String outputFile
) { ) {
assert(platform != null); assert(platform != null);
assert(buildVariant != null); assert(buildMode != null);
Directory tempDir = Directory.systemTemp.createTempSync('flutter_tools'); Directory tempDir = Directory.systemTemp.createTempSync('flutter_tools');
printTrace('Building APK; buildVariant: ${getVariantName(buildVariant)}.'); printTrace('Building APK; buildMode: ${getModeName(buildMode)}.');
try { try {
_ApkBuilder builder = new _ApkBuilder(androidSdk.latestVersion); _ApkBuilder builder = new _ApkBuilder(androidSdk.latestVersion);
...@@ -391,7 +382,7 @@ bool _needsRebuild(String apkPath, String manifest) { ...@@ -391,7 +382,7 @@ bool _needsRebuild(String apkPath, String manifest) {
Future<int> buildAndroid( Future<int> buildAndroid(
TargetPlatform platform, TargetPlatform platform,
BuildVariant buildVariant, { BuildMode buildMode, {
Toolchain toolchain, Toolchain toolchain,
bool force: false, bool force: false,
String manifest: _kDefaultAndroidManifestPath, String manifest: _kDefaultAndroidManifestPath,
...@@ -429,17 +420,15 @@ Future<int> buildAndroid( ...@@ -429,17 +420,15 @@ Future<int> buildAndroid(
resources = _kDefaultResourcesPath; resources = _kDefaultResourcesPath;
} }
_ApkComponents components = await _findApkComponents( _ApkComponents components = await _findApkComponents(platform, buildMode, manifest, resources);
platform, buildVariant, manifest, resources
);
if (components == null) { if (components == null) {
printError('Failure building APK: unable to find components.'); printError('Failure building APK: unable to find components.');
return 1; return 1;
} }
String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, buildVariant).path); String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, buildMode).path);
printStatus('Building APK in ${getVariantName(buildVariant)} mode ($typeName)...'); printStatus('Building APK in ${getModeName(buildMode)} mode ($typeName)...');
if (flxPath != null && flxPath.isNotEmpty) { if (flxPath != null && flxPath.isNotEmpty) {
if (!FileSystemEntity.isFileSync(flxPath)) { if (!FileSystemEntity.isFileSync(flxPath)) {
...@@ -448,16 +437,16 @@ Future<int> buildAndroid( ...@@ -448,16 +437,16 @@ Future<int> buildAndroid(
return 1; return 1;
} }
return _buildApk(platform, buildVariant, components, flxPath, keystore, outputFile); return _buildApk(platform, buildMode, components, flxPath, keystore, outputFile);
} else { } else {
// Find the path to the main Dart file; build the FLX. // Find the path to the main Dart file; build the FLX.
String mainPath = findMainDartFile(target); String mainPath = findMainDartFile(target);
String localBundlePath = await flx.buildFlx( String localBundlePath = await flx.buildFlx(
toolchain, toolchain,
mainPath: mainPath, mainPath: mainPath,
includeRobotoFonts: false); includeRobotoFonts: false);
return _buildApk(platform, buildVariant, components, localBundlePath, keystore, outputFile); return _buildApk(platform, buildMode, components, localBundlePath, keystore, outputFile);
} }
} }
...@@ -465,7 +454,7 @@ Future<int> buildApk( ...@@ -465,7 +454,7 @@ Future<int> buildApk(
TargetPlatform platform, TargetPlatform platform,
Toolchain toolchain, { Toolchain toolchain, {
String target, String target,
BuildVariant buildVariant: BuildVariant.develop BuildMode buildMode: BuildMode.debug
}) async { }) async {
if (!FileSystemEntity.isFileSync(_kDefaultAndroidManifestPath)) { if (!FileSystemEntity.isFileSync(_kDefaultAndroidManifestPath)) {
printError('Cannot build APK: missing $_kDefaultAndroidManifestPath.'); printError('Cannot build APK: missing $_kDefaultAndroidManifestPath.');
...@@ -474,7 +463,7 @@ Future<int> buildApk( ...@@ -474,7 +463,7 @@ Future<int> buildApk(
int result = await buildAndroid( int result = await buildAndroid(
platform, platform,
buildVariant, buildMode,
toolchain: toolchain, toolchain: toolchain,
force: false, force: false,
target: target target: target
......
...@@ -62,6 +62,7 @@ class RunCommand extends RunCommandBase { ...@@ -62,6 +62,7 @@ class RunCommand extends RunCommandBase {
final List<String> aliases = <String>['start']; final List<String> aliases = <String>['start'];
RunCommand() { RunCommand() {
addBuildModeFlags();
argParser.addFlag('full-restart', argParser.addFlag('full-restart',
defaultsTo: true, defaultsTo: true,
help: 'Stop any currently running application process before running the app.'); help: 'Stop any currently running application process before running the app.');
...@@ -106,7 +107,8 @@ class RunCommand extends RunCommandBase { ...@@ -106,7 +107,8 @@ class RunCommand extends RunCommandBase {
route: route, route: route,
clearLogs: clearLogs, clearLogs: clearLogs,
startPaused: argResults['start-paused'], startPaused: argResults['start-paused'],
debugPort: debugPort debugPort: debugPort,
buildMode: getBuildMode()
); );
return result; return result;
...@@ -136,7 +138,8 @@ Future<int> startApp( ...@@ -136,7 +138,8 @@ Future<int> startApp(
String route, String route,
bool clearLogs: false, bool clearLogs: false,
bool startPaused: false, bool startPaused: false,
int debugPort: observatoryDefaultPort int debugPort: observatoryDefaultPort,
BuildMode buildMode: BuildMode.debug
}) async { }) async {
String mainPath = findMainDartFile(target); String mainPath = findMainDartFile(target);
if (!FileSystemEntity.isFileSync(mainPath)) { if (!FileSystemEntity.isFileSync(mainPath)) {
...@@ -166,7 +169,7 @@ Future<int> startApp( ...@@ -166,7 +169,7 @@ Future<int> startApp(
device.platform, device.platform,
toolchain, toolchain,
target: target, target: target,
buildVariant: BuildVariant.develop buildMode: buildMode
); );
if (result != 0) if (result != 0)
......
...@@ -99,7 +99,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath) async { ...@@ -99,7 +99,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath) async {
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, BuildVariant.develop); Directory toolDir = tools.getEngineArtifactsDirectory(TargetPlatform.ios, BuildMode.debug);
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();
......
...@@ -60,6 +60,25 @@ abstract class FlutterCommand extends Command { ...@@ -60,6 +60,25 @@ abstract class FlutterCommand extends Command {
_usesPubOption = true; _usesPubOption = true;
} }
void addBuildModeFlags() {
argParser.addFlag('debug',
negatable: false,
help: 'Build a debug version of your app (the default).');
argParser.addFlag('deploy',
negatable: false,
help: 'Build a deployable version of your app.');
}
BuildMode getBuildMode() {
if (argResults['debug'] && argResults['deploy'])
throw new UsageException('Only one of --debug or --deploy should be specified.', null);
BuildMode mode = BuildMode.debug;
if (argResults['deploy'])
mode = BuildMode.deploy;
return mode;
}
void _setupToolchain() { void _setupToolchain() {
toolchain ??= Toolchain.forConfigs(buildConfigurations); toolchain ??= Toolchain.forConfigs(buildConfigurations);
} }
......
...@@ -126,14 +126,14 @@ class ToolConfiguration { ...@@ -126,14 +126,14 @@ class ToolConfiguration {
/// Return the directory that contains engine artifacts for the given targets. /// Return the directory that contains engine artifacts for the given targets.
/// This directory might contain artifacts like `libsky_shell.so`. /// This directory might contain artifacts like `libsky_shell.so`.
Directory getEngineArtifactsDirectory(TargetPlatform platform, BuildVariant variant) { Directory getEngineArtifactsDirectory(TargetPlatform platform, BuildMode mode) {
Directory dir = _getEngineArtifactsDirectory(platform, variant); Directory dir = _getEngineArtifactsDirectory(platform, mode);
if (dir != null) if (dir != null)
printTrace('Using engine artifacts dir: ${dir.path}'); printTrace('Using engine artifacts dir: ${dir.path}');
return dir; return dir;
} }
Directory _getEngineArtifactsDirectory(TargetPlatform platform, BuildVariant variant) { Directory _getEngineArtifactsDirectory(TargetPlatform platform, BuildMode mode) {
if (engineOutDir != null) { if (engineOutDir != null) {
return new Directory(engineOutDir); return new Directory(engineOutDir);
} else if (engineSrcPath != null) { } else if (engineSrcPath != null) {
...@@ -162,7 +162,7 @@ class ToolConfiguration { ...@@ -162,7 +162,7 @@ class ToolConfiguration {
return new Directory(path.join(engineSrcPath, 'out/${type}_$_modeStr')); return new Directory(path.join(engineSrcPath, 'out/${type}_$_modeStr'));
} else { } else {
// For now, only suffix for deploy variants. // For now, only suffix for deploy variants.
String suffix = variant == BuildVariant.deploy ? '-${getVariantName(variant)}' : ''; String suffix = mode == BuildMode.deploy ? '-${getModeName(mode)}' : '';
// Create something like `android-arm` or `android-arm-deploy`. // Create something like `android-arm` or `android-arm-deploy`.
String dirName = getNameForTargetPlatform(platform) + suffix; String dirName = getNameForTargetPlatform(platform) + suffix;
......
...@@ -33,11 +33,11 @@ void main() { ...@@ -33,11 +33,11 @@ void main() {
endsWith('cache/artifacts/engine/linux-x64') endsWith('cache/artifacts/engine/linux-x64')
); );
expect( expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildVariant.develop).path, toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
endsWith('cache/artifacts/engine/android-arm') endsWith('cache/artifacts/engine/android-arm')
); );
expect( expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildVariant.deploy).path, toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.deploy).path,
endsWith('cache/artifacts/engine/android-arm-deploy') endsWith('cache/artifacts/engine/android-arm-deploy')
); );
}); });
...@@ -52,7 +52,7 @@ void main() { ...@@ -52,7 +52,7 @@ void main() {
'engine/out/Release' 'engine/out/Release'
); );
expect( expect(
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildVariant.develop).path, toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
'engine/out/android_Release' 'engine/out/android_Release'
); );
......
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