diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2017-12-30 08:15:15 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2017-12-30 08:15:15 +0000 |
commit | 0c1981ea0db8eed3f9d1693bab11bcd61b7d05d0 (patch) | |
tree | a06c030bdbe827a4a1055245ad238b39c252b607 /llvm/include/llvm/Support/CommandLine.h | |
parent | ca3cdd7f27134525d28d740707c3cdb6b388b95a (diff) | |
download | bcm5719-llvm-0c1981ea0db8eed3f9d1693bab11bcd61b7d05d0.tar.gz bcm5719-llvm-0c1981ea0db8eed3f9d1693bab11bcd61b7d05d0.zip |
Added support for reading configuration files
Configuration file is read as a response file in which file names in
the nested constructs `@file` are resolved relative to the directory
where the including file resides. Lines in which the first non-whitespace
character is '#' are considered as comments and are skipped. Trailing
backslashes are used to concatenate lines in the same way as they
are used in shell scripts.
Differential Revision: https://reviews.llvm.org/D24926
llvm-svn: 321580
Diffstat (limited to 'llvm/include/llvm/Support/CommandLine.h')
-rw-r--r-- | llvm/include/llvm/Support/CommandLine.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index d1901db7c68..f043c112861 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -1862,6 +1862,33 @@ using TokenizerCallback = void (*)(StringRef Source, StringSaver &Saver, SmallVectorImpl<const char *> &NewArgv, bool MarkEOLs); +/// Tokenizes content of configuration file. +/// +/// \param [in] Source The string representing content of config file. +/// \param [in] Saver Delegates back to the caller for saving parsed strings. +/// \param [out] NewArgv All parsed strings are appended to NewArgv. +/// \param [in] MarkEOLs Added for compatibility with TokenizerCallback. +/// +/// It works like TokenizeGNUCommandLine with ability to skip comment lines. +/// +void tokenizeConfigFile(StringRef Source, StringSaver &Saver, + SmallVectorImpl<const char *> &NewArgv, + bool MarkEOLs = false); + +/// Reads command line options from the given configuration file. +/// +/// \param [in] CfgFileName Path to configuration file. +/// \param [in] Saver Objects that saves allocated strings. +/// \param [out] Argv Array to which the read options are added. +/// \return true if the file was successfully read. +/// +/// It reads content of the specified file, tokenizes it and expands "@file" +/// commands resolving file names in them relative to the directory where +/// CfgFilename resides. +/// +bool readConfigFile(StringRef CfgFileName, StringSaver &Saver, + SmallVectorImpl<const char *> &Argv); + /// \brief Expand response files on a command line recursively using the given /// StringSaver and tokenization strategy. Argv should contain the command line /// before expansion and will be modified in place. If requested, Argv will |