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);
|
||||
Status status = logger.startProgress('Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...');
|
||||
String outputPath = await buildAotSnapshot(
|
||||
findMainDartFile(argResults['target']),
|
||||
findMainDartFile(targetFile),
|
||||
platform,
|
||||
getBuildMode(),
|
||||
outputPath: argResults['output-dir'],
|
||||
|
@ -208,7 +208,7 @@ class BuildApkCommand extends BuildSubCommand {
|
||||
return await buildAndroidWithGradle(
|
||||
TargetPlatform.android_arm,
|
||||
getBuildMode(),
|
||||
target: argResults['target']
|
||||
target: targetFile
|
||||
);
|
||||
} else {
|
||||
// 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'],
|
||||
resources: argResults['resources'],
|
||||
outputFile: argResults['output-file'],
|
||||
target: argResults['target'],
|
||||
target: targetFile,
|
||||
flxPath: argResults['flx'],
|
||||
aotPath: argResults['aot-path'],
|
||||
keystore: (argResults['keystore'] ?? '').isEmpty ? null : new ApkKeystoreInfo(
|
||||
|
@ -41,7 +41,7 @@ class BuildFlxCommand extends BuildSubCommand {
|
||||
String outputPath = argResults['output-file'];
|
||||
|
||||
return await build(
|
||||
mainPath: argResults['target'],
|
||||
mainPath: targetFile,
|
||||
manifestPath: argResults['manifest'],
|
||||
outputPath: outputPath,
|
||||
snapshotPath: argResults['snapshot'],
|
||||
|
@ -58,7 +58,7 @@ class BuildIOSCommand extends BuildSubCommand {
|
||||
XcodeBuildResult result = await buildXcodeProject(
|
||||
app: app,
|
||||
mode: getBuildMode(),
|
||||
target: argResults['target'],
|
||||
target: targetFile,
|
||||
buildForDevice: !forSimulator,
|
||||
codesign: shouldCodesign
|
||||
);
|
||||
|
@ -160,7 +160,7 @@ class DriveCommand extends RunCommandBase {
|
||||
}
|
||||
|
||||
String _getTestFile() {
|
||||
String appFile = path.normalize(target);
|
||||
String appFile = path.normalize(targetFile);
|
||||
|
||||
// This command extends `flutter start` and therefore CWD == package dir
|
||||
String packageDir = getCurrentDirectory();
|
||||
@ -266,7 +266,7 @@ void restoreAppStarter() {
|
||||
}
|
||||
|
||||
Future<int> startApp(DriveCommand command) async {
|
||||
String mainPath = findMainDartFile(command.target);
|
||||
String mainPath = findMainDartFile(command.targetFile);
|
||||
if (await fs.type(mainPath) != FileSystemEntityType.FILE) {
|
||||
printError('Tried to run $mainPath, but that file does not exist.');
|
||||
return 1;
|
||||
@ -277,7 +277,7 @@ Future<int> startApp(DriveCommand command) async {
|
||||
printTrace('Building an APK.');
|
||||
int result = await build_apk.buildApk(
|
||||
command.device.platform,
|
||||
target: command.target,
|
||||
target: command.targetFile,
|
||||
buildMode: command.getBuildMode()
|
||||
);
|
||||
|
||||
|
@ -62,7 +62,7 @@ class ListenCommand extends RunCommandBase {
|
||||
|
||||
result = await startApp(
|
||||
deviceForCommand,
|
||||
target: target,
|
||||
target: targetFile,
|
||||
install: firstTime,
|
||||
stop: true,
|
||||
debuggingOptions: new DebuggingOptions.enabled(getBuildMode()),
|
||||
|
@ -40,7 +40,7 @@ class RefreshCommand extends FlutterCommand {
|
||||
Directory tempDir = await Directory.systemTemp.createTemp('flutter_tools');
|
||||
try {
|
||||
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) {
|
||||
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'];
|
||||
String get target => argResults['target'];
|
||||
String get route => argResults['route'];
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ class RunCommand extends RunCommandBase {
|
||||
if (argResults['resident']) {
|
||||
RunAndStayResident runner = new RunAndStayResident(
|
||||
deviceForCommand,
|
||||
target: target,
|
||||
target: targetFile,
|
||||
debuggingOptions: options,
|
||||
hotMode: argResults['hot']
|
||||
);
|
||||
@ -150,7 +149,7 @@ class RunCommand extends RunCommandBase {
|
||||
// using the `RunAndStayResident` class.
|
||||
return startApp(
|
||||
deviceForCommand,
|
||||
target: target,
|
||||
target: targetFile,
|
||||
stop: argResults['full-restart'],
|
||||
install: true,
|
||||
debuggingOptions: options,
|
||||
|
@ -53,6 +53,15 @@ abstract class FlutterCommand extends Command {
|
||||
_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() {
|
||||
argParser.addFlag('pub',
|
||||
defaultsTo: true,
|
||||
@ -184,7 +193,7 @@ abstract class FlutterCommand extends Command {
|
||||
}
|
||||
|
||||
if (_usesTargetOption) {
|
||||
String targetPath = argResults['target'];
|
||||
String targetPath = targetFile;
|
||||
if (!FileSystemEntity.isFileSync(targetPath)) {
|
||||
printError('Target file "$targetPath" not found.');
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user