1 | /* |
---|
2 | * Copyright (c) 2011-2014, Chris Johns <chrisj@rtems.org> |
---|
3 | * |
---|
4 | * Permission to use, copy, modify, and/or distribute this software for any |
---|
5 | * purpose with or without fee is hereby granted, provided that the above |
---|
6 | * copyright notice and this permission notice appear in all copies. |
---|
7 | * |
---|
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
---|
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
---|
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
---|
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
---|
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
15 | */ |
---|
16 | /** |
---|
17 | * @file |
---|
18 | * |
---|
19 | * @ingroup rtems-ld |
---|
20 | * |
---|
21 | * @brief Various calls to CC. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #if !defined (_RLD_CC_H_) |
---|
26 | #define _RLD_CC_H_ |
---|
27 | |
---|
28 | #include <string> |
---|
29 | |
---|
30 | #include <rld-files.h> |
---|
31 | #include <rld-process.h> |
---|
32 | |
---|
33 | namespace rld |
---|
34 | { |
---|
35 | namespace cc |
---|
36 | { |
---|
37 | /* |
---|
38 | * The type of flags. |
---|
39 | */ |
---|
40 | enum flag_type |
---|
41 | { |
---|
42 | ft_cppflags = 1 << 0, |
---|
43 | ft_cflags = 1 << 1, |
---|
44 | ft_cxxflags = 1 << 2, |
---|
45 | ft_ldflags = 1 << 3 |
---|
46 | }; |
---|
47 | |
---|
48 | /* |
---|
49 | * Flags groups. |
---|
50 | */ |
---|
51 | enum flag_group |
---|
52 | { |
---|
53 | fg_warning_flags, |
---|
54 | fg_include_flags, |
---|
55 | fg_machine_flags, |
---|
56 | fg_spec_flags |
---|
57 | }; |
---|
58 | |
---|
59 | /** |
---|
60 | * Strip the flags of -O and -g options. |
---|
61 | * |
---|
62 | * @param flags The flags a space delimited list to strip. |
---|
63 | * @return const std::string The stripped flags. |
---|
64 | */ |
---|
65 | const std::string strip_cflags (const std::string& flags); |
---|
66 | |
---|
67 | /** |
---|
68 | * Filter the flags. Provide the type of flags being passed, the flags as a |
---|
69 | * space separated list, the architure, and a path. Provide strings |
---|
70 | * containers for the different flag groups so they can be sorted and |
---|
71 | * returned. |
---|
72 | * |
---|
73 | * @param flags The flags a space delimited list to strip. |
---|
74 | * @param arch The architecure per the OS specific name. |
---|
75 | * @param path A path to adjust based on the architecture. |
---|
76 | * @param type The type of flags being passed. |
---|
77 | * @param warnings Return warning flags in this string. |
---|
78 | * @param includes Return include flags in this string. |
---|
79 | * @param machines Return machine flags in this string. |
---|
80 | * @param specs Return spec flags in this string. |
---|
81 | * @return const std::string The filtered flags. |
---|
82 | */ |
---|
83 | const std::string filter_flags (const std::string& flags, |
---|
84 | const std::string& arch, |
---|
85 | const std::string& path, |
---|
86 | flag_type type, |
---|
87 | std::string& warnings, |
---|
88 | std::string& includes, |
---|
89 | std::string& machines, |
---|
90 | std::string& specs); |
---|
91 | |
---|
92 | /** |
---|
93 | * Filter the cflags and update the warnings, includes, machines and specs |
---|
94 | * if the type of flags is cflags. Provide the cflags as a space separated |
---|
95 | * list, the architure, and a path. |
---|
96 | * |
---|
97 | * @param flags The flags a space delimited list to strip. |
---|
98 | * @param arch The architecure per the OS specific name. |
---|
99 | * @param path A path to adjust based on the architecture. |
---|
100 | * @param type The type of flags being passed. |
---|
101 | * @return const std::string The filtered flags. |
---|
102 | */ |
---|
103 | const std::string filter_flags (const std::string& flags, |
---|
104 | const std::string& arch, |
---|
105 | const std::string& path, |
---|
106 | flag_type type); |
---|
107 | |
---|
108 | /** |
---|
109 | * Set CC. The exec-prefix is ignored if this is set. |
---|
110 | */ |
---|
111 | void set_cc (const std::string& cc); |
---|
112 | |
---|
113 | /** |
---|
114 | * Get the CC. |
---|
115 | */ |
---|
116 | const std::string get_cc (); |
---|
117 | |
---|
118 | /** |
---|
119 | * Is the CC set ? |
---|
120 | */ |
---|
121 | bool is_cc_set (); |
---|
122 | |
---|
123 | /** |
---|
124 | * Set LD. The exec-prefix is ignored if this is set. |
---|
125 | */ |
---|
126 | void set_ld (const std::string& ld); |
---|
127 | |
---|
128 | /** |
---|
129 | * Get the LD. |
---|
130 | */ |
---|
131 | const std::string get_ld (); |
---|
132 | |
---|
133 | /** |
---|
134 | * Is the LD set ? |
---|
135 | */ |
---|
136 | bool is_ld_set (); |
---|
137 | |
---|
138 | /** |
---|
139 | * Set the exec-prefix. If CC is set the exec-prefix is ignored. |
---|
140 | */ |
---|
141 | void set_exec_prefix (const std::string& exec_prefix); |
---|
142 | |
---|
143 | /** |
---|
144 | * Get the exec-prefix. |
---|
145 | */ |
---|
146 | const std::string get_exec_prefix (); |
---|
147 | |
---|
148 | /** |
---|
149 | * Is exec-prefix set ? |
---|
150 | */ |
---|
151 | bool is_exec_prefix_set (); |
---|
152 | |
---|
153 | /** |
---|
154 | * Set the flags with a specific arch and include path. |
---|
155 | */ |
---|
156 | void set_flags (const std::string& flags, |
---|
157 | const std::string& arch, |
---|
158 | const std::string& path, |
---|
159 | flag_type type); |
---|
160 | |
---|
161 | /** |
---|
162 | * Set the flags. |
---|
163 | */ |
---|
164 | void set_flags (const std::string& flags, flag_type type); |
---|
165 | |
---|
166 | /** |
---|
167 | * Append the flags with a specific arch and include path. |
---|
168 | */ |
---|
169 | void append_flags (const std::string& flags, |
---|
170 | const std::string& arch, |
---|
171 | const std::string& path, |
---|
172 | flag_type type); |
---|
173 | |
---|
174 | /** |
---|
175 | * Append the flags. |
---|
176 | */ |
---|
177 | void append_flags (const std::string& flags, flag_type type); |
---|
178 | |
---|
179 | /** |
---|
180 | * Get the flags. |
---|
181 | */ |
---|
182 | const std::string get_flags (flag_type type); |
---|
183 | const std::string get_flags (flag_group group); |
---|
184 | |
---|
185 | /** |
---|
186 | * Append the flags if set. |
---|
187 | */ |
---|
188 | void append_flags (flag_type type, rld::process::arg_container& args); |
---|
189 | |
---|
190 | /** |
---|
191 | * Make a CC command from the set arguments. |
---|
192 | */ |
---|
193 | void make_cc_command (rld::process::arg_container& args); |
---|
194 | |
---|
195 | /** |
---|
196 | * Make a LD command from the set arguments. |
---|
197 | */ |
---|
198 | void make_ld_command (rld::process::arg_container& args); |
---|
199 | |
---|
200 | /** |
---|
201 | * Get the standard libraries paths from the compiler. |
---|
202 | */ |
---|
203 | void get_standard_libpaths (rld::path::paths& libpaths); |
---|
204 | |
---|
205 | /** |
---|
206 | * Get the standard libraries. Optionally add the C++ library. |
---|
207 | */ |
---|
208 | void get_standard_libs (rld::path::paths& libs, |
---|
209 | rld::path::paths& libpaths, |
---|
210 | bool cpp = false); |
---|
211 | |
---|
212 | } |
---|
213 | } |
---|
214 | |
---|
215 | #endif |
---|