brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.8 KiB · f484594 Raw
221 lines · c
1//===--- clang-installapi/Options.h - Options -------------------*- 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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_CLANG_INSTALLAPI_OPTIONS_H10#define LLVM_CLANG_TOOLS_CLANG_INSTALLAPI_OPTIONS_H11 12#include "clang/Basic/Diagnostic.h"13#include "clang/Basic/FileManager.h"14#include "clang/Driver/Driver.h"15#include "clang/Frontend/FrontendOptions.h"16#include "clang/InstallAPI/Context.h"17#include "clang/InstallAPI/DylibVerifier.h"18#include "clang/InstallAPI/MachO.h"19#include "llvm/Option/ArgList.h"20#include "llvm/Option/Option.h"21#include "llvm/Support/Program.h"22#include "llvm/TargetParser/Triple.h"23#include <string>24#include <vector>25 26namespace clang {27namespace installapi {28 29struct DriverOptions {30  /// \brief Path to input file lists (JSON).31  llvm::MachO::PathSeq FileLists;32 33  /// \brief Path to input directory.34  std::string InputDirectory;35 36  /// \brief Path to public umbrella header.37  std::string PublicUmbrellaHeader;38 39  /// \brief Path to private umbrella header.40  std::string PrivateUmbrellaHeader;41 42  /// \brief Path to project umbrella header.43  std::string ProjectUmbrellaHeader;44 45  /// \brief Paths of extra public headers.46  PathSeq ExtraPublicHeaders;47 48  /// \brief Paths of extra private headers.49  PathSeq ExtraPrivateHeaders;50 51  /// \brief Paths of extra project headers.52  PathSeq ExtraProjectHeaders;53 54  /// \brief List of excluded public headers.55  PathSeq ExcludePublicHeaders;56 57  /// \brief List of excluded private headers.58  PathSeq ExcludePrivateHeaders;59 60  /// \brief List of excluded project headers.61  PathSeq ExcludeProjectHeaders;62 63  /// \brief Mappings of target triples & tapi targets to build for.64  std::map<llvm::MachO::Target, llvm::Triple> Targets;65 66  /// \brief Path to binary dylib for comparing.67  std::string DylibToVerify;68 69  /// \brief Output path.70  std::string OutputPath;71 72  /// \brief DSYM path.73  std::string DSYMPath;74 75  /// \brief File encoding to print.76  FileType OutFT = FileType::TBD_V5;77 78  /// \brief Verification mode for comparing symbols.79  VerificationMode VerifyMode = VerificationMode::Pedantic;80 81  /// \brief Whether the library is zippered.82  bool Zippered = false;83 84  /// \brief Print demangled symbols when reporting errors.85  bool Demangle = false;86 87  /// \brief Print verbose output.88  bool Verbose = false;89 90  /// \brief Log libraries loaded.91  bool TraceLibraryLocation = false;92};93 94struct LinkerOptions {95  /// \brief List of allowable clients to use for the dynamic library.96  LibAttrs AllowableClients;97 98  /// \brief List of reexported libraries to use for the dynamic library.99  LibAttrs ReexportedLibraries;100 101  /// \brief List of reexported libraries to use for the dynamic library.102  LibAttrs ReexportedLibraryPaths;103 104  /// \brief List of reexported frameworks to use for the dynamic library.105  LibAttrs ReexportedFrameworks;106 107  /// \brief List of rpaths to use for the dynamic library.108  LibAttrs RPaths;109 110  /// \brief Additional library search paths.111  PathSeq LibPaths;112 113  /// \brief List of alias symbol files.114  PathSeq AliasLists;115 116  /// \brief The install name to use for the dynamic library.117  std::string InstallName;118 119  /// \brief The current version to use for the dynamic library.120  PackedVersion CurrentVersion;121 122  /// \brief The compatibility version to use for the dynamic library.123  PackedVersion CompatVersion;124 125  /// \brief Name of the umbrella library.126  std::string ParentUmbrella;127 128  /// \brief Is application extension safe.129  bool AppExtensionSafe = false;130 131  /// \brief Set if we should scan for a dynamic library and not a framework.132  bool IsDylib = false;133 134  /// \brief Is an OS library that is not shared cache eligible.135  bool OSLibNotForSharedCache = false;136};137 138struct FrontendOptions {139  /// \brief Unique clang options to pass per key in map.140  llvm::StringMap<std::vector<std::string>> UniqueArgs;141 142  /// \brief The language mode to parse headers in.143  Language LangMode = Language::ObjC;144 145  /// \brief The sysroot to search for SDK headers or libraries.146  std::string ISysroot;147 148  /// \brief Additional framework search paths.149  PathSeq FwkPaths;150 151  /// \brief Additional SYSTEM framework search paths.152  PathToPlatformSeq SystemFwkPaths;153};154 155using arg_iterator = llvm::opt::arg_iterator<llvm::opt::Arg **>;156class Options {157private:158  bool processDriverOptions(llvm::opt::InputArgList &Args);159  bool processLinkerOptions(llvm::opt::InputArgList &Args);160  bool processFrontendOptions(llvm::opt::InputArgList &Args);161  std::vector<const char *>162  processAndFilterOutInstallAPIOptions(ArrayRef<const char *> Args);163  bool processInstallAPIXOptions(llvm::opt::InputArgList &Args);164  bool processXarchOption(llvm::opt::InputArgList &Args, arg_iterator Curr);165  bool processXplatformOption(llvm::opt::InputArgList &Args, arg_iterator Curr);166  bool processXprojectOption(llvm::opt::InputArgList &Args, arg_iterator Curr);167  bool processOptionList(llvm::opt::InputArgList &Args,168                         llvm::opt::OptTable *Table);169 170public:171  /// The various options grouped together.172  DriverOptions DriverOpts;173  LinkerOptions LinkerOpts;174  FrontendOptions FEOpts;175 176  Options() = delete;177 178  /// \brief Create InstallAPIContext from processed options.179  InstallAPIContext createContext();180 181  /// \brief Constructor for options.182  Options(clang::DiagnosticsEngine &Diag, FileManager *FM,183          ArrayRef<const char *> Args, const StringRef ProgName);184 185  /// \brief Get CC1 arguments after extracting out the irrelevant186  /// ones.187  std::vector<std::string> &getClangFrontendArgs() { return FrontendArgs; }188 189  /// \brief Add relevant, but conditionalized by active target and header type,190  /// arguments for constructing a CC1 invocation.191  void addConditionalCC1Args(std::vector<std::string> &ArgStrings,192                             const llvm::Triple &Targ, const HeaderType Type);193 194private:195  bool addFilePaths(llvm::opt::InputArgList &Args, PathSeq &Headers,196                    llvm::opt::OptSpecifier ID);197 198  std::pair<LibAttrs, ReexportedInterfaces> getReexportedLibraries();199 200  DiagnosticsEngine *Diags;201  FileManager *FM;202  std::vector<std::string> FrontendArgs;203  llvm::DenseMap<const llvm::opt::Arg *, Architecture> ArgToArchMap;204  std::vector<std::string> ProjectLevelArgs;205};206 207enum ID {208  OPT_INVALID = 0, // This is not an option ID.209#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS,         \210               VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR,     \211               VALUES, SUBCOMMANDIDS_OFFSET)                                   \212  OPT_##ID,213#include "InstallAPIOpts.inc"214  LastOption215#undef OPTION216};217 218} // namespace installapi219} // namespace clang220#endif221