@@ -21,23 +21,24 @@ Author: CM Wintersteiger, 2006
2121
2222#include < iostream>
2323
24- #include < util/message.h>
25- #include < util/prefix.h>
2624#include < util/config.h>
25+ #include < util/file_util.h>
2726#include < util/get_base_name.h>
27+ #include < util/message.h>
28+ #include < util/prefix.h>
2829
2930#include " compile.h"
3031
31- // / does it.
32- static bool is_directory (const std::string &s)
32+ static bool has_directory_suffix (const std::string &path)
3333{
34- if (s. empty ())
35- return false ;
36- char last_char=s[s. size ()- 1 ];
37- // Visual CL recognizes both
38- return last_char ==' \\ ' || last_char ==' / ' ;
34+ // MS CL decides whether a parameter is a directory on the
35+ // basis of the / or \\ suffix; it doesn't matter
36+ // whether the directory actually exists.
37+ return path. empty () ? false :
38+ path. back () ==' / ' || path. back () ==' \\ ' ;
3939}
4040
41+ // / does it.
4142int ms_cl_modet::doit ()
4243{
4344 if (cmdline.isset (' ?' ) ||
@@ -103,24 +104,36 @@ int ms_cl_modet::doit()
103104
104105 if (cmdline.isset (" Fo" ))
105106 {
106- compiler. output_file_object = cmdline.get_value (" Fo" );
107+ std::string Fo_value = cmdline.get_value (" Fo" );
107108
108- // this could be a directory
109- if (is_directory (compiler.output_file_object ) &&
110- cmdline.args .size ()>=1 )
111- compiler.output_file_object +=
112- get_base_name (cmdline.args [0 ], true )+" .obj" ;
109+ // this could be a directory or a file name
110+ if (has_directory_suffix (Fo_value))
111+ {
112+ compiler.output_directory_object = Fo_value;
113+
114+ if (!is_directory (Fo_value))
115+ warning () << " not a directory: " << Fo_value << eom;
116+ }
117+ else
118+ compiler.output_file_object = Fo_value;
113119 }
114120
115121 if (cmdline.isset (" Fe" ))
116122 {
117123 compiler.output_file_executable =cmdline.get_value (" Fe" );
118124
119125 // this could be a directory
120- if (is_directory (compiler.output_file_executable ) &&
121- cmdline.args .size ()>=1 )
126+ if (
127+ has_directory_suffix (compiler.output_file_executable ) &&
128+ cmdline.args .size () >= 1 )
129+ {
130+ if (!is_directory (compiler.output_file_executable ))
131+ warning () << " not a directory: "
132+ << compiler.output_file_executable << eom;
133+
122134 compiler.output_file_executable +=
123- get_base_name (cmdline.args [0 ], true )+" .exe" ;
135+ get_base_name (cmdline.args [0 ], true ) + " .exe" ;
136+ }
124137 }
125138 else
126139 {
0 commit comments