You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clean up the code and some of the API of compiling plugins, and improve persistence of cached compiler outputs (#4290)
Clients now get the command line and compiler output even in the case of failure, and also when the plugin doesn't have to be recompiled because nothing changed (previously this information was lost). This is done by serializing a proper struct to JSON rather than just storing the hexadecimal representation of the configuration hash.
Callers also have control over the name of the temporary directory to represent the plugin, rather than always having it be the last path component of the sources directory.
/// Implements the mechanics of running and communicating with a plugin (implemented as a set of Swift source files). In most environments this is done by compiling the code to an executable, invoking it as a sandboxed subprocess, and communicating with it using pipes. Specific implementations are free to implement things differently, however.
22
22
publicprotocolPluginScriptRunner{
23
23
24
-
/// Public protocol function that starts compiling the plugin script to an exectutable. The tools version controls the availability of APIs in PackagePlugin, and should be set to the tools version of the package that defines the plugin (not of the target to which it is being applied). This function returns immediately and then calls the completion handler on the callbackq queue when compilation ends.
24
+
/// Public protocol function that starts compiling the plugin script to an exectutable. The name is used as the basename for the executable and auxiliary files. The tools version controls the availability of APIs in PackagePlugin, and should be set to the tools version of the package that defines the plugin (not of the target to which it is being applied). This function returns immediately and then calls the completion handler on the callbackq queue when compilation ends.
/// Implements the mechanics of running a plugin script implemented as a set of Swift source files, for use
32
35
/// by the package graph when it is evaluating package plugins.
@@ -39,7 +42,8 @@ public protocol PluginScriptRunner {
39
42
///
40
43
/// Every concrete implementation should cache any intermediates as necessary to avoid redundant work.
41
44
func runPluginScript(
42
-
sources:Sources,
45
+
sourceFiles:[AbsolutePath],
46
+
pluginName:String,
43
47
initialMessage:Data,
44
48
toolsVersion:ToolsVersion,
45
49
workingDirectory:AbsolutePath,
@@ -69,36 +73,44 @@ public protocol PluginScriptRunnerDelegate {
69
73
70
74
/// The result of compiling a plugin. The executable path will only be present if the compilation succeeds, while the other properties are present in all cases.
71
75
publicstructPluginCompilationResult{
72
-
/// Process result of invoking the Swift compiler to produce the executable (contains command line, environment, exit status, and any output).
73
-
publicvarcompilerResult:ProcessResult?
76
+
/// Whether compilation succeeded.
77
+
publicvarsucceeded:Bool
74
78
75
-
/// Path of the libClang diagnostics file emitted by the compiler (even if compilation succeded, it might contain warnings).
0 commit comments