Fix typo in last changelog.
[binutils.git] / gold / options.h
blobba32ef569997d3f419c0b2a7dfd82a7d2864e245
1 // options.h -- handle command line options for gold -*- C++ -*-
3 // Command_line
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
15 #include <list>
16 #include <string>
18 namespace gold
21 class Command_line;
23 namespace options {
25 class Command_line_options;
26 struct One_option;
28 } // End namespace gold::options.
30 // The position independent options which apply to the whole link.
31 // There are a lot of them.
33 class General_options
35 public:
36 General_options();
38 // -L: Library search path.
39 typedef std::list<const char*> Dir_list;
41 const Dir_list&
42 search_path() const
43 { return this->search_path_; }
45 // -o: Output file name.
46 const char*
47 output_file_name() const
48 { return this->output_file_name_; }
50 // -r: Whether we are doing a relocatable link.
51 bool
52 is_relocatable() const
53 { return this->is_relocatable_; }
55 // --static: Whether doing a static link.
56 bool
57 is_static() const
58 { return this->is_static_; }
60 private:
61 friend class Command_line;
62 friend class options::Command_line_options;
64 void
65 add_to_search_path(const char* arg)
66 { this->search_path_.push_back(arg); }
68 void
69 set_output_file_name(const char* arg)
70 { this->output_file_name_ = arg; }
72 void
73 set_relocatable()
74 { this->is_relocatable_ = true; }
76 void
77 set_static()
78 { this->is_static_ = true; }
80 Dir_list search_path_;
81 const char* output_file_name_;
82 bool is_relocatable_;
83 bool is_static_;
85 // Don't copy this structure.
86 General_options(const General_options&);
87 General_options& operator=(const General_options&);
90 // The current state of the position dependent options.
92 class Position_dependent_options
94 public:
95 Position_dependent_options();
97 // -Bstatic: Whether we are searching for a static archive rather
98 // -than a shared object.
99 bool
100 do_static_search()
101 { return this->do_static_search_; }
103 private:
104 friend class Command_line;
105 friend class options::Command_line_options;
107 void
108 set_static_search()
109 { this->do_static_search_ = true; }
111 void
112 set_dynamic_search()
113 { this->do_static_search_ = false; }
115 bool do_static_search_;
118 // A single file or library argument from the command line.
120 class Input_argument
122 public:
123 Input_argument(const char* name, bool is_lib,
124 const Position_dependent_options& options)
125 : name_(name), is_lib_(is_lib), options_(options)
128 const char*
129 name() const
130 { return this->name_; }
132 const Position_dependent_options&
133 options() const
134 { return this->options_; }
136 bool
137 is_lib() const
138 { return this->is_lib_; }
140 private:
141 const char* name_;
142 bool is_lib_;
143 Position_dependent_options options_;
146 // All the information read from the command line.
148 class Command_line
150 public:
151 Command_line();
153 // Process the command line options. This will exit with an
154 // appropriate error message if an unrecognized option is seen.
155 void
156 process(int argc, char** argv);
158 // Handle a -l option.
160 process_l_option(int, char**, char*);
162 // Get the general options.
163 const General_options&
164 options() const
165 { return this->options_; }
167 typedef std::list<Input_argument> Input_argument_list;
169 // Get the list of input files.
170 const Input_argument_list&
171 inputs() const
172 { return this->inputs_; }
174 private:
175 void usage() ATTRIBUTE_NORETURN;
176 void usage(const char* msg, const char* opt) ATTRIBUTE_NORETURN;
177 void usage(const char* msg, char opt) ATTRIBUTE_NORETURN;
178 void apply_option(const gold::options::One_option&, const char*);
180 General_options options_;
181 Position_dependent_options position_options_;
182 Input_argument_list inputs_;
185 } // End namespace gold.
187 #endif // !defined(GOLD_OPTIONS_H)