ldc/driver/tool.cpp
kai f1c71e4bac Make ldc compatible with LLVM 3.4
Development of LLVM 3.4 started with a cleanup of the path class (PathV1).
The changes here let ldc compile at least with rev. 184039 of LLVM.
2013-06-15 19:52:29 +02:00

51 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//===-- tool.cpp ----------------------------------------------------------===//
//
// LDC the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
#include "driver/tool.h"
#include "mars.h"
#include "llvm/Support/Program.h"
int executeToolAndWait(llvm::sys::Path tool, std::vector<std::string> const & args, bool verbose)
{
// Construct real argument list.
// First entry is the tool itself, last entry must be NULL.
std::vector<const char *> realargs;
realargs.reserve(args.size() + 2);
realargs.push_back(tool.c_str());
for (std::vector<std::string>::const_iterator it = args.begin(); it != args.end(); ++it)
{
realargs.push_back((*it).c_str());
}
realargs.push_back(NULL);
// Print command line if requested
if (verbose)
{
// Print it
for (size_t i = 0; i < realargs.size()-1; i++)
printf("%s ", realargs[i]);
printf("\n");
fflush(stdout);
}
// Execute tool.
std::string errstr;
#if LDC_LLVM_VER >= 304
if (int status = llvm::sys::ExecuteAndWait(tool.str(), &realargs[0], NULL, NULL, 0, 0, &errstr))
#else
if (int status = llvm::sys::Program::ExecuteAndWait(tool, &realargs[0], NULL, NULL, 0, 0, &errstr))
#endif
{
error("%s failed with status: %d", tool.c_str(), status);
if (!errstr.empty())
error("message: %s", errstr.c_str());
return status;
}
return 0;
}