clang 20.0.0git
Library.cpp
Go to the documentation of this file.
1//===- Library.cpp --------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11using namespace llvm;
12namespace clang::installapi {
13
14const Regex Rule("(.+)/(.+)\\.framework/");
15StringRef Library::getFrameworkNameFromInstallName(StringRef InstallName) {
16 assert(InstallName.contains(".framework") && "expected a framework");
18 Rule.match(InstallName, &Match);
19 if (Match.empty())
20 return "";
21 return Match.back();
22}
23
24StringRef Library::getName() const {
25 assert(!IsUnwrappedDylib && "expected a framework");
26 StringRef Path = BaseDirectory;
27
28 // Return the framework name extracted from path.
29 while (!Path.empty()) {
30 if (Path.ends_with(".framework"))
31 return sys::path::filename(Path);
32 Path = sys::path::parent_path(Path);
33 }
34
35 // Otherwise, return the name of the BaseDirectory.
36 Path = BaseDirectory;
37 return sys::path::filename(Path.rtrim("/"));
38}
39
40} // namespace clang::installapi
IndirectLocalPath & Path
StringRef getName() const
Get name of library by the discovered file path.
Definition: Library.cpp:24
static StringRef getFrameworkNameFromInstallName(StringRef InstallName)
Capture the name of the framework by the install name.
Definition: Library.cpp:15
The DirectoryScanner for collecting library files on the file system.
Definition: Context.h:20
const Regex Rule("(.+)/(.+)\\.framework/")
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30