diff options
author | 2018-02-07 08:46:31 -0800 | |
---|---|---|
committer | 2018-02-07 08:48:27 -0800 | |
commit | ebd28a9f20a429dc1d347202017824f7aeabedad (patch) | |
tree | 39fc38dcdfdf9d3e092c0dc6e2e5f72ca7b116e6 /src/main/cpp/option_processor.h | |
parent | e00dc41957a75099780988157ae5bed751cc4e13 (diff) |
Refactor blazerc parsing out of OptionProcessor. This change should be a no-op behavior-wise.
RELNOTES: None
PiperOrigin-RevId: 184843442
Diffstat (limited to 'src/main/cpp/option_processor.h')
-rw-r--r-- | src/main/cpp/option_processor.h | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/src/main/cpp/option_processor.h b/src/main/cpp/option_processor.h index 0fe45ba015..d2053017ef 100644 --- a/src/main/cpp/option_processor.h +++ b/src/main/cpp/option_processor.h @@ -21,6 +21,7 @@ #include <string> #include <vector> +#include "src/main/cpp/rc_file.h" #include "src/main/cpp/startup_options.h" #include "src/main/cpp/util/exit_code.h" @@ -56,7 +57,7 @@ class OptionProcessor { OptionProcessor(const WorkspaceLayout* workspace_layout, std::unique_ptr<StartupOptions> default_startup_options); - virtual ~OptionProcessor(); + virtual ~OptionProcessor() {} // Splits the arguments of a command line invocation. // @@ -113,51 +114,17 @@ class OptionProcessor { // to the failure. Otherwise, the server will handle any required logging. void PrintStartupOptionsProvenanceMessage() const; - private: - class RcOption { - public: - RcOption(int rcfile_index, const std::string& option); - - const int rcfile_index() const { return rcfile_index_; } - const std::string& option() const { return option_; } - - private: - int rcfile_index_; - std::string option_; - }; - - class RcFile { - public: - RcFile(const std::string& filename, int index); - blaze_exit_code::ExitCode Parse( - const std::string& workspace, const WorkspaceLayout* workspace_layout, - std::vector<RcFile*>* rcfiles, - std::map<std::string, std::vector<RcOption>>* rcoptions, - std::string* error); - const std::string& Filename() const { return filename_; } - const int Index() const { return index_; } - - private: - static blaze_exit_code::ExitCode Parse( - const std::string& workspace, const std::string& filename, - const int index, const WorkspaceLayout* workspace_layout, - std::vector<RcFile*>* rcfiles, - std::map<std::string, std::vector<RcOption>>* rcoptions, - std::list<std::string>* import_stack, std::string* error); - - std::string filename_; - int index_; - }; - blaze_exit_code::ExitCode ParseStartupOptions(std::string* error); + // Constructs all synthetic command args that should be passed to the + // server to configure blazerc options and client environment. static std::vector<std::string> GetBlazercAndEnvCommandArgs( const std::string& cwd, - const std::vector<RcFile*>& blazercs, - const std::map<std::string, std::vector<RcOption>>& rcoptions); + const std::vector<std::unique_ptr<RcFile>>& blazercs, + const std::vector<std::string>& env); // The list of parsed rc files, this field is initialized by ParseOptions. - std::vector<RcFile*> blazercs_; + std::vector<std::unique_ptr<RcFile>> blazercs_; // A map representing the flags parsed from the bazelrc files. // A key is a command (e.g. 'build', 'startup') and its value is an ordered |