Skip to content

Commit 17a81f6

Browse files
author
David Ungar
committed
Restore -### functionality for batch-mode by extending OutputLevel.
1 parent 26c08fb commit 17a81f6

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

include/swift/Driver/Compilation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ namespace driver {
5151
enum class OutputLevel {
5252
/// Indicates that normal output should be produced.
5353
Normal,
54+
55+
/// Indicates that only jobs should be printed and not run. (-###)
56+
PrintJobs,
5457

5558
/// Indicates that verbose output should be produced. (-v)
5659
Verbose,

include/swift/Driver/Driver.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,6 @@ class Driver {
357357
/// Print the list of Actions in a Compilation.
358358
void printActions(const Compilation &C) const;
359359

360-
/// Print the list of Jobs in a Compilation.
361-
void printJobs(const Compilation &C) const;
362-
363360
/// Print the driver version.
364361
void printVersion(const ToolChain &TC, raw_ostream &OS) const;
365362

lib/Driver/Compilation.cpp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,21 @@ namespace driver {
311311
DriverTimers[BeganCmd]->startTimer();
312312
}
313313

314-
// For verbose output, print out each command as it begins execution.
315-
if (Comp.Level == OutputLevel::Verbose)
314+
switch (Comp.Level) {
315+
case OutputLevel::Normal:
316+
break;
317+
// For command line or verbose output, print out each command as it
318+
// begins execution.
319+
case OutputLevel::PrintJobs:
320+
BeganCmd->printCommandLineAndEnvironment(llvm::outs());
321+
break;
322+
case OutputLevel::Verbose:
316323
BeganCmd->printCommandLine(llvm::errs());
317-
else if (Comp.Level == OutputLevel::Parseable)
324+
break;
325+
case OutputLevel::Parseable:
318326
parseable_output::emitBeganMessage(llvm::errs(), *BeganCmd, Pid);
327+
break;
328+
}
319329
}
320330

321331
/// Note that a .swiftdeps file failed to load and take corrective actions:
@@ -450,15 +460,22 @@ namespace driver {
450460
DriverTimers[FinishedCmd]->stopTimer();
451461
}
452462

453-
if (Comp.Level == OutputLevel::Parseable) {
454-
// Parseable output was requested.
455-
parseable_output::emitFinishedMessage(llvm::errs(), *FinishedCmd, Pid,
456-
ReturnCode, Output);
457-
} else {
458-
// Otherwise, send the buffered output to stderr, though only if we
463+
switch (Comp.Level) {
464+
case OutputLevel::PrintJobs:
465+
// Only print the jobs, not the outputs
466+
break;
467+
case OutputLevel::Normal:
468+
case OutputLevel::Verbose:
469+
// Send the buffered output to stderr, though only if we
459470
// support getting buffered output.
460471
if (TaskQueue::supportsBufferingOutput())
461472
llvm::errs() << Output;
473+
break;
474+
case OutputLevel::Parseable:
475+
// Parseable output was requested.
476+
parseable_output::emitFinishedMessage(llvm::errs(), *FinishedCmd, Pid,
477+
ReturnCode, Output);
478+
break;
462479
}
463480
}
464481

@@ -1109,8 +1126,17 @@ int Compilation::performSingleCommand(const Job *Cmd) {
11091126
if (!writeFilelistIfNecessary(Cmd, Diags))
11101127
return 1;
11111128

1112-
if (Level == OutputLevel::Verbose)
1129+
switch (Level) {
1130+
case OutputLevel::Normal:
1131+
case OutputLevel::Parseable:
1132+
break;
1133+
case OutputLevel::PrintJobs:
1134+
Cmd->printCommandLineAndEnvironment(llvm::outs());
1135+
return 0;
1136+
case OutputLevel::Verbose:
11131137
Cmd->printCommandLine(llvm::errs());
1138+
break;
1139+
}
11141140

11151141
SmallVector<const char *, 128> Argv;
11161142
Argv.push_back(Cmd->getExecutable());

lib/Driver/Driver.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ Driver::buildCompilation(const ToolChain &TC,
515515
bool DriverPrintDerivedOutputFileMap =
516516
ArgList->hasArg(options::OPT_driver_print_derived_output_file_map);
517517
DriverPrintBindings = ArgList->hasArg(options::OPT_driver_print_bindings);
518-
bool DriverPrintJobs = ArgList->hasArg(options::OPT_driver_print_jobs);
519518
bool DriverSkipExecution =
520-
ArgList->hasArg(options::OPT_driver_skip_execution);
519+
ArgList->hasArg(options::OPT_driver_skip_execution,
520+
options::OPT_driver_print_jobs);
521521
bool ShowIncrementalBuildDecisions =
522522
ArgList->hasArg(options::OPT_driver_show_incremental);
523523
bool ShowJobLifecycle =
@@ -679,9 +679,12 @@ Driver::buildCompilation(const ToolChain &TC,
679679
}
680680

681681
OutputLevel Level = OutputLevel::Normal;
682-
if (const Arg *A = ArgList->getLastArg(options::OPT_v,
683-
options::OPT_parseable_output)) {
684-
if (A->getOption().matches(options::OPT_v))
682+
if (const Arg *A =
683+
ArgList->getLastArg(options::OPT_driver_print_jobs, options::OPT_v,
684+
options::OPT_parseable_output)) {
685+
if (A->getOption().matches(options::OPT_driver_print_jobs))
686+
Level = OutputLevel::PrintJobs;
687+
else if (A->getOption().matches(options::OPT_v))
685688
Level = OutputLevel::Verbose;
686689
else if (A->getOption().matches(options::OPT_parseable_output))
687690
Level = OutputLevel::Parseable;
@@ -754,11 +757,6 @@ Driver::buildCompilation(const ToolChain &TC,
754757
if (DriverPrintBindings)
755758
return nullptr;
756759

757-
if (DriverPrintJobs) {
758-
printJobs(*C);
759-
return nullptr;
760-
}
761-
762760
return C;
763761
}
764762

@@ -2622,11 +2620,6 @@ void Driver::printActions(const Compilation &C) const {
26222620
}
26232621
}
26242622

2625-
void Driver::printJobs(const Compilation &C) const {
2626-
for (const Job *J : C.getJobs())
2627-
J->printCommandLineAndEnvironment(llvm::outs());
2628-
}
2629-
26302623
void Driver::printVersion(const ToolChain &TC, raw_ostream &OS) const {
26312624
OS << version::getSwiftFullVersion(
26322625
version::Version::getCurrentLanguageVersion()) << '\n';

test/Driver/embed-bitcode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@
9797
// CHECK-LIB: -emit-bc
9898
// CHECK-LIB: -primary-file
9999
// CHECK-LIB: swift -frontend
100-
// CHECK-LIB: -emit-module
101-
// CHECK-LIB: swift -frontend
102100
// CHECK-LIB: -c
103101
// CHECK-LIB: -embed-bitcode
104102
// CHECK-LIB: -disable-llvm-optzns
105103
// CHECK-LIB: swift -frontend
106104
// CHECK-LIB: -c
107105
// CHECK-LIB: -embed-bitcode
108106
// CHECK-LIB: -disable-llvm-optzns
107+
// CHECK-LIB: swift -frontend
108+
// CHECK-LIB: -emit-module
109109
// CHECK-LIB-NOT: swift -frontend
110110

111111
// RUN: %target-swiftc_driver -embed-bitcode -emit-module %s 2>&1 -### | %FileCheck %s -check-prefix=WARN-EMBED-BITCODE

0 commit comments

Comments
 (0)