clang  20.0.0git
Library.h
Go to the documentation of this file.
1 //===- InstallAPI/Library.h -------------------------------------*- C++ -*-===//
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 ///
9 /// Defines the content of a library, such as public and private
10 /// header files, and whether it is a framework.
11 ///
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_INSTALLAPI_LIBRARY_H
14 #define LLVM_CLANG_INSTALLAPI_LIBRARY_H
15 
17 #include "clang/InstallAPI/MachO.h"
18 
19 namespace clang::installapi {
20 
21 class Library {
22 public:
23  Library(StringRef Directory) : BaseDirectory(Directory) {}
24 
25  /// Capture the name of the framework by the install name.
26  ///
27  /// \param InstallName The install name of the library encoded in a dynamic
28  /// library.
29  static StringRef getFrameworkNameFromInstallName(StringRef InstallName);
30 
31  /// Get name of library by the discovered file path.
32  StringRef getName() const;
33 
34  /// Get discovered path of library.
35  StringRef getPath() const { return BaseDirectory; }
36 
37  /// Add a header file that belongs to the library.
38  ///
39  /// \param FullPath Path to header file.
40  /// \param Type Access level of header.
41  /// \param IncludePath The way the header should be included.
42  void addHeaderFile(StringRef FullPath, HeaderType Type,
43  StringRef IncludePath = StringRef()) {
44  Headers.emplace_back(FullPath, Type, IncludePath);
45  }
46 
47  /// Determine if library is empty.
48  bool empty() {
49  return SubFrameworks.empty() && Headers.empty() &&
50  FrameworkVersions.empty();
51  }
52 
53 private:
54  std::string BaseDirectory;
55  HeaderSeq Headers;
56  std::vector<Library> SubFrameworks;
57  std::vector<Library> FrameworkVersions;
58  bool IsUnwrappedDylib{false};
59 
60  friend class DirectoryScanner;
61 };
62 
63 } // namespace clang::installapi
64 
65 #endif // LLVM_CLANG_INSTALLAPI_LIBRARY_H
The base class of the type hierarchy.
Definition: Type.h:1829
StringRef getPath() const
Get discovered path of library.
Definition: Library.h:35
void addHeaderFile(StringRef FullPath, HeaderType Type, StringRef IncludePath=StringRef())
Add a header file that belongs to the library.
Definition: Library.h:42
StringRef getName() const
Get name of library by the discovered file path.
Definition: Library.cpp:24
Library(StringRef Directory)
Definition: Library.h:23
bool empty()
Determine if library is empty.
Definition: Library.h:48
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
std::vector< HeaderFile > HeaderSeq
Definition: HeaderFile.h:150