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 16 #include "clang/InstallAPI/HeaderFile.h" 17 #include "clang/InstallAPI/MachO.h" 18 19 namespace clang::installapi { 20 21 class Library { 22 public: Library(StringRef Directory)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. getPath()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. 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 66