BuildCache
gcc_wrapper.hpp
1 //--------------------------------------------------------------------------------------------------
2 // Copyright (c) 2018 Marcus Geelnard
3 //
4 // This software is provided 'as-is', without any express or implied warranty. In no event will the
5 // authors be held liable for any damages arising from the use of this software.
6 //
7 // Permission is granted to anyone to use this software for any purpose, including commercial
8 // applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 //
10 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote
11 // the original software. If you use this software in a product, an acknowledgment in the
12 // product documentation would be appreciated but is not required.
13 //
14 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
15 // being the original software.
16 //
17 // 3. This notice may not be removed or altered from any source distribution.
18 //--------------------------------------------------------------------------------------------------
19 
20 #ifndef BUILDCACHE_GCC_WRAPPER_HPP_
21 #define BUILDCACHE_GCC_WRAPPER_HPP_
22 
23 #include <wrappers/program_wrapper.hpp>
24 
25 namespace bcache {
28 public:
29  gcc_wrapper_t(const file::exe_path_t& exe_path, const string_list_t& args);
30 
31  bool can_handle_command() override;
32 
33 protected:
35  std::map<std::string, expected_file_t> get_build_files() override;
36  std::string get_program_id() override;
38  std::map<std::string, std::string> get_relevant_env_vars() override;
39  string_list_t get_input_files() override;
40  std::string preprocess_source() override;
42 
43  string_list_t m_resolved_args;
44 
45 private:
46  void resolve_args() override;
47  string_list_t parse_args(const string_list_t& args);
48  string_list_t parse_response_file(const std::string& filename);
49  virtual string_list_t get_include_files(const std::string& std_err) const;
50 
51  string_list_t m_implicit_input_files;
52 };
53 } // namespace bcache
54 #endif // BUILDCACHE_GCC_WRAPPER_HPP_
bcache::gcc_wrapper_t::preprocess_source
std::string preprocess_source() override
Generate the preprocessed source text.
Definition: gcc_wrapper.cpp:340
bcache::file::exe_path_t
Path to an executable file.
Definition: file_utils.hpp:127
bcache::gcc_wrapper_t::get_program_id
std::string get_program_id() override
Get a string that uniquely identifies the program.
Definition: gcc_wrapper.cpp:263
bcache::gcc_wrapper_t
A program wrapper for GCC and GCC-like C/C++ compilers.
Definition: gcc_wrapper.hpp:27
bcache
The top level namespace.
Definition: compressor.cpp:34
bcache::string_list_t
A convenient vector of strings container with support functions for program argument handling.
Definition: string_list.hpp:30
bcache::gcc_wrapper_t::can_handle_command
bool can_handle_command() override
Check if this class implements a wrapper for the given command.
Definition: gcc_wrapper.cpp:204
bcache::gcc_wrapper_t::get_relevant_arguments
string_list_t get_relevant_arguments() override
Get relevant command line arguments for hashing.
Definition: gcc_wrapper.cpp:281
bcache::gcc_wrapper_t::get_build_files
std::map< std::string, expected_file_t > get_build_files() override
Get the paths to the files that are to be generated by the command.
Definition: gcc_wrapper.cpp:241
bcache::gcc_wrapper_t::get_capabilities
string_list_t get_capabilities() override
Generate a list of supported capabilites.
Definition: gcc_wrapper.cpp:235
bcache::gcc_wrapper_t::get_input_files
string_list_t get_input_files() override
Get the paths to the input files for the command.
Definition: gcc_wrapper.cpp:320
bcache::program_wrapper_t
The base class for all program wrappers.
Definition: program_wrapper.hpp:38
bcache::gcc_wrapper_t::get_relevant_env_vars
std::map< std::string, std::string > get_relevant_env_vars() override
Get relevant environment variables for hashing.
Definition: gcc_wrapper.cpp:314
bcache::gcc_wrapper_t::resolve_args
void resolve_args() override
Resolve arguments on the command line.
Definition: gcc_wrapper.cpp:139
bcache::gcc_wrapper_t::get_implicit_input_files
string_list_t get_implicit_input_files() override
Get a list of paths to implicit input files.
Definition: gcc_wrapper.cpp:373