1 // options.h -- handle command line options for gold -*- C++ -*-
4 // Holds everything we get from the command line.
5 // General_options (from Command_line::options())
6 // Options which are not position dependent.
7 // Input_argument (from Command_line::inputs())
8 // The list of input files, including -l options.
9 // Position_dependent_options (from Input_argument::options())
10 // Position dependent options which apply to this argument.
12 #ifndef GOLD_OPTIONS_H
13 #define GOLD_OPTIONS_H
26 class Command_line_options;
29 } // End namespace gold::options.
31 // The position independent options which apply to the whole link.
32 // There are a lot of them.
39 // -L: Library search path.
40 typedef std::list<const char*> Dir_list;
44 { return this->search_path_; }
46 // -o: Output file name.
48 output_file_name() const
49 { return this->output_file_name_; }
51 // -r: Whether we are doing a relocatable link.
53 is_relocatable() const
54 { return this->is_relocatable_; }
56 // --shared: Whether generating a shared object.
59 { return this->is_shared_; }
61 // --static: Whether doing a static link.
64 { return this->is_static_; }
67 friend class Command_line;
68 friend class options::Command_line_options;
71 add_to_search_path(const char* arg)
72 { this->search_path_.push_back(arg); }
75 set_output_file_name(const char* arg)
76 { this->output_file_name_ = arg; }
80 { this->is_relocatable_ = true; }
84 { this->is_shared_ = true; }
88 { this->is_static_ = true; }
90 Dir_list search_path_;
91 const char* output_file_name_;
96 // Don't copy this structure.
97 General_options(const General_options&);
98 General_options& operator=(const General_options&);
101 // The current state of the position dependent options.
103 class Position_dependent_options
106 Position_dependent_options();
108 // -Bstatic: Whether we are searching for a static archive rather
109 // -than a shared object.
112 { return this->do_static_search_; }
115 friend class Command_line;
116 friend class options::Command_line_options;
120 { this->do_static_search_ = true; }
124 { this->do_static_search_ = false; }
126 bool do_static_search_;
129 // A single file or library argument from the command line.
134 Input_argument(const char* name, bool is_lib,
135 const Position_dependent_options& options)
136 : name_(name), is_lib_(is_lib), options_(options)
141 { return this->name_; }
143 const Position_dependent_options&
145 { return this->options_; }
149 { return this->is_lib_; }
154 Position_dependent_options options_;
157 // A list of input files.
158 class Input_argument_list : public std::vector<Input_argument>
162 // All the information read from the command line.
169 // Process the command line options. This will exit with an
170 // appropriate error message if an unrecognized option is seen.
172 process(int argc, char** argv);
174 // Handle a -l option.
176 process_l_option(int, char**, char*);
178 // Get the general options.
179 const General_options&
181 { return this->options_; }
183 // Get the list of input files.
184 const Input_argument_list&
186 { return this->inputs_; }
189 void usage() ATTRIBUTE_NORETURN;
190 void usage(const char* msg, const char* opt) ATTRIBUTE_NORETURN;
191 void usage(const char* msg, char opt) ATTRIBUTE_NORETURN;
192 void apply_option(const gold::options::One_option&, const char*);
194 General_options options_;
195 Position_dependent_options position_options_;
196 Input_argument_list inputs_;
199 } // End namespace gold.
201 #endif // !defined(GOLD_OPTIONS_H)