@@ -379,6 +379,33 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
379379 return g_developer_directory;
380380}
381381
382+ std::string HostInfoMacOSX::FindComponentInPath (llvm::StringRef path,
383+ llvm::StringRef component) {
384+ auto begin = llvm::sys::path::begin (path);
385+ auto end = llvm::sys::path::end (path);
386+ for (auto it = begin; it != end; ++it) {
387+ if (it->contains (component)) {
388+ llvm::SmallString<128 > buffer;
389+ llvm::sys::path::append (buffer, begin, ++it,
390+ llvm::sys::path::Style::posix);
391+ return buffer.str ().str ();
392+ }
393+ }
394+ return {};
395+ }
396+
397+ FileSpec HostInfoMacOSX::GetCurrentXcodeToolchainDirectory () {
398+ if (FileSpec fspec = HostInfo::GetShlibDir ())
399+ return FileSpec (FindComponentInPath (fspec.GetPath (), " .xctoolchain" ));
400+ return {};
401+ }
402+
403+ FileSpec HostInfoMacOSX::GetCurrentCommandLineToolsDirectory () {
404+ if (FileSpec fspec = HostInfo::GetShlibDir ())
405+ return FileSpec (FindComponentInPath (fspec.GetPath (), " CommandLineTools" ));
406+ return {};
407+ }
408+
382409static llvm::Expected<std::string>
383410xcrun (const std::string &sdk, llvm::ArrayRef<llvm::StringRef> arguments,
384411 llvm::StringRef developer_dir = " " ) {
0 commit comments