diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2023-04-28 09:29:19 -0700 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2023-04-28 09:30:59 -0700 |
commit | ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9 (patch) | |
tree | 6862d070438c5f37da2dfe6e4f8c29789e48ae93 /lldb/include | |
parent | 8c8fe11916b03887f89f04b216e0044f2a9cb505 (diff) | |
download | llvm-ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9.tar.gz |
Host: generalise `GetXcodeSDKPath`
This generalises the GetXcodeSDKPath hook to a GetSDKRoot path which
will be re-used for the Windows support to compute a language specific
SDK path on the platform. Because there may be other options that we
wish to use to compute the SDK path, sink the XcodeSDK parameter into
a structure which can pass a disaggregated set of options. Furthermore,
optionalise the parameter as Xcode is not available for all platforms.
Differential Revision: https://reviews.llvm.org/D149397
Reviewed By: JDevlieghere
Diffstat (limited to 'lldb/include')
-rw-r--r-- | lldb/include/lldb/Host/HostInfoBase.h | 29 | ||||
-rw-r--r-- | lldb/include/lldb/Host/macosx/HostInfoMacOSX.h | 2 |
2 files changed, 26 insertions, 5 deletions
diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h index 42f71d91f9bf..28f809398d5b 100644 --- a/lldb/include/lldb/Host/HostInfoBase.h +++ b/lldb/include/lldb/Host/HostInfoBase.h @@ -31,6 +31,23 @@ struct SharedCacheImageInfo { lldb::DataBufferSP data_sp; }; +namespace { +struct HostInfoError : public llvm::ErrorInfo<HostInfoError> { + static char ID; + const std::string message_; + + HostInfoError(const std::string message) : message_(std::move(message)) {} + + void log(llvm::raw_ostream &OS) const override { OS << "HostInfoError"; } + + std::error_code convertToErrorCode() const override { + return llvm::inconvertibleErrorCode(); + } +}; + +char HostInfoError::ID = 0; +} // namespace + class HostInfoBase { private: // Static class, unconstructable. @@ -108,10 +125,14 @@ public: static FileSpec GetXcodeContentsDirectory() { return {}; } static FileSpec GetXcodeDeveloperDirectory() { return {}; } - - /// Return the directory containing a specific Xcode SDK. - static llvm::Expected<llvm::StringRef> GetXcodeSDKPath(XcodeSDK sdk) { - return ""; + + struct SDKOptions { + std::optional<XcodeSDK> XcodeSDK; + }; + + /// Return the directory containing something like a SDK (reused for Swift). + static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options) { + return llvm::make_error<HostInfoError>("cannot determine SDK root"); } /// Return information about module \p image_name if it is loaded in diff --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h index 0402509cfa26..74d979d965a7 100644 --- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h +++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h @@ -31,7 +31,7 @@ public: static FileSpec GetXcodeDeveloperDirectory(); /// Query xcrun to find an Xcode SDK directory. - static llvm::Expected<llvm::StringRef> GetXcodeSDKPath(XcodeSDK sdk); + static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options); /// Shared cache utilities static SharedCacheImageInfo |