Skip to content

Commit c38fcc1

Browse files
committed
[Driver] Expose -emit-parseable-module-interface[-path]
Commit to a command line option spelling so that build systems can start testing it. I deliberately picked one of the longer names we were considering because we can always decide to add a shorter alias, but can't decide a shorter name was too generic. Like the other supplementary output flags, -emit-parseable-module-interface-path will emit a .swiftinterface file to a particular path, while -emit-parseable-module-interface will put it next to the main output (the one specified with -o). rdar://problem/43776945
1 parent 73d5eba commit c38fcc1

24 files changed

+64
-48
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ function(_compile_swift_files
501501
COMMAND
502502
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
503503
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
504-
"-experimental-emit-interface" ${swift_flags} "@${file_path}"
504+
"-emit-parseable-module-interface" ${swift_flags} "@${file_path}"
505505
${command_touch_module_outputs}
506506
OUTPUT ${module_outputs}
507507
DEPENDS

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ def emit_fixits_path
6363
: Separate<["-"], "emit-fixits-path">, MetaVarName<"<path>">,
6464
HelpText<"Output compiler fixits as source edits to <path>">;
6565

66+
// For transition purposes.
6667
def emit_interface_path
67-
: Separate<["-"], "emit-interface-path">, MetaVarName<"<path>">,
68-
HelpText<"Output parseable interface file to <path>">;
68+
: Separate<["-"], "emit-interface-path">,
69+
Alias<emit_parseable_module_interface_path>;
6970

7071
def tbd_install_name
7172
: Separate<["-"], "tbd-install_name">, MetaVarName<"<path>">,

include/swift/Option/Options.td

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,15 @@ def emit_module_path_EQ : Joined<["-"], "emit-module-path=">,
300300
ArgumentIsPath]>,
301301
Alias<emit_module_path>;
302302

303-
def experimental_emit_interface : Flag<["-"], "experimental-emit-interface">,
304-
Flags<[NoInteractiveOption, HelpHidden]>,
305-
HelpText<"Test out the parseable interfaces feature">;
303+
def emit_parseable_module_interface :
304+
Flag<["-"], "emit-parseable-module-interface">,
305+
Flags<[NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
306+
HelpText<"Output parseable interface file">;
307+
def emit_parseable_module_interface_path :
308+
Separate<["-"], "emit-parseable-module-interface-path">,
309+
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild,
310+
ArgumentIsPath]>,
311+
MetaVarName<"<path>">, HelpText<"Output parseable interface file to <path>">;
306312

307313
def emit_objc_header : Flag<["-"], "emit-objc-header">,
308314
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,

lib/Driver/Driver.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,8 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
14941494
OI.ShouldTreatModuleAsTopLevelOutput = false;
14951495
} else if (Args.hasArg(options::OPT_emit_objc_header,
14961496
options::OPT_emit_objc_header_path,
1497-
options::OPT_experimental_emit_interface) &&
1497+
options::OPT_emit_parseable_module_interface,
1498+
options::OPT_emit_parseable_module_interface_path) &&
14981499
OI.CompilerMode != OutputInfo::Mode::SingleCompile) {
14991500
// An option has been passed which requires whole-module knowledge, but we
15001501
// don't have that. Generate a module, but treat it as an intermediate
@@ -2473,7 +2474,8 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
24732474
chooseSwiftModuleDocOutputPath(C, OutputMap, workingDirectory,
24742475
Output.get());
24752476

2476-
if (C.getArgs().hasArg(options::OPT_experimental_emit_interface))
2477+
if (C.getArgs().hasArg(options::OPT_emit_parseable_module_interface,
2478+
options::OPT_emit_parseable_module_interface_path))
24772479
chooseParseableInterfacePath(C, JA, workingDirectory, Buf, Output.get());
24782480

24792481
if (C.getArgs().hasArg(options::OPT_update_code) && isa<CompileJobAction>(JA))
@@ -2773,9 +2775,9 @@ void Driver::chooseRemappingOutputPath(Compilation &C,
27732775
}
27742776

27752777
void Driver::chooseParseableInterfacePath(Compilation &C, const JobAction *JA,
2776-
StringRef workingDirectory,
2777-
llvm::SmallString<128> &buffer,
2778-
CommandOutput *output) const {
2778+
StringRef workingDirectory,
2779+
llvm::SmallString<128> &buffer,
2780+
CommandOutput *output) const {
27792781
switch (C.getOutputInfo().CompilerMode) {
27802782
case OutputInfo::Mode::StandardCompile:
27812783
case OutputInfo::Mode::BatchModeCompile:
@@ -2792,9 +2794,10 @@ void Driver::chooseParseableInterfacePath(Compilation &C, const JobAction *JA,
27922794
}
27932795

27942796
StringRef outputPath = *getOutputFilenameFromPathArgOrAsTopLevel(
2795-
C.getOutputInfo(), C.getArgs(), llvm::opt::OptSpecifier(),
2796-
file_types::TY_SwiftModuleInterfaceFile,
2797-
/*TreatAsTopLevelOutput*/true, workingDirectory, buffer);
2797+
C.getOutputInfo(), C.getArgs(),
2798+
options::OPT_emit_parseable_module_interface_path,
2799+
file_types::TY_SwiftModuleInterfaceFile,
2800+
/*TreatAsTopLevelOutput*/true, workingDirectory, buffer);
27982801
output->setAdditionalOutputForType(file_types::TY_SwiftModuleInterfaceFile,
27992802
outputPath);
28002803
}

lib/Driver/ToolChains.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ void ToolChain::JobContext::addFrontendSupplementaryOutputArguments(
547547

548548
addOutputsOfType(arguments, Output, Args,
549549
file_types::ID::TY_SwiftModuleInterfaceFile,
550-
"-emit-interface-path");
550+
"-emit-parseable-module-interface-path");
551551

552552
addOutputsOfType(arguments, Output, Args,
553553
file_types::TY_SerializedDiagnostics,
@@ -804,7 +804,7 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
804804
file_types::TY_SwiftModuleDocFile, "-emit-module-doc-path");
805805
addOutputsOfType(Arguments, context.Output, context.Args,
806806
file_types::ID::TY_SwiftModuleInterfaceFile,
807-
"-emit-interface-path");
807+
"-emit-parseable-module-interface-path");
808808
addOutputsOfType(Arguments, context.Output, context.Args,
809809
file_types::TY_SerializedDiagnostics,
810810
"-serialize-diagnostics-path");

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
295295
options::OPT_emit_loaded_module_trace_path);
296296
auto TBD = getSupplementaryFilenamesFromArguments(options::OPT_emit_tbd_path);
297297
auto parseableInterfaceOutput = getSupplementaryFilenamesFromArguments(
298-
options::OPT_emit_interface_path);
298+
options::OPT_emit_parseable_module_interface_path);
299299

300300
if (!objCHeaderOutput || !moduleOutput || !moduleDocOutput ||
301301
!dependenciesFile || !referenceDependenciesFile ||

test/Driver/emit-interface.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 %s -experimental-emit-interface -o %t/foo 2>&1 | %FileCheck %s
1+
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 %s -emit-parseable-module-interface -o %t/foo 2>&1 | %FileCheck %s
22

33
// CHECK: swift -frontend
44
// CHECK-SAME: emit-interface.swift
55
// CHECK: swift -frontend -merge-modules
6-
// CHECK-SAME: -emit-interface-path {{.+}}/foo.swiftinterface
6+
// CHECK-SAME: -emit-parseable-module-interface-path {{.+}}/foo.swiftinterface
77
// CHECK: bin/ld
88

9-
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 %s -experimental-emit-interface -o %t/foo -force-single-frontend-invocation 2>&1 | %FileCheck -check-prefix=CHECK-WHOLE-MODULE %s
9+
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 %s -emit-parseable-module-interface -o %t/foo -force-single-frontend-invocation 2>&1 | %FileCheck -check-prefix=CHECK-WHOLE-MODULE %s
1010

1111
// CHECK-WHOLE-MODULE: swift -frontend
1212
// CHECK-WHOLE-MODULE-SAME: emit-interface.swift
13-
// CHECK-WHOLE-MODULE-SAME: -emit-interface-path {{.+}}/foo.swiftinterface
13+
// CHECK-WHOLE-MODULE-SAME: -emit-parseable-module-interface-path {{.+}}/foo.swiftinterface
1414
// CHECK-WHOLE-MODULE-NOT: -merge-modules
1515
// CHECK-WHOLE-MODULE: bin/ld
16+
17+
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 %s -emit-parseable-module-interface-path %t/unrelated.swiftinterface -o %t/foo -force-single-frontend-invocation 2>&1 | %FileCheck -check-prefix=CHECK-EXPLICIT-PATH %s
18+
19+
// CHECK-EXPLICIT-PATH: swift -frontend
20+
// CHECK-EXPLICIT-PATH-SAME: emit-interface.swift
21+
// CHECK-EXPLICIT-PATH-SAME: -emit-parseable-module-interface-path {{.+}}/unrelated.swiftinterface

test/Frontend/dependencies.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// NO-PRIMARY-FILE: warning: ignoring -emit-reference-dependencies (requires -primary-file)
2626

2727

28-
// RUN: %target-swift-frontend -emit-dependencies-path - -emit-module %S/../Inputs/empty\ file.swift -o %t/empty\ file.swiftmodule -emit-module-doc-path %t/empty\ file.swiftdoc -emit-objc-header-path %t/empty\ file.h -emit-interface-path %t/empty\ file.swiftinterface | %FileCheck -check-prefix=CHECK-MULTIPLE-OUTPUTS %s
28+
// RUN: %target-swift-frontend -emit-dependencies-path - -emit-module %S/../Inputs/empty\ file.swift -o %t/empty\ file.swiftmodule -emit-module-doc-path %t/empty\ file.swiftdoc -emit-objc-header-path %t/empty\ file.h -emit-parseable-module-interface-path %t/empty\ file.swiftinterface | %FileCheck -check-prefix=CHECK-MULTIPLE-OUTPUTS %s
2929

3030
// CHECK-MULTIPLE-OUTPUTS-LABEL: empty\ file.swiftmodule :
3131
// CHECK-MULTIPLE-OUTPUTS: Inputs/empty\ file.swift

test/Frontend/supplementary-output-support.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// RUN: not %target-swift-frontend -resolve-imports -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=RESOLVE_IMPORTS_NO_OBJC_HEADER %s
2525
// RESOLVE_IMPORTS_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C headers{{$}}
2626

27-
// RUN: not %target-swift-frontend -parse -emit-interface-path %t %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_INTERFACE %s
27+
// RUN: not %target-swift-frontend -parse -emit-parseable-module-interface-path %t %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_INTERFACE %s
2828
// PARSE_NO_INTERFACE: error: this mode does not support emitting parseable interface files{{$}}
29-
// RUN: not %target-swift-frontend -emit-silgen -emit-interface-path %t %s 2>&1 | %FileCheck -check-prefix=SILGEN_NO_INTERFACE %s
29+
// RUN: not %target-swift-frontend -emit-silgen -emit-parseable-module-interface-path %t %s 2>&1 | %FileCheck -check-prefix=SILGEN_NO_INTERFACE %s
3030
// SILGEN_NO_INTERFACE: error: this mode does not support emitting parseable interface files{{$}}

test/ParseableInterface/access-filter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -typecheck -emit-interface-path %t.swiftinterface %s
1+
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.swiftinterface %s
22
// RUN: %FileCheck %s < %t.swiftinterface
33
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t.swiftinterface
44

0 commit comments

Comments
 (0)