mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Flutter run target 2 (#5035)
* This reverts commit 5e7e7b6ea7
.
* default to lib/main.dart
This commit is contained in:
parent
07ba37976c
commit
d3cc554828
@ -56,7 +56,7 @@ class BuildAotCommand extends BuildSubCommand {
|
|||||||
String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, getBuildMode()).path);
|
String typeName = path.basename(tools.getEngineArtifactsDirectory(platform, getBuildMode()).path);
|
||||||
Status status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...');
|
Status status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...');
|
||||||
String outputPath = await buildAotSnapshot(
|
String outputPath = await buildAotSnapshot(
|
||||||
findMainDartFile(argResults['target']),
|
findMainDartFile(targetFile),
|
||||||
platform,
|
platform,
|
||||||
getBuildMode(),
|
getBuildMode(),
|
||||||
outputPath: argResults['output-dir'],
|
outputPath: argResults['output-dir'],
|
||||||
|
@ -208,7 +208,7 @@ class BuildApkCommand extends BuildSubCommand {
|
|||||||
return await buildAndroidWithGradle(
|
return await buildAndroidWithGradle(
|
||||||
TargetPlatform.android_arm,
|
TargetPlatform.android_arm,
|
||||||
getBuildMode(),
|
getBuildMode(),
|
||||||
target: argResults['target']
|
target: targetFile
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// 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).
|
||||||
@ -219,7 +219,7 @@ class BuildApkCommand extends BuildSubCommand {
|
|||||||
manifest: argResults['manifest'],
|
manifest: argResults['manifest'],
|
||||||
resources: argResults['resources'],
|
resources: argResults['resources'],
|
||||||
outputFile: argResults['output-file'],
|
outputFile: argResults['output-file'],
|
||||||
target: argResults['target'],
|
target: targetFile,
|
||||||
flxPath: argResults['flx'],
|
flxPath: argResults['flx'],
|
||||||
aotPath: argResults['aot-path'],
|
aotPath: argResults['aot-path'],
|
||||||
keystore: (argResults['keystore'] ?? '').isEmpty ? null : new ApkKeystoreInfo(
|
keystore: (argResults['keystore'] ?? '').isEmpty ? null : new ApkKeystoreInfo(
|
||||||
|
@ -41,7 +41,7 @@ class BuildFlxCommand extends BuildSubCommand {
|
|||||||
String outputPath = argResults['output-file'];
|
String outputPath = argResults['output-file'];
|
||||||
|
|
||||||
return await build(
|
return await build(
|
||||||
mainPath: argResults['target'],
|
mainPath: targetFile,
|
||||||
manifestPath: argResults['manifest'],
|
manifestPath: argResults['manifest'],
|
||||||
outputPath: outputPath,
|
outputPath: outputPath,
|
||||||
snapshotPath: argResults['snapshot'],
|
snapshotPath: argResults['snapshot'],
|
||||||
|
@ -58,7 +58,7 @@ class BuildIOSCommand extends BuildSubCommand {
|
|||||||
XcodeBuildResult result = await buildXcodeProject(
|
XcodeBuildResult result = await buildXcodeProject(
|
||||||
app: app,
|
app: app,
|
||||||
mode: getBuildMode(),
|
mode: getBuildMode(),
|
||||||
target: argResults['target'],
|
target: targetFile,
|
||||||
buildForDevice: !forSimulator,
|
buildForDevice: !forSimulator,
|
||||||
codesign: shouldCodesign
|
codesign: shouldCodesign
|
||||||
);
|
);
|
||||||
|
@ -160,7 +160,7 @@ class DriveCommand extends RunCommandBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _getTestFile() {
|
String _getTestFile() {
|
||||||
String appFile = path.normalize(target);
|
String appFile = path.normalize(targetFile);
|
||||||
|
|
||||||
// This command extends `flutter start` and therefore CWD == package dir
|
// This command extends `flutter start` and therefore CWD == package dir
|
||||||
String packageDir = getCurrentDirectory();
|
String packageDir = getCurrentDirectory();
|
||||||
@ -266,7 +266,7 @@ void restoreAppStarter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> startApp(DriveCommand command) async {
|
Future<int> startApp(DriveCommand command) async {
|
||||||
String mainPath = findMainDartFile(command.target);
|
String mainPath = findMainDartFile(command.targetFile);
|
||||||
if (await fs.type(mainPath) != FileSystemEntityType.FILE) {
|
if (await fs.type(mainPath) != FileSystemEntityType.FILE) {
|
||||||
printError('Tried to run $mainPath, but that file does not exist.');
|
printError('Tried to run $mainPath, but that file does not exist.');
|
||||||
return 1;
|
return 1;
|
||||||
@ -277,7 +277,7 @@ Future<int> startApp(DriveCommand command) async {
|
|||||||
printTrace('Building an APK.');
|
printTrace('Building an APK.');
|
||||||
int result = await build_apk.buildApk(
|
int result = await build_apk.buildApk(
|
||||||
command.device.platform,
|
command.device.platform,
|
||||||
target: command.target,
|
target: command.targetFile,
|
||||||
buildMode: command.getBuildMode()
|
buildMode: command.getBuildMode()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class ListenCommand extends RunCommandBase {
|
|||||||
|
|
||||||
result = await startApp(
|
result = await startApp(
|
||||||
deviceForCommand,
|
deviceForCommand,
|
||||||
target: target,
|
target: targetFile,
|
||||||
install: firstTime,
|
install: firstTime,
|
||||||
stop: true,
|
stop: true,
|
||||||
debuggingOptions: new DebuggingOptions.enabled(getBuildMode()),
|
debuggingOptions: new DebuggingOptions.enabled(getBuildMode()),
|
||||||
|
@ -40,7 +40,7 @@ class RefreshCommand extends FlutterCommand {
|
|||||||
Directory tempDir = await Directory.systemTemp.createTemp('flutter_tools');
|
Directory tempDir = await Directory.systemTemp.createTemp('flutter_tools');
|
||||||
try {
|
try {
|
||||||
String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin');
|
String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin');
|
||||||
int result = await createSnapshot(mainPath: argResults['target'], snapshotPath: snapshotPath);
|
int result = await createSnapshot(mainPath: targetFile, snapshotPath: snapshotPath);
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
printError('Failed to run the Flutter compiler. Exit code: $result');
|
printError('Failed to run the Flutter compiler. Exit code: $result');
|
||||||
|
@ -33,7 +33,6 @@ abstract class RunCommandBase extends FlutterCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool get traceStartup => argResults['trace-startup'];
|
bool get traceStartup => argResults['trace-startup'];
|
||||||
String get target => argResults['target'];
|
|
||||||
String get route => argResults['route'];
|
String get route => argResults['route'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +134,7 @@ class RunCommand extends RunCommandBase {
|
|||||||
if (argResults['resident']) {
|
if (argResults['resident']) {
|
||||||
RunAndStayResident runner = new RunAndStayResident(
|
RunAndStayResident runner = new RunAndStayResident(
|
||||||
deviceForCommand,
|
deviceForCommand,
|
||||||
target: target,
|
target: targetFile,
|
||||||
debuggingOptions: options,
|
debuggingOptions: options,
|
||||||
hotMode: argResults['hot']
|
hotMode: argResults['hot']
|
||||||
);
|
);
|
||||||
@ -150,7 +149,7 @@ class RunCommand extends RunCommandBase {
|
|||||||
// using the `RunAndStayResident` class.
|
// using the `RunAndStayResident` class.
|
||||||
return startApp(
|
return startApp(
|
||||||
deviceForCommand,
|
deviceForCommand,
|
||||||
target: target,
|
target: targetFile,
|
||||||
stop: argResults['full-restart'],
|
stop: argResults['full-restart'],
|
||||||
install: true,
|
install: true,
|
||||||
debuggingOptions: options,
|
debuggingOptions: options,
|
||||||
|
@ -53,6 +53,15 @@ abstract class FlutterCommand extends Command {
|
|||||||
_usesTargetOption = true;
|
_usesTargetOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get targetFile {
|
||||||
|
if (argResults.wasParsed('target'))
|
||||||
|
return argResults['target'];
|
||||||
|
else if (argResults.rest.isNotEmpty)
|
||||||
|
return argResults.rest.first;
|
||||||
|
else
|
||||||
|
return flx.defaultMainPath;
|
||||||
|
}
|
||||||
|
|
||||||
void usesPubOption() {
|
void usesPubOption() {
|
||||||
argParser.addFlag('pub',
|
argParser.addFlag('pub',
|
||||||
defaultsTo: true,
|
defaultsTo: true,
|
||||||
@ -184,7 +193,7 @@ abstract class FlutterCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_usesTargetOption) {
|
if (_usesTargetOption) {
|
||||||
String targetPath = argResults['target'];
|
String targetPath = targetFile;
|
||||||
if (!FileSystemEntity.isFileSync(targetPath)) {
|
if (!FileSystemEntity.isFileSync(targetPath)) {
|
||||||
printError('Target file "$targetPath" not found.');
|
printError('Target file "$targetPath" not found.');
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user