Skip to content

Commit f09ab5c

Browse files
committed
Add support for emitting parseable-outpuit "began" message from swift-frontend
1 parent b827875 commit f09ab5c

File tree

4 files changed

+298
-93
lines changed

4 files changed

+298
-93
lines changed

include/swift/Basic/ParseableOutput.h

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//===--- ParseableOutput.h - Helpers for parseable output -------*- C++ -*-===//
1+
//===----- ParseableOutput.h - Helpers for parseable output ------- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -11,43 +11,50 @@
1111
//===----------------------------------------------------------------------===//
1212
///
1313
/// \file
14-
/// Helpers for emitting the driver's parseable output.
14+
/// Helpers for emitting the compiler's parseable output.
1515
///
1616
//===----------------------------------------------------------------------===//
1717

18-
#ifndef SWIFT_DRIVER_PARSEABLEOUTPUT_H
19-
#define SWIFT_DRIVER_PARSEABLEOUTPUT_H
18+
#ifndef SWIFT_PARSEABLEOUTPUT_H
19+
#define SWIFT_PARSEABLEOUTPUT_H
2020

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

2426
namespace swift {
25-
namespace driver {
2627

27-
class Job;
2828

2929
namespace parseable_output {
3030

31-
/// Emits a "began" message to the given stream.
32-
void emitBeganMessage(raw_ostream &os, const Job &Cmd, int64_t Pid,
31+
/// Emits a "began" message to the given stream, corresponding to a Driver Job.
32+
void emitBeganMessage(raw_ostream &os, const driver::Job &Cmd, int64_t Pid,
33+
sys::TaskProcessInformation ProcInfo);
34+
35+
/// Emits a "began" message to the given stream, corresponding to a given Frontend
36+
/// Compiler Invocation.
37+
void emitBeganMessage(raw_ostream &os,
38+
const CompilerInvocation &Invocation,
39+
ArrayRef<const char *> Args,
40+
int64_t Pid,
3341
sys::TaskProcessInformation ProcInfo);
3442

3543
/// Emits a "finished" message to the given stream.
36-
void emitFinishedMessage(raw_ostream &os, const Job &Cmd, int64_t Pid,
44+
void emitFinishedMessage(raw_ostream &os, const driver::Job &Cmd, int64_t Pid,
3745
int ExitStatus, StringRef Output,
3846
sys::TaskProcessInformation ProcInfo);
3947

4048
/// Emits a "signalled" message to the given stream.
41-
void emitSignalledMessage(raw_ostream &os, const Job &Cmd, int64_t Pid,
49+
void emitSignalledMessage(raw_ostream &os, const driver::Job &Cmd, int64_t Pid,
4250
StringRef ErrorMsg, StringRef Output,
4351
Optional<int> Signal,
4452
sys::TaskProcessInformation ProcInfo);
4553

4654
/// Emits a "skipped" message to the given stream.
47-
void emitSkippedMessage(raw_ostream &os, const Job &Cmd);
55+
void emitSkippedMessage(raw_ostream &os, const driver::Job &Cmd);
4856

4957
} // end namespace parseable_output
50-
} // end namespace driver
5158
} // end namespace swift
5259

5360
#endif

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_FRONTEND_SUPPLEMENTARYOUTPUTPATHS_H
1515

1616
#include "swift/Basic/LLVM.h"
17+
#include "llvm/IR/Function.h"
1718

1819
#include <string>
1920

@@ -171,6 +172,42 @@ struct SupplementaryOutputPaths {
171172
SupplementaryOutputPaths() = default;
172173
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;
173174

175+
/// Apply a given function for each existing (non-empty string) supplementary output
176+
void forEachSetOutput(llvm::function_ref<void(const std::string&)> fn) const {
177+
if (!ObjCHeaderOutputPath.empty())
178+
fn(ObjCHeaderOutputPath);
179+
if (!ModuleOutputPath.empty())
180+
fn(ModuleOutputPath);
181+
if (!ModuleSourceInfoOutputPath.empty())
182+
fn(ModuleSourceInfoOutputPath);
183+
if (!ModuleDocOutputPath.empty())
184+
fn(ModuleDocOutputPath);
185+
if (!DependenciesFilePath.empty())
186+
fn(DependenciesFilePath);
187+
if (!ReferenceDependenciesFilePath.empty())
188+
fn(ReferenceDependenciesFilePath);
189+
if (!SwiftRangesFilePath.empty())
190+
fn(SwiftRangesFilePath);
191+
if (!CompiledSourceFilePath.empty())
192+
fn(CompiledSourceFilePath);
193+
if (!SerializedDiagnosticsPath.empty())
194+
fn(SerializedDiagnosticsPath);
195+
if (!FixItsOutputPath.empty())
196+
fn(FixItsOutputPath);
197+
if (!LoadedModuleTracePath.empty())
198+
fn(LoadedModuleTracePath);
199+
if (!TBDPath.empty())
200+
fn(TBDPath);
201+
if (!ModuleInterfaceOutputPath.empty())
202+
fn(ModuleInterfaceOutputPath);
203+
if (!PrivateModuleInterfaceOutputPath.empty())
204+
fn(PrivateModuleInterfaceOutputPath);
205+
if (!LdAddCFilePath.empty())
206+
fn(LdAddCFilePath);
207+
if (!ModuleSummaryOutputPath.empty())
208+
fn(ModuleSummaryOutputPath);
209+
}
210+
174211
bool empty() const {
175212
return ObjCHeaderOutputPath.empty() && ModuleOutputPath.empty() &&
176213
ModuleDocOutputPath.empty() && DependenciesFilePath.empty() &&

0 commit comments

Comments
 (0)