goto-cl: /Fo can set an output directory

This commit is contained in:
Daniel Kroening 2018-07-24 22:27:47 +01:00
parent a43e4fad96
commit 5bc7456787
9 changed files with 78 additions and 21 deletions

View File

@ -63,6 +63,7 @@ phases:
- |
$env:Path = "C:\tools\cygwin\bin;$env:Path"
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C regression test BUILD_ENV=MSVC" '
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C regression/goto-cl test BUILD_ENV=MSVC" '
- |
$env:Path = "C:\tools\cygwin\bin;$env:Path"

View File

@ -0,0 +1,8 @@
CORE
/c main1.c main2.c /Fodir/
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^CONVERSION ERROR$

View File

@ -0,0 +1 @@
// blank

View File

@ -0,0 +1 @@
// blank

View File

@ -0,0 +1 @@
// blank

View File

@ -0,0 +1,21 @@
default: tests.log
test:
@../test.pl -p -c ../../../src/goto-cc/goto-cl
tests.log: ../test.pl
@../test.pl -p -c ../../../src/goto-cc/goto-cl
show:
@for dir in *; do \
if [ -d "$$dir" ]; then \
vim -o "$$dir/*.c" "$$dir/*.out"; \
fi; \
done;
clean:
find -name '*.out' -execdir $(RM) '{}' \;
find -name '*.gb' -execdir $(RM) '{}' \;
find -name '*.obj' -execdir $(RM) '{}' \;
find -name '*.goto-cc-saved' -execdir $(RM) '{}' \;
$(RM) tests.log

View File

@ -421,9 +421,17 @@ bool compilet::compile()
std::string cfn;
if(output_file_object=="")
cfn=get_base_name(file_name, true)+"."+object_file_extension;
{
const std::string file_name_with_obj_ext =
get_base_name(file_name, true) + "." + object_file_extension;
if(!output_directory_object.empty())
cfn = concat_dir_file(output_directory_object, file_name_with_obj_ext);
else
cfn = file_name_with_obj_ext;
}
else
cfn=output_file_object;
cfn = output_file_object;
if(write_object_file(cfn, symbol_table, compiled_functions))
return true;

View File

@ -45,7 +45,10 @@ public:
std::list<irep_idt> seen_modes;
std::string object_file_extension;
std::string output_file_object, output_file_executable;
std::string output_file_executable;
// the two options below are mutually exclusive -- use either or
std::string output_file_object, output_directory_object;
compilet(cmdlinet &_cmdline, ui_message_handlert &mh, bool Werror);

View File

@ -21,23 +21,24 @@ Author: CM Wintersteiger, 2006
#include <iostream>
#include <util/config.h>
#include <util/file_util.h>
#include <util/get_base_name.h>
#include <util/message.h>
#include <util/prefix.h>
#include <util/config.h>
#include <util/get_base_name.h>
#include "compile.h"
/// does it.
static bool is_directory(const std::string &s)
static bool has_directory_suffix(const std::string &path)
{
if(s.empty())
return false;
char last_char=s[s.size()-1];
// Visual CL recognizes both
return last_char=='\\' || last_char=='/';
// MS CL decides whether a parameter is a directory on the
// basis of the / or \\ suffix; it doesn't matter
// whether the directory actually exists.
return path.empty() ? false :
path.back()=='/' || path.back()=='\\';
}
/// does it.
int ms_cl_modet::doit()
{
if(cmdline.isset('?') ||
@ -103,13 +104,18 @@ int ms_cl_modet::doit()
if(cmdline.isset("Fo"))
{
compiler.output_file_object=cmdline.get_value("Fo");
std::string Fo_value = cmdline.get_value("Fo");
// this could be a directory
if(is_directory(compiler.output_file_object) &&
cmdline.args.size()>=1)
compiler.output_file_object+=
get_base_name(cmdline.args[0], true)+".obj";
// this could be a directory or a file name
if(has_directory_suffix(Fo_value))
{
compiler.output_directory_object = Fo_value;
if(!is_directory(Fo_value))
warning() << "not a directory: " << Fo_value << eom;
}
else
compiler.output_file_object = Fo_value;
}
if(cmdline.isset("Fe"))
@ -117,10 +123,17 @@ int ms_cl_modet::doit()
compiler.output_file_executable=cmdline.get_value("Fe");
// this could be a directory
if(is_directory(compiler.output_file_executable) &&
cmdline.args.size()>=1)
if(
has_directory_suffix(compiler.output_file_executable) &&
cmdline.args.size() >= 1)
{
if(!is_directory(compiler.output_file_executable))
warning() << "not a directory: "
<< compiler.output_file_executable << eom;
compiler.output_file_executable+=
get_base_name(cmdline.args[0], true)+".exe";
get_base_name(cmdline.args[0], true) + ".exe";
}
}
else
{