mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ModuleInterface: teach -compile-module-from-interface to emit forwarding module
-compile-module-from-interface action now takes arguments of -candidate-module-file. If one of the candidate module files is up-to-date, the action emits a forwarding module pointing to the candidate module instead of building a binary module.
This commit is contained in:
@@ -147,7 +147,8 @@ bool ModuleInterfaceBuilder::collectDepsForSerialization(
|
||||
|
||||
bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
|
||||
StringRef OutPath, bool ShouldSerializeDeps,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer) {
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
ArrayRef<std::string> CompiledCandidates) {
|
||||
|
||||
auto outerPrettyStackState = llvm::SavePrettyStackState();
|
||||
|
||||
@@ -167,6 +168,13 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
|
||||
[&](SubCompilerInstanceInfo &info) {
|
||||
auto &SubInstance = *info.Instance;
|
||||
auto subInvocation = SubInstance.getInvocation();
|
||||
// Try building forwarding module first. If succeed, return.
|
||||
if (static_cast<ModuleInterfaceLoader*>(SubInstance.getASTContext()
|
||||
.getModuleInterfaceLoader())->tryEmitForwardingModule(moduleName,
|
||||
interfacePath,
|
||||
CompiledCandidates, OutPath)) {
|
||||
return false;
|
||||
}
|
||||
FrontendOptions &FEOpts = subInvocation.getFrontendOptions();
|
||||
const auto &InputInfo = FEOpts.InputsAndOutputs.firstInput();
|
||||
StringRef InPath = InputInfo.file();
|
||||
@@ -256,12 +264,14 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
|
||||
bool ModuleInterfaceBuilder::buildSwiftModule(StringRef OutPath,
|
||||
bool ShouldSerializeDeps,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
llvm::function_ref<void()> RemarkRebuild) {
|
||||
llvm::function_ref<void()> RemarkRebuild,
|
||||
ArrayRef<std::string> CompiledCandidates) {
|
||||
auto build = [&]() {
|
||||
if (RemarkRebuild) {
|
||||
RemarkRebuild();
|
||||
}
|
||||
return buildSwiftModuleInternal(OutPath, ShouldSerializeDeps, ModuleBuffer);
|
||||
return buildSwiftModuleInternal(OutPath, ShouldSerializeDeps, ModuleBuffer,
|
||||
CompiledCandidates);
|
||||
};
|
||||
if (disableInterfaceFileLock) {
|
||||
return build();
|
||||
|
||||
Reference in New Issue
Block a user