Skip to content

Commit 915186a

Browse files
committed
Refactor Basic/Parseable-Output to remove dependency on Driver & Frontend
Introducing new entry-points that can be used from both Driver and Frontend clients, using an intermediary new type: `DetailedMessagePayload`, when needed.
1 parent 222b153 commit 915186a

File tree

7 files changed

+285
-358
lines changed

7 files changed

+285
-358
lines changed

include/swift/Basic/ParseableOutput.h

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
#include "swift/Basic/LLVM.h"
2222
#include "swift/Basic/TaskQueue.h"
23-
#include "swift/Driver/Job.h"
24-
#include "swift/Frontend/Frontend.h"
23+
#include "swift/Basic/FileTypes.h"
2524

2625
namespace swift {
2726

@@ -36,35 +35,42 @@ namespace parseable_output {
3635
/// into the stream of real PIDs (say, due to a TaskQueue bug).
3736
const int QUASI_PID_START = -1000;
3837

39-
/// Emits a "began" message to the given stream, corresponding to a Driver Job.
40-
void emitBeganMessage(raw_ostream &os, const driver::Job &Cmd, int64_t Pid,
41-
sys::TaskProcessInformation ProcInfo);
38+
struct CommandInput {
39+
std::string Path;
40+
CommandInput() {}
41+
CommandInput(StringRef Path) : Path(Path) {}
42+
};
4243

43-
/// Emits a "began" message to the given stream, corresponding to a given
44-
/// Frontend Compiler Invocation.
45-
void emitBeganMessage(raw_ostream &os, const CompilerInvocation &Invocation,
46-
ArrayRef<const char *> Args, int64_t OSPid);
44+
using OutputPair = std::pair<file_types::ID, std::string>;
4745

48-
/// Emits a "finished" message to the given stream.
49-
void emitFinishedMessage(raw_ostream &os, const driver::Job &Cmd, int64_t Pid,
50-
int ExitStatus, StringRef Output,
51-
sys::TaskProcessInformation ProcInfo);
46+
/// A client-agnostic (e.g. either the compiler driver or `swift-frontend`)
47+
/// description of a task that is the subject of a parseable-output message.
48+
struct DetailedTaskDescription {
49+
std::string Executable;
50+
SmallVector<std::string, 16> Arguments;
51+
std::string CommandLine;
52+
SmallVector<CommandInput, 4> Inputs;
53+
SmallVector<OutputPair, 8> Outputs;
54+
};
55+
56+
/// Emits a "began" message to the given stream.
57+
void emitBeganMessage(raw_ostream &os, StringRef Name,
58+
DetailedTaskDescription TascDesc,
59+
int64_t Pid, sys::TaskProcessInformation ProcInfo);
5260

53-
/// Emits a "finished" message to the given stream corresponding to a given
54-
/// Frontend Compiler Invocation.
55-
void emitFinishedMessage(
56-
raw_ostream &os, const CompilerInvocation &Invocation, int ExitStatus,
57-
const llvm::StringMap<std::vector<std::string>> &FileSpecificDiagnostics,
58-
int64_t OSPid);
61+
/// Emits a "finished" message to the given stream.
62+
void emitFinishedMessage(raw_ostream &os, StringRef Name,
63+
std::string Output, int ExitStatus,
64+
int64_t Pid, sys::TaskProcessInformation ProcInfo);
5965

6066
/// Emits a "signalled" message to the given stream.
61-
void emitSignalledMessage(raw_ostream &os, const driver::Job &Cmd, int64_t Pid,
62-
StringRef ErrorMsg, StringRef Output,
63-
Optional<int> Signal,
64-
sys::TaskProcessInformation ProcInfo);
67+
void emitSignalledMessage(raw_ostream &os, StringRef Name, StringRef ErrorMsg,
68+
StringRef Output, Optional<int> Signal,
69+
int64_t Pid, sys::TaskProcessInformation ProcInfo);
6570

6671
/// Emits a "skipped" message to the given stream.
67-
void emitSkippedMessage(raw_ostream &os, const driver::Job &Cmd);
72+
void emitSkippedMessage(raw_ostream &os, StringRef Name,
73+
DetailedTaskDescription TascDesc);
6874

6975
} // end namespace parseable_output
7076
} // end namespace swift

0 commit comments

Comments
 (0)