Skip to content

Commit adf1101

Browse files
authored
Merge pull request #74747 from artemcm/60EmitModuleParsableOutput
[6.0 🍒][Parseable Output] Make Emit-Module tasks indicate their name accordingly, instead of `compile`
2 parents fc881dc + 2d2f0c8 commit adf1101

7 files changed

+79
-14
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ mapFrontendInvocationToAction(const CompilerInvocation &Invocation) {
598598
return "backend";
599599
else
600600
return "compile";
601+
case FrontendOptions::ActionType::EmitModuleOnly:
602+
return "emit-module";
601603
default:
602604
return "compile";
603605
}
@@ -634,7 +636,8 @@ static swift::file_types::ID computeFileTypeForPath(const StringRef Path) {
634636
static DetailedTaskDescription
635637
constructDetailedTaskDescription(const CompilerInvocation &Invocation,
636638
ArrayRef<InputFile> PrimaryInputs,
637-
ArrayRef<const char *> Args) {
639+
ArrayRef<const char *> Args,
640+
bool isEmitModuleOnly = false) {
638641
// Command line and arguments
639642
std::string Executable = Invocation.getFrontendOptions().MainExecutablePath;
640643
SmallVector<std::string, 16> Arguments;
@@ -653,10 +656,12 @@ constructDetailedTaskDescription(const CompilerInvocation &Invocation,
653656
}
654657

655658
for (const auto &input : PrimaryInputs) {
656-
// Main outputs
657-
auto OutputFile = input.outputFilename();
658-
if (!OutputFile.empty())
659-
Outputs.push_back(OutputPair(computeFileTypeForPath(OutputFile), OutputFile));
659+
if (!isEmitModuleOnly) {
660+
// Main per-input outputs
661+
auto OutputFile = input.outputFilename();
662+
if (!OutputFile.empty())
663+
Outputs.push_back(OutputPair(computeFileTypeForPath(OutputFile), OutputFile));
664+
}
660665

661666
// Supplementary outputs
662667
const auto &primarySpecificFiles = input.getPrimarySpecificPaths();
@@ -2335,10 +2340,14 @@ int swift::performFrontend(ArrayRef<const char *> Args,
23352340
return false;
23362341
});
23372342
} else {
2338-
// If no primary inputs are present, we are in WMO.
2343+
// If no primary inputs are present, we are in WMO or EmitModule.
2344+
bool isEmitModule =
2345+
Invocation.getFrontendOptions().RequestedAction ==
2346+
FrontendOptions::ActionType::EmitModuleOnly;
23392347
emitBeganMessage(llvm::errs(),
23402348
mapFrontendInvocationToAction(Invocation),
2341-
constructDetailedTaskDescription(Invocation, IO.getAllInputs(), Args),
2349+
constructDetailedTaskDescription(Invocation, IO.getAllInputs(),
2350+
Args, isEmitModule),
23422351
OSPid, ProcInfo);
23432352
}
23442353
};

test/Frontend/parseable_output.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %target-swift-frontend -primary-file %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.json -emit-module -emit-module-path %t.swiftmodule -serialize-diagnostics -serialize-diagnostics-path %t.dia -frontend-parseable-output 2>&1 | %FileCheck %s
1+
// RUN: %target-swift-frontend -c -primary-file %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.json -emit-module -emit-module-path %t.swiftmodule -serialize-diagnostics -serialize-diagnostics-path %t.dia -frontend-parseable-output 2>&1 | %FileCheck %s
22
// Check without primary files (WMO):
3-
// RUN: %target-swift-frontend %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.json -emit-module -emit-module-path %t.swiftmodule -serialize-diagnostics -serialize-diagnostics-path %t.dia -frontend-parseable-output 2>&1 | %FileCheck %s
3+
// RUN: %target-swift-frontend -c %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.json -emit-module -emit-module-path %t.swiftmodule -serialize-diagnostics -serialize-diagnostics-path %t.dia -frontend-parseable-output 2>&1 | %FileCheck %s
44

55
// CHECK: {{[1-9][0-9]*}}
66
// CHECK-NEXT: {

test/Frontend/parseable_output_batch.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22
// RUN: touch %t/test.swift
33
// RUN: echo 'func foo() {}' > %t/test.swift
4-
// RUN: %target-swift-frontend -primary-file %s -primary-file %t/test.swift -o %t.out -o test.tmp.out -module-name parseable_output_batch -emit-module -emit-module-path %t.swiftmodule -module-name test -emit-module -emit-module-path test.tmp.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
4+
// RUN: %target-swift-frontend -c -primary-file %s -primary-file %t/test.swift -o %t.out -o test.tmp.out -module-name parseable_output_batch -emit-module -emit-module-path %t.swiftmodule -module-name test -emit-module -emit-module-path test.tmp.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
55

66
// Despite only one frontend invocation, two compile jobs are "begin" and "finish", using quasi-PIDs, on per-primary and its outputs.
77

test/Frontend/parseable_output_early.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not %target-swift-frontend(mock-sdk: -sdk %/S/../ModuleInterface/Inputs/BadStdlib.sdk -module-cache-path %/t/module-cache -resource-dir %/S/../ModuleInterface/Inputs/BadStdlib.sdk) -primary-file %s -o %t.out -emit-module -emit-module-path %t.swiftmodule -module-name parseable_output_early -frontend-parseable-output 2>&1 | %FileCheck %s
1+
// RUN: not %target-swift-frontend(mock-sdk: -sdk %/S/../ModuleInterface/Inputs/BadStdlib.sdk -module-cache-path %/t/module-cache -resource-dir %/S/../ModuleInterface/Inputs/BadStdlib.sdk) -c -primary-file %s -o %t.out -emit-module -emit-module-path %t.swiftmodule -module-name parseable_output_early -frontend-parseable-output 2>&1 | %FileCheck %s
22

33
// CHECK: {{[1-9][0-9]*}}
44
// CHECK-NEXT: {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// RUN: %target-swift-frontend -emit-module %s %S/Inputs/filelist-other.swift -module-name parseable_output_emit_module -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.json -emit-module -emit-module-path %t.swiftmodule -serialize-diagnostics -serialize-diagnostics-path %t.dia -frontend-parseable-output 2>&1 | %FileCheck %s
2+
3+
// CHECK: {{[1-9][0-9]*}}
4+
// CHECK-NEXT: {
5+
// CHECK-NEXT: "kind": "began",
6+
// CHECK-NEXT: "name": "emit-module",
7+
// CHECK-NEXT: "command": "{{.*[\\/]}}swift-frontend{{(\.exe)?}}{{.*}} {{.*}} -emit-module {{.*[\\/]}}parseable_output_emit_module.swift {{.*[\\/]}}filelist-other.swift -module-name parseable_output_emit_module -empty-abi-descriptor -emit-abi-descriptor-path {{.*[\\/]}}parseable_output_emit_module.swift.tmp.abi.json -emit-module -emit-module-path {{.*[\\/]}}parseable_output_emit_module.swift.tmp.swiftmodule -serialize-diagnostics -serialize-diagnostics-path {{.*[\\/]}}parseable_output_emit_module.swift.tmp.dia -frontend-parseable-output",
8+
// CHECK-NEXT: "command_executable": "{{.*[\\/]}}swift{{(-frontend|c)?(\.exe)?}}",
9+
// CHECK-NEXT: "command_arguments": [
10+
// CHECK: "{{.*[\\/]}}parseable_output_emit_module.swift",
11+
// CHECK-NEXT: "{{.*[\\/]}}filelist-other.swift",
12+
// CHECK-NEXT: "-module-name",
13+
// CHECK-NEXT: "parseable_output_emit_module",
14+
// CHECK-NEXT: "-empty-abi-descriptor",
15+
// CHECK-NEXT: "-emit-abi-descriptor-path",
16+
// CHECK-NEXT: "{{.*[\\/]}}parseable_output_emit_module.swift.tmp.abi.json",
17+
// CHECK-NEXT: "-emit-module",
18+
// CHECK-NEXT: "-emit-module-path",
19+
// CHECK-NEXT: "{{.*[\\/]}}parseable_output_emit_module.swift.tmp.swiftmodule",
20+
// CHECK-NEXT: "-serialize-diagnostics",
21+
// CHECK-NEXT: "-serialize-diagnostics-path"
22+
// CHECK-NEXT: "{{.*[\\/]}}parseable_output_emit_module.swift.tmp.dia",
23+
// CHECK-NEXT: "-frontend-parseable-output"
24+
// CHECK-NEXT: ],
25+
// CHECK-NEXT: "inputs": [
26+
// CHECK-NEXT: "{{.*[\\/]}}parseable_output_emit_module.swift"
27+
// CHECK: "outputs": [
28+
// CHECK-NEXT: {
29+
// CHECK-NEXT: "type": "swiftmodule",
30+
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_emit_module.swift.tmp.swiftmodule"
31+
// CHECK-NEXT: },
32+
// CHECK-NEXT: {
33+
// CHECK-NEXT: "type": "diagnostics",
34+
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_emit_module.swift.tmp.dia"
35+
// CHECK-NEXT: },
36+
// CHECK-NEXT: {
37+
// CHECK-NEXT: "type": "abi-baseline-json",
38+
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_emit_module.swift.tmp.abi.json"
39+
// CHECK-NEXT: }
40+
// CHECK-NEXT: ],
41+
// CHECK-NEXT: "pid": [[PID:[0-9]*]]
42+
// CHECK-NEXT: "process": {
43+
// CHECK-NEXT: "real_pid": [[PID]]
44+
// CHECK-NEXT: }
45+
// CHECK-NEXT: }
46+
47+
// CHECK-NEXT: {{[1-9][0-9]*}}
48+
// CHECK-NEXT: {
49+
// CHECK-NEXT: "kind": "finished",
50+
// CHECK-NEXT: "name": "emit-module",
51+
// CHECK-NEXT: "pid": [[PID]],
52+
// CHECK-NEXT: "process": {
53+
// CHECK-NEXT: "real_pid": [[PID]]
54+
// CHECK-NEXT: },
55+
// CHECK-NEXT: "exit-status": 0
56+
// CHECK-NEXT: }

test/Frontend/parseable_output_error.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: not %target-swift-frontend -primary-file %s -o %t.out -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
1+
// RUN: not %target-swift-frontend -c -primary-file %s -o %t.out -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
22
// Check without primary files (WMO):
3-
// RUN: not %target-swift-frontend %s -o %t.out -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
3+
// RUN: not %target-swift-frontend -c %s -o %t.out -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
44

55
func foo() {
66
return 11;

test/Frontend/parseable_output_unknown_file_type.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.weird_file_extension -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
1+
// RUN: %target-swift-frontend -c -primary-file %s %S/Inputs/filelist-other.swift -o %t.out -module-name parseable_output -empty-abi-descriptor -emit-abi-descriptor-path %t.abi.weird_file_extension -emit-module -emit-module-path %t.swiftmodule -frontend-parseable-output 2>&1 | %FileCheck %s
22

33
// CHECK: {{[1-9][0-9]*}}
44
// CHECK-NEXT: {

0 commit comments

Comments
 (0)