cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
armcc_mode.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Command line option container
4
5
Author: CM Wintersteiger, 2006
6
7
\*******************************************************************/
8
11
12
#include "
armcc_mode.h
"
13
14
#ifdef _WIN32
15
#define EX_OK 0
16
#define EX_USAGE 64
17
#define EX_SOFTWARE 70
18
#else
19
#include <sysexits.h>
20
#endif
21
22
#include <iostream>
23
24
#include <
util/message.h
>
25
#include <
util/config.h
>
26
27
#include "
compile.h
"
28
30
int
armcc_modet::doit
()
31
{
32
if
(
cmdline
.isset(
'?'
) ||
cmdline
.isset(
"help"
))
33
{
34
help
();
35
return
EX_OK;
36
}
37
38
compilet
compiler(
cmdline
,
message_handler
,
cmdline
.isset(
"diag_error="
));
39
40
#if 0
41
bool
act_as_ld=
42
has_prefix
(
base_name
,
"ld"
) ||
43
has_prefix
(
base_name
,
"goto-ld"
) ||
44
has_prefix
(
base_name
,
"link"
) ||
45
has_prefix
(
base_name
,
"goto-link"
);
46
#endif
47
48
const
auto
default_verbosity =
49
cmdline
.isset(
"diag_warning="
) ?
messaget::M_WARNING
:
messaget::M_ERROR
;
50
const
auto
verbosity =
messaget::eval_verbosity
(
51
cmdline
.get_value(
"verbosity"
), default_verbosity,
message_handler
);
52
message_handler
.print_warnings_as_errors(
cmdline
.isset(
"diag_error="
));
53
54
messaget
log{
message_handler
};
55
log.
debug
() <<
"ARM mode"
<<
messaget::eom
;
56
57
// model validation
58
compiler.
validate_goto_model
=
cmdline
.isset(
"validate-goto-model"
);
59
60
// get configuration
61
config
.set(
cmdline
);
62
63
config
.ansi_c.mode=
configt::ansi_ct::flavourt::ARM
;
64
config
.ansi_c.arch=
"arm"
;
65
66
// determine actions to be taken
67
68
if
(
cmdline
.isset(
'E'
))
69
compiler.
mode
=
compilet::PREPROCESS_ONLY
;
70
else
if
(
cmdline
.isset(
'c'
) ||
cmdline
.isset(
'S'
))
71
compiler.
mode
=
compilet::COMPILE_ONLY
;
72
else
73
compiler.
mode
=
compilet::COMPILE_LINK_EXECUTABLE
;
74
75
if
(
cmdline
.isset(
'U'
))
76
config
.ansi_c.undefines=
cmdline
.get_values(
'U'
);
77
78
if
(
cmdline
.isset(
'L'
))
79
compiler.
library_paths
=
cmdline
.get_values(
'L'
);
80
// Don't add the system paths!
81
82
// these take precedence over -I
83
if
(
cmdline
.isset(
'J'
))
84
{
85
const
std::list<std::string> &values=
86
cmdline
.get_values(
'J'
);
87
88
for
(std::list<std::string>::const_iterator
89
it=values.begin();
90
it!=values.end();
91
it++)
92
config
.ansi_c.preprocessor_options.push_back(
"-J"
+*it);
93
}
94
95
if
(
cmdline
.isset(
"preinclude="
))
96
{
97
const
std::list<std::string> &values=
98
cmdline
.get_values(
"preinclude="
);
99
100
for
(std::list<std::string>::const_iterator
101
it=values.begin();
102
it!=values.end();
103
it++)
104
config
.ansi_c.preprocessor_options.push_back(
"--preinclude="
+*it);
105
}
106
107
// armcc's default is .o
108
compiler.
object_file_extension
=
109
cmdline
.value_opt(
"default_extension="
).value_or(
"o"
);
110
111
// note that ARM's default is "unsigned_chars",
112
// in contrast to gcc's default!
113
if
(
cmdline
.isset(
"signed_chars"
))
114
config
.ansi_c.char_is_unsigned=
false
;
115
else
116
config
.ansi_c.char_is_unsigned=
true
;
117
118
// ARM's default is 16 bits for wchar_t
119
if
(
cmdline
.isset(
"wchar32"
))
120
config
.ansi_c.wchar_t_width=32;
121
else
122
config
.ansi_c.wchar_t_width=16;
123
124
if
(
cmdline
.isset(
'o'
))
125
{
126
// given goto-armcc -o file1 -o file2, we output to file2, not file1
127
compiler.
output_file_object
=
cmdline
.get_values(
'o'
).back();
128
compiler.
output_file_executable
=
cmdline
.get_values(
'o'
).back();
129
}
130
else
131
{
132
compiler.
output_file_object
.clear();
133
compiler.
output_file_executable
=
"a.out"
;
134
}
135
136
if
(verbosity >
messaget::M_STATISTICS
)
137
{
138
std::list<std::string>::iterator it;
139
140
std::cout <<
"Defines:\n"
;
141
for
(it=
config
.ansi_c.defines.begin();
142
it!=
config
.ansi_c.defines.end();
143
it++)
144
{
145
std::cout <<
" "
<< (*it) <<
'\n'
;
146
}
147
148
std::cout <<
"Undefines:\n"
;
149
for
(it=
config
.ansi_c.undefines.begin();
150
it!=
config
.ansi_c.undefines.end();
151
it++)
152
{
153
std::cout <<
" "
<< (*it) <<
'\n'
;
154
}
155
156
std::cout <<
"Preprocessor Options:\n"
;
157
for
(it=
config
.ansi_c.preprocessor_options.begin();
158
it!=
config
.ansi_c.preprocessor_options.end();
159
it++)
160
{
161
std::cout <<
" "
<< (*it) <<
'\n'
;
162
}
163
164
std::cout <<
"Include Paths:\n"
;
165
for
(it=
config
.ansi_c.include_paths.begin();
166
it!=
config
.ansi_c.include_paths.end();
167
it++)
168
{
169
std::cout <<
" "
<< (*it) <<
'\n'
;
170
}
171
172
std::cout <<
"Library Paths:\n"
;
173
for
(it=compiler.
library_paths
.begin();
174
it!=compiler.
library_paths
.end();
175
it++)
176
{
177
std::cout <<
" "
<< (*it) <<
'\n'
;
178
}
179
180
std::cout <<
"Output file (object): "
181
<< compiler.
output_file_object
<<
'\n'
;
182
std::cout <<
"Output file (executable): "
183
<< compiler.
output_file_executable
<<
'\n'
;
184
}
185
186
// Parse input program, convert to goto program, write output
187
return
compiler.
doit
() ? EX_USAGE : EX_OK;
188
}
189
191
void
armcc_modet::help_mode
()
192
{
193
std::cout <<
"goto-armcc understands the options "
194
<<
"of armcc plus the following.\n\n"
;
195
}
config
configt config
Definition
config.cpp:25
armcc_mode.h
Base class for command line interpretation for CL.
armcc_modet::message_handler
gcc_message_handlert message_handler
Definition
armcc_mode.h:37
armcc_modet::doit
int doit() final
does it.
Definition
armcc_mode.cpp:30
armcc_modet::cmdline
armcc_cmdlinet & cmdline
Definition
armcc_mode.h:36
armcc_modet::help_mode
void help_mode() final
display command line help
Definition
armcc_mode.cpp:191
compilet
Definition
compile.h:32
compilet::PREPROCESS_ONLY
@ PREPROCESS_ONLY
Definition
compile.h:38
compilet::COMPILE_LINK_EXECUTABLE
@ COMPILE_LINK_EXECUTABLE
Definition
compile.h:43
compilet::COMPILE_ONLY
@ COMPILE_ONLY
Definition
compile.h:39
compilet::output_file_object
std::string output_file_object
Definition
compile.h:55
compilet::doit
bool doit()
reads and source and object files, compiles and links them into goto program objects.
Definition
compile.cpp:54
compilet::object_file_extension
std::string object_file_extension
Definition
compile.h:51
compilet::validate_goto_model
bool validate_goto_model
Definition
compile.h:36
compilet::mode
enum compilet::@010007010156070135133373264143331307343141370152 mode
compilet::library_paths
std::list< std::string > library_paths
Definition
compile.h:46
compilet::output_file_executable
std::string output_file_executable
Definition
compile.h:52
goto_cc_modet::base_name
const std::string base_name
Definition
goto_cc_mode.h:39
goto_cc_modet::help
void help()
display command line help
Definition
goto_cc_mode.cpp:48
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition
message.h:154
messaget::eval_verbosity
static unsigned eval_verbosity(const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest.
Definition
message.cpp:105
messaget::debug
mstreamt & debug() const
Definition
message.h:421
messaget::M_STATISTICS
@ M_STATISTICS
Definition
message.h:170
messaget::M_ERROR
@ M_ERROR
Definition
message.h:169
messaget::M_WARNING
@ M_WARNING
Definition
message.h:169
messaget::eom
static eomt eom
Definition
message.h:289
compile.h
Compile and link source and object files.
config.h
has_prefix
bool has_prefix(const std::string &s, const std::string &prefix)
Definition
converter.cpp:13
message.h
configt::ansi_ct::flavourt::ARM
@ ARM
Definition
config.h:275
goto-cc
armcc_mode.cpp
Generated by
1.17.0