Skip to content

Commit 366cb3e

Browse files
Plumb the serve-with-dart-sdk command through to the dt run command (#9198)
1 parent 9200cca commit 366cb3e

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

tool/lib/commands/run.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import '../utils.dart';
1515
/// flag to this command.
1616
class RunCommand extends Command {
1717
RunCommand() {
18-
argParser.addDebugServerFlag();
18+
argParser
19+
..addDebugServerFlag()
20+
..addServeWithSdkOption();
1921
}
2022

2123
@override

tool/lib/commands/serve.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const _buildAppFlag = 'build-app';
2020
const _machineFlag = 'machine';
2121
const _dtdUriFlag = 'dtd-uri';
2222
const _allowEmbeddingFlag = 'allow-embedding';
23-
const _serveWithDartSdkFlag = 'serve-with-dart-sdk';
2423

2524
/// This command builds DevTools in release mode by running the
2625
/// `dt build` command and then serves DevTools with a locally
@@ -86,6 +85,7 @@ class ServeCommand extends Command {
8685
' directly from the DevTools server.',
8786
)
8887
..addDebugServerFlag()
88+
..addServeWithSdkOption()
8989
..addUpdateFlutterFlag()
9090
..addUpdatePerfettoFlag()
9191
..addPubGetFlag()
@@ -105,12 +105,6 @@ class ServeCommand extends Command {
105105
..addFlag(
106106
_allowEmbeddingFlag,
107107
help: 'Allow embedding DevTools inside an iframe.',
108-
)
109-
..addOption(
110-
_serveWithDartSdkFlag,
111-
help: 'Uses the specified Dart SDK to serve the DevTools server',
112-
valueHelp:
113-
'/Users/me/absolute_path_to/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart',
114108
);
115109
}
116110

@@ -156,7 +150,8 @@ class ServeCommand extends Command {
156150
final runPubGet = results[SharedCommandArgs.pubGet.flagName] as bool;
157151
final devToolsAppBuildMode =
158152
results[SharedCommandArgs.buildMode.flagName] as String;
159-
final serveWithDartSdk = results[_serveWithDartSdkFlag] as String?;
153+
final serveWithDartSdk =
154+
results[SharedCommandArgs.serveWithDartSdk.flagName] as String?;
160155
final forMachine = results[_machineFlag] as bool;
161156

162157
// TODO(https://github.com/flutter/devtools/issues/8643): Support running in
@@ -188,7 +183,9 @@ class ServeCommand extends Command {
188183
element.startsWith(SharedCommandArgs.buildMode.asArg()),
189184
)
190185
..removeWhere(
191-
(element) => element.startsWith(valueAsArg(_serveWithDartSdkFlag)),
186+
(element) => element.startsWith(
187+
valueAsArg(SharedCommandArgs.serveWithDartSdk.flagName),
188+
),
192189
);
193190

194191
final localDartSdkLocation = Platform.environment['LOCAL_DART_SDK'];

tool/lib/commands/shared.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ extension BuildCommandArgsExtension on ArgParser {
8080
help: 'Enable debugging for the DevTools server.',
8181
);
8282
}
83+
84+
void addServeWithSdkOption() {
85+
addOption(
86+
SharedCommandArgs.serveWithDartSdk.flagName,
87+
help: 'Uses the specified Dart SDK to serve the DevTools server',
88+
valueHelp:
89+
'/Users/me/absolute_path_to/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart',
90+
);
91+
}
8392
}
8493

8594
enum SharedCommandArgs {
@@ -89,6 +98,7 @@ enum SharedCommandArgs {
8998
wasm('wasm'),
9099
noStripWasm('no-strip-wasm'),
91100
runApp('run-app'),
101+
serveWithDartSdk('serve-with-dart-sdk'),
92102
updateFlutter('update-flutter'),
93103
updatePerfetto('update-perfetto');
94104

0 commit comments

Comments
 (0)