cprover
ms_link_mode.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Visual Studio Link Mode
4
5
Author: Daniel Kroening
6
7
\*******************************************************************/
8
11
12
#include "
ms_link_mode.h
"
13
14
#include <iostream>
15
16
#include <
util/config.h
>
17
#include <
util/get_base_name.h
>
18
19
ms_link_modet::ms_link_modet
(
goto_cc_cmdlinet
&_cmdline)
20
:
goto_cc_modet
(_cmdline,
"link"
, message_handler)
21
{
22
}
23
25
int
ms_link_modet::doit
()
26
{
27
if
(
cmdline
.
isset
(
"help"
))
28
{
29
help
();
30
return
0;
31
}
32
33
eval_verbosity
(
34
cmdline
.
get_value
(
"verbosity"
),
messaget::M_ERROR
,
message_handler
);
35
36
compilet
compiler(
cmdline
,
message_handler
,
false
);
37
38
// determine actions to be undertaken
39
compiler.mode =
compilet::LINK_LIBRARY
;
40
41
// get configuration
42
config
.
set
(
cmdline
);
43
44
compiler.object_file_extension =
"obj"
;
45
46
if
(
cmdline
.
isset
(
"LIBPATH"
))
47
compiler.library_paths =
cmdline
.
get_values
(
"LIBPATH"
);
48
// Don't add the system paths!
49
50
if
(
cmdline
.
isset
(
"OUT"
))
51
{
52
// This must be a file, not a directory.
53
// If the option is given multiple times, the last instance wins.
54
const
auto
&values =
cmdline
.
get_values
(
"OUT"
);
55
if
(!values.empty())
56
compiler.output_file_executable = values.back();
57
}
58
else
59
{
60
// The first input file is used to determine the default
61
// name of the executable.
62
if
(!
cmdline
.
args
.empty())
63
compiler.output_file_executable =
get_base_name
(
cmdline
.
args
[0],
true
)+
".exe"
;
64
}
65
66
// We now iterate over any input files
67
68
for
(
const
auto
&arg :
cmdline
.
parsed_argv
)
69
if
(arg.is_infile_name)
70
compiler.add_input_file(arg.arg);
71
72
// do all the rest
73
if
(compiler.doit())
74
return
1;
75
76
return
0;
77
}
78
80
void
ms_link_modet::help_mode
()
81
{
82
std::cout <<
"goto-link understands the options of "
83
<<
"link plus the following.\n\n"
;
84
}
cmdlinet::args
argst args
Definition:
cmdline.h:44
get_base_name
std::string get_base_name(const std::string &in, bool strip_suffix)
cleans a filename from path and extension
Definition:
get_base_name.cpp:16
goto_cc_cmdlinet::parsed_argv
parsed_argvt parsed_argv
Definition:
goto_cc_cmdline.h:63
cmdlinet::isset
virtual bool isset(char option) const
Definition:
cmdline.cpp:27
messaget::M_ERROR
Definition:
message.h:160
cmdlinet::get_value
std::string get_value(char option) const
Definition:
cmdline.cpp:45
ms_link_mode.h
get_base_name.h
goto_cc_modet::cmdline
goto_cc_cmdlinet & cmdline
Definition:
goto_cc_mode.h:37
config
configt config
Definition:
config.cpp:24
ms_link_modet::message_handler
console_message_handlert message_handler
Definition:
ms_link_mode.h:31
configt::set
bool set(const cmdlinet &cmdline)
Definition:
config.cpp:767
goto_cc_modet
Definition:
goto_cc_mode.h:21
ms_link_modet::doit
int doit() final
does it.
Definition:
ms_link_mode.cpp:25
compilet::LINK_LIBRARY
Definition:
compile.h:40
config.h
ms_link_modet::help_mode
void help_mode() final
display command line help
Definition:
ms_link_mode.cpp:80
goto_cc_modet::help
virtual void help()
display command line help
Definition:
goto_cc_mode.cpp:47
compilet
Definition:
compile.h:25
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:98
ms_link_modet::ms_link_modet
ms_link_modet(goto_cc_cmdlinet &)
Definition:
ms_link_mode.cpp:19
cmdlinet::get_values
const std::list< std::string > & get_values(const std::string &option) const
Definition:
cmdline.cpp:110
goto_cc_cmdlinet
Definition:
goto_cc_cmdline.h:19
goto-cc
ms_link_mode.cpp
Generated by
1.8.16