mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add IsSDKRelative field to ModuleInterfaceLayout
When serializing the module interface path of an interface that is part of the SDK, we serialize relative to the SDK path. During deserialization we need to know if a path was serialized relative to the SDK or not. The existing logic assumes any relative path has been serialized relative to the SDK, which makes it impossible to compile modules from relative swiftinterface paths that are not part of the SDK. Update the swiftmodule file to include an attribute to show if the path was serialized relative to the SDK or not, which is used during deserialization to correctly reconstruct the interface path.
This commit is contained in:
@@ -1615,6 +1615,8 @@ ModuleFileSharedCore::ModuleFileSharedCore(
|
||||
break;
|
||||
}
|
||||
case input_block::MODULE_INTERFACE_PATH: {
|
||||
input_block::ModuleInterfaceLayout::readRecord(
|
||||
scratch, IsModuleInterfaceSDKRelative);
|
||||
ModuleInterfacePath = blobData;
|
||||
break;
|
||||
}
|
||||
@@ -1837,10 +1839,12 @@ bool ModuleFileSharedCore::hasSourceInfo() const {
|
||||
std::string ModuleFileSharedCore::resolveModuleDefiningFilePath(const StringRef SDKPath) const {
|
||||
if (!ModuleInterfacePath.empty()) {
|
||||
std::string interfacePath = ModuleInterfacePath.str();
|
||||
if (llvm::sys::path::is_relative(interfacePath) && !ModuleInterfacePath.starts_with(SDKPath)) {
|
||||
SmallString<128> absoluteInterfacePath(SDKPath);
|
||||
llvm::sys::path::append(absoluteInterfacePath, interfacePath);
|
||||
return absoluteInterfacePath.str().str();
|
||||
if (IsModuleInterfaceSDKRelative &&
|
||||
!ModuleInterfacePath.starts_with(SDKPath) &&
|
||||
llvm::sys::path::is_relative(interfacePath)) {
|
||||
SmallString<128> resolvedPath(SDKPath);
|
||||
llvm::sys::path::append(resolvedPath, interfacePath);
|
||||
return resolvedPath.str().str();
|
||||
} else
|
||||
return interfacePath;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user