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