@@ -12,64 +12,15 @@ import 'package:path/path.dart' as path;
1212
1313import 'utils.dart' ;
1414
15- String getDTDSnapshotDir () {
16- // This logic is originally from pkg/dartdev/lib/src/sdk.dart
17- //
18- // Find SDK path.
19- (String , bool )? trySDKPath (String executablePath) {
20- // The common case, and how cli_util.dart computes the Dart SDK directory,
21- // [path.dirname] called twice on Platform.executable. We confirm by
22- // asserting that the directory `./bin/snapshots/` exists in this directory:
23- var sdkPath = path.absolute (path.dirname (path.dirname (executablePath)));
24- var snapshotsDir = path.join (sdkPath, 'bin' , 'snapshots' );
25- var runFromBuildRoot = false ;
26- final type = FileSystemEntity .typeSync (snapshotsDir);
27- if (type != FileSystemEntityType .directory &&
28- type != FileSystemEntityType .link) {
29- // This is the less common case where the user is in
30- // the checked out Dart SDK, and is executing `dart` via:
31- // ./out/ReleaseX64/dart ... or in google3.
32- sdkPath = path.absolute (path.dirname (executablePath));
33- snapshotsDir = sdkPath;
34- runFromBuildRoot = true ;
35- }
36-
37- // Try to locate the DartDev snapshot to determine if we're able to find
38- // the SDK snapshots with this SDK path. This is meant to handle
39- // non-standard SDK layouts that can involve symlinks (e.g., Brew
40- // installations, google3 tests, etc).
41- if (! File (
42- path.join (snapshotsDir, 'dartdev.dart.snapshot' ),
43- ).existsSync ()) {
44- return null ;
45- }
46- return (sdkPath, runFromBuildRoot);
47- }
48-
49- final (sdkPath, runFromBuildRoot) = trySDKPath (Platform .resolvedExecutable) ??
50- trySDKPath (Platform .executable)! ;
51-
52- final String snapshotDir;
53- if (runFromBuildRoot) {
54- snapshotDir = sdkPath;
55- } else {
56- snapshotDir = path.absolute (sdkPath, 'bin' , 'snapshots' );
57- }
58-
59- return snapshotDir;
60- }
61-
6215Future <DtdInfo ?> startDtd ({
6316 required bool machineMode,
6417 required bool printDtdUri,
6518}) async {
66- final snapshotDir = getDTDSnapshotDir ();
67- final dtdAotSnapshot = path.absolute (
68- snapshotDir,
69- 'dart_tooling_daemon_aot.dart.snapshot' ,
70- );
71- final dtdSnapshot = path.absolute (
72- snapshotDir,
19+ final sdkPath = File (Platform .resolvedExecutable).parent.parent.path;
20+ final dtdSnapshot = path.absolute (
21+ sdkPath,
22+ 'bin' ,
23+ 'snapshots' ,
7324 'dart_tooling_daemon.dart.snapshot' ,
7425 );
7526
@@ -114,29 +65,15 @@ Future<DtdInfo?> startDtd({
11465 });
11566
11667 try {
117- // Try to spawn an isolate using the AOT snapshot of the tooling daemon.
11868 await Isolate .spawnUri (
119- Uri .file (dtdAotSnapshot ),
69+ Uri .file (dtdSnapshot ),
12070 ['--machine' ],
12171 receivePort.sendPort,
12272 onExit: exitPort.sendPort,
12373 onError: errorPort.sendPort,
12474 );
12575 } catch (_, __) {
126- // Spawning an isolate using the AOT snapshot of the tooling daemon failed,
127- // we are probably in a JIT VM, try again using the JIT snapshot of the
128- // tooling daemon.
129- try {
130- await Isolate .spawnUri (
131- Uri .file (dtdSnapshot),
132- ['--machine' ],
133- receivePort.sendPort,
134- onExit: exitPort.sendPort,
135- onError: errorPort.sendPort,
136- );
137- } catch (_, __) {
138- completeForError ();
139- }
76+ completeForError ();
14077 }
14178
14279 final result = await completer.future.timeout (
0 commit comments