mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #40923 from hyp/emit-cxx-interface-option
[interop] add an option to emit C++ header interface for a module
This commit is contained in:
@@ -186,6 +186,22 @@ static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
|
||||
});
|
||||
}
|
||||
|
||||
/// Prints the C++ "generated header" interface for \p M to \p
|
||||
/// outputPath.
|
||||
///
|
||||
/// ...unless \p outputPath is empty, in which case it does nothing.
|
||||
///
|
||||
/// \returns true if there were any errors
|
||||
///
|
||||
/// \see swift::printAsCxx
|
||||
static bool printAsCxxIfNeeded(StringRef outputPath, ModuleDecl *M) {
|
||||
if (outputPath.empty())
|
||||
return false;
|
||||
return withOutputFile(
|
||||
M->getDiags(), outputPath,
|
||||
[&](raw_ostream &os) -> bool { return printAsCXX(os, M); });
|
||||
}
|
||||
|
||||
/// Prints the stable module interface for \p M to \p outputPath.
|
||||
///
|
||||
/// ...unless \p outputPath is empty, in which case it does nothing.
|
||||
@@ -826,6 +842,12 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
|
||||
Invocation.getObjCHeaderOutputPathForAtMostOnePrimary(),
|
||||
Instance.getMainModule(), BridgingHeaderPathForPrint);
|
||||
}
|
||||
if ((!Context.hadError() || opts.AllowModuleWithCompilerErrors) &&
|
||||
opts.InputsAndOutputs.hasCxxHeaderOutputPath()) {
|
||||
hadAnyError |= printAsCxxIfNeeded(
|
||||
Invocation.getCxxHeaderOutputPathForAtMostOnePrimary(),
|
||||
Instance.getMainModule());
|
||||
}
|
||||
|
||||
// Only want the header if there's been any errors, ie. there's not much
|
||||
// point outputting a swiftinterface for an invalid module
|
||||
|
||||
Reference in New Issue
Block a user