John Thompson | d845bae | 2015-02-13 14:29:22 +0000 | [diff] [blame] | 1 | //=====-- ModularizeUtilities.h - Utilities for modularize -*- C++ -*-======// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===--------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// \brief ModularizeUtilities class definition. |
| 12 | /// |
| 13 | //===--------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef MODULARIZEUTILITIES_H |
| 16 | #define MODULARIZEUTILITIES_H |
| 17 | |
| 18 | #include "Modularize.h" |
| 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace Modularize { |
| 23 | |
| 24 | /// Modularize utilities class. |
| 25 | /// Support functions and data for modularize. |
| 26 | class ModularizeUtilities { |
| 27 | public: |
| 28 | // Input arguments. |
| 29 | |
| 30 | /// The input file paths. |
| 31 | std::vector<std::string> InputFilePaths; |
| 32 | /// The header prefix. |
| 33 | llvm::StringRef HeaderPrefix; |
| 34 | |
| 35 | // Output data. |
| 36 | |
| 37 | // List of top-level header files. |
| 38 | llvm::SmallVector<std::string, 32> HeaderFileNames; |
| 39 | // Map of top-level header file dependencies. |
| 40 | DependencyMap Dependencies; |
| 41 | |
| 42 | // Functions. |
| 43 | |
| 44 | /// Constructor. |
| 45 | /// You can use the static createModularizeUtilities to create an instance |
| 46 | /// of this object. |
| 47 | /// \param InputPaths The input file paths. |
| 48 | /// \param Prefix The headear path prefix. |
| 49 | ModularizeUtilities(std::vector<std::string> &InputPaths, |
| 50 | llvm::StringRef Prefix); |
| 51 | |
| 52 | /// Create instance of ModularizeUtilities. |
| 53 | /// \param InputPaths The input file paths. |
| 54 | /// \param Prefix The headear path prefix. |
| 55 | /// \returns Initialized ModularizeUtilities object. |
| 56 | static ModularizeUtilities *createModularizeUtilities( |
| 57 | std::vector<std::string> &InputPaths, |
| 58 | llvm::StringRef Prefix); |
| 59 | |
| 60 | /// Load header list and dependencies. |
| 61 | /// \returns std::error_code. |
| 62 | std::error_code loadAllHeaderListsAndDependencies(); |
| 63 | |
| 64 | protected: |
| 65 | /// Load single header list and dependencies. |
| 66 | /// \param InputPath The input file path. |
| 67 | /// \returns std::error_code. |
| 68 | std::error_code loadSingleHeaderListsAndDependencies( |
| 69 | llvm::StringRef InputPath); |
John Thompson | 3dcb393 | 2015-02-17 20:43:47 +0000 | [diff] [blame] | 70 | |
| 71 | public: |
| 72 | |
| 73 | // Utility functions. |
| 74 | |
| 75 | /// Convert header path to canonical form. |
| 76 | /// The canonical form is basically just use forward slashes, |
| 77 | /// and remove "./". |
| 78 | /// \param FilePath The file path. |
| 79 | /// \returns The file path in canonical form. |
| 80 | static std::string getCanonicalPath(llvm::StringRef FilePath); |
John Thompson | d845bae | 2015-02-13 14:29:22 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // end namespace Modularize |
| 84 | |
| 85 | #endif // MODULARIZEUTILITIES_H |