[lld] [lld] handle re-exports for full framework paths (PR #137989)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 10:08:20 PDT 2025
================
@@ -1566,6 +1566,25 @@ static DylibFile *loadDylib(StringRef path, DylibFile *umbrella) {
return loadDylib(*mbref, umbrella);
}
+static StringRef findFramework(StringRef path, StringRef frameworkName) {
----------------
alx32 wrote:
`findFramework` implies a filesystem-type operation.
Am I understanding this correctly ?
```
// Given an install path (e.g., /Path/To/Foo.framework/Versions/A/Foo or
// /Path/To/Bar.framework/Bar) and a framework name (e.g., Foo.framework),
// searches the path components from right-to-left. Returns the substring
// of the install path starting from the first component that matches the
// framework name.
// For example:
// path = "/Path/To/Foo.framework/Versions/A/Foo", frameworkName = "Foo.framework"
// -> returns "Foo.framework/Versions/A/Foo"
// path = "/Path/To/Bar.framework/Bar", frameworkName = "Bar.framework"
// -> returns "Bar.framework/Bar"
// Returns an empty StringRef if the framework name is not found as a path
// component.
static StringRef getRelativeFrameworkPath(StringRef path,
StringRef frameworkName) {
size_t end = path.size();
// Search backwards for the framework name component.
while (true) {
// Find the last '/' before the current end position.
size_t slashPos = path.rfind('/', end);
if (slashPos == StringRef::npos)
return StringRef();
// Extract the component after the slash.
StringRef component = path.substr(slashPos + 1, end - (slashPos + 1));
if (component == frameworkName)
// Found the component, return the relative path starting from here.
return path.substr(slashPos + 1);
// Continue searching before the previously found slash.
end = slashPos;
}
}
```
https://github.com/llvm/llvm-project/pull/137989
More information about the llvm-commits
mailing list