[driver] Add -working-directory option

Adds a -working-directory option which can be used to modify how
relative paths are resolved. It affects all other paths used in driver
options (controlled by a new ArgumentIsPath flag on options) as well as
the contents of output file maps and auxilliary file paths generated
implicitly by the compiler itself.

rdar://37713856
This commit is contained in:
Ben Langmuir
2018-02-19 15:40:33 -08:00
parent 642cbbad7c
commit 20cb3e3eb2
9 changed files with 393 additions and 122 deletions

View File

@@ -39,14 +39,23 @@ public:
~OutputFileMap() = default;
/// Loads an OutputFileMap from the given \p Path, if possible.
static std::unique_ptr<OutputFileMap> loadFromPath(StringRef Path);
///
/// When non-empty, \p workingDirectory is used to resolve relative paths in
/// the output file map.
static std::unique_ptr<OutputFileMap>
loadFromPath(StringRef Path, StringRef workingDirectory);
static std::unique_ptr<OutputFileMap> loadFromBuffer(StringRef Data);
static std::unique_ptr<OutputFileMap>
loadFromBuffer(StringRef Data, StringRef workingDirectory);
/// Loads an OutputFileMap from the given \p Buffer, taking ownership
/// of the buffer in the process.
///
/// When non-empty, \p workingDirectory is used to resolve relative paths in
/// the output file map.
static std::unique_ptr<OutputFileMap>
loadFromBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer);
loadFromBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer,
StringRef workingDirectory);
/// Get the map of outputs for the given \p Input, if present in the
/// OutputFileMap. (If not present, returns nullptr.)
@@ -69,8 +78,12 @@ private:
/// \brief Parses the given \p Buffer into the OutputFileMap, taking ownership
/// of \p Buffer in the process.
///
/// When non-empty, \p workingDirectory is used to resolve relative paths in
/// the output file map.
///
/// \returns true on error, false on success
bool parse(std::unique_ptr<llvm::MemoryBuffer> Buffer);
bool parse(std::unique_ptr<llvm::MemoryBuffer> Buffer,
StringRef workingDirectory);
};
} // end namespace driver