@@ -29,17 +29,46 @@ bool HostInfoMacOSX::ComputeSwiftResourceDirectory(FileSpec &lldb_shlib_spec,
29
29
if (!lldb_shlib_spec)
30
30
return false ;
31
31
32
- std::string raw_path = lldb_shlib_spec.GetPath ();
33
- size_t framework_pos = raw_path.find (" LLDB.framework" );
34
- if (framework_pos == std::string::npos)
32
+ std::string shlib_path = lldb_shlib_spec.GetPath ();
33
+ std::string resource_dir;
34
+
35
+ llvm::StringRef path (shlib_path);
36
+ // "LLDB.framework/Versions/A/LLDB" -> "LLDB.framework"
37
+ while (!path.empty () && llvm::sys::path::filename (path) != " LLDB.framework" )
38
+ path = llvm::sys::path::parent_path (path);
39
+ // POSIX-style install.
40
+ if (path.empty () || llvm::sys::path::filename (path) != " LLDB.framework" )
35
41
return HostInfoPosix::ComputeSwiftResourceDirectory (lldb_shlib_spec,
36
- file_spec, verify);
37
-
38
- framework_pos += strlen (" LLDB.framework" );
39
- raw_path.resize (framework_pos);
40
- raw_path.append (" /Resources/Swift" );
41
- if (!verify || VerifySwiftPath (raw_path)) {
42
- file_spec.SetDirectory (raw_path);
42
+ file_spec, verify);
43
+
44
+ assert (llvm::sys::path::filename (path) == " LLDB.framework" );
45
+ path = llvm::sys::path::parent_path (path);
46
+ if (llvm::sys::path::filename (path) == " PrivateFrameworks" ) {
47
+ // Toolchain:
48
+ // Xcode.app/Contents/Developer/Toolchains/OSX26.0.xctoolchain/System/Library/PrivateFrameworks/LLDB.framework
49
+ // Xcode.app/Contents/Developer/Toolchains/OSX26.0.xctoolchain/usr/lib/swift
50
+ path = llvm::sys::path::parent_path (path);
51
+ if (llvm::sys::path::filename (path) != " Library" )
52
+ return {};
53
+ path = llvm::sys::path::parent_path (path);
54
+ if (llvm::sys::path::filename (path) != " System" )
55
+ return {};
56
+ path = llvm::sys::path::parent_path (path);
57
+ resource_dir = std::string (path) + " /usr/lib/swift" ;
58
+ } else if (llvm::sys::path::filename (path) == " SharedFrameworks" ) {
59
+ // Xcode:
60
+ // Xcode.app/Contents/SharedFrameworks/LLDB.framework
61
+ // Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
62
+ path = llvm::sys::path::parent_path (path);
63
+ resource_dir =
64
+ std::string (path) +
65
+ " /Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift" ;
66
+ } else {
67
+ // Local build: LLDB.framework
68
+ resource_dir = std::string (path) + " /LLDB.framework/Resources/Swift" ;
69
+ }
70
+ if (!verify || VerifySwiftPath (resource_dir)) {
71
+ file_spec.SetDirectory (resource_dir);
43
72
FileSystem::Instance ().Resolve (file_spec);
44
73
return true ;
45
74
}
0 commit comments