Skip to content

Commit d612b0f

Browse files
srawlinsCommit Queue
authored andcommitted
DAS: support legacy plugins when compiled to AOT
Change-Id: I61bcd4b5ac8d0d6bee8f3c99636d9cebb164899b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424641 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 77124ef commit d612b0f

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

pkg/analysis_server/lib/src/plugin/plugin_manager.dart

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,31 @@ class PluginManager {
711711
return result;
712712
}
713713

714+
/// Compiles [pluginFile], in [pluginFolder], to an AOT snapshot, and returns
715+
/// the [File] for the snapshot.
716+
File _compileAsAot({required File pluginFile, required Folder pluginFolder}) {
717+
// When the Dart Analysis Server is built as AOT, then all spawned
718+
// Isolates must also be built as AOT.
719+
var aotResult = _compileAotSnapshot(pluginFile.path);
720+
if (aotResult.exitCode != 0) {
721+
var buffer = StringBuffer();
722+
buffer.writeln(
723+
'Failed to compile "${pluginFile.path}" to an AOT snapshot.',
724+
);
725+
buffer.writeln(' pluginFolder = ${pluginFolder.path}');
726+
buffer.writeln(' exitCode = ${aotResult.exitCode}');
727+
buffer.writeln(' stdout = ${aotResult.stdout}');
728+
buffer.writeln(' stderr = ${aotResult.stderr}');
729+
var exceptionReason = buffer.toString();
730+
instrumentationService.logError(exceptionReason);
731+
throw PluginException(exceptionReason);
732+
}
733+
734+
return pluginFolder
735+
.getChildAssumingFolder('bin')
736+
.getChildAssumingFile('plugin.aot');
737+
}
738+
714739
/// Computes the plugin files, given that the plugin should exist in
715740
/// [pluginFolder].
716741
///
@@ -752,27 +777,11 @@ class PluginManager {
752777
}
753778

754779
if (_builtAsAot) {
755-
// When the Dart Analysis Server is built as AOT, then all spawned
756-
// Isolates must also be built as AOT.
757-
var aotResult = _compileAotSnapshot(pluginFile.path);
758-
if (aotResult.exitCode != 0) {
759-
var buffer = StringBuffer();
760-
buffer.writeln(
761-
'Failed to compile "${pluginFile.path}" to an AOT snapshot.',
762-
);
763-
buffer.writeln(' pluginFolder = ${pluginFolder.path}');
764-
buffer.writeln(' exitCode = ${aotResult.exitCode}');
765-
buffer.writeln(' stdout = ${aotResult.stdout}');
766-
buffer.writeln(' stderr = ${aotResult.stderr}');
767-
var exceptionReason = buffer.toString();
768-
instrumentationService.logError(exceptionReason);
769-
throw PluginException(exceptionReason);
770-
}
771-
772780
// Update the entrypoint path to be the AOT-compiled file.
773-
pluginFile = pluginFolder
774-
.getChildAssumingFolder('bin')
775-
.getChildAssumingFile('plugin.aot');
781+
pluginFile = _compileAsAot(
782+
pluginFile: pluginFile,
783+
pluginFolder: pluginFolder,
784+
);
776785
}
777786

778787
return PluginFiles(pluginFile, packageConfigFile);
@@ -794,6 +803,14 @@ class PluginManager {
794803
);
795804
}
796805
}
806+
807+
if (_builtAsAot) {
808+
// Update the entrypoint path to be the AOT-compiled file.
809+
pluginFile = _compileAsAot(
810+
pluginFile: pluginFile,
811+
pluginFolder: pluginFolder,
812+
);
813+
}
797814
return PluginFiles(pluginFile, packageConfigFile);
798815
}
799816

0 commit comments

Comments
 (0)