Files
llvm/lib/Support/SystemUtils.cpp
T

56 lines
2.1 KiB
C++
Raw Normal View History

2004-06-18 15:38:49 +00:00
//===- SystemUtils.cpp - Utilities for low-level system tasks -------------===//
2005-04-21 22:55:34 +00:00
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
2005-04-21 22:55:34 +00:00
//
//===----------------------------------------------------------------------===//
2002-12-23 23:50:16 +00:00
//
// This file contains functions used to do a variety of low-level, often
// system-specific, tasks.
//
//===----------------------------------------------------------------------===//
2004-09-01 22:55:40 +00:00
#include "llvm/Support/SystemUtils.h"
#include "llvm/System/Process.h"
2005-04-22 19:13:22 +00:00
#include "llvm/System/Program.h"
#include "llvm/Support/raw_ostream.h"
2003-12-14 21:35:53 +00:00
using namespace llvm;
bool llvm::CheckBitcodeOutputToConsole(raw_ostream &stream_to_check,
bool print_warning) {
if (stream_to_check.is_displayed()) {
if (print_warning) {
errs() << "WARNING: You're attempting to print out a bitcode file.\n"
<< "This is inadvisable as it may cause display problems. If\n"
<< "you REALLY want to taste LLVM bitcode first-hand, you\n"
<< "can force output with the `-f' option.\n\n";
}
return true;
}
return false;
}
/// FindExecutable - Find a named executable, giving the argv[0] of program
/// being executed. This allows us to find another LLVM tool if it is built in
/// the same directory. If the executable cannot be found, return an
/// empty string.
/// @brief Find a named executable.
#undef FindExecutable // needed on windows :(
2004-12-13 23:41:37 +00:00
sys::Path llvm::FindExecutable(const std::string &ExeName,
const char *Argv0, void *MainAddr) {
// Check the directory that the calling program is in. We can do
// this if ProgramPath contains at least one / character, indicating that it
2009-07-12 20:23:56 +00:00
// is a relative path to the executable itself.
sys::Path Result = sys::Path::GetMainExecutable(Argv0, MainAddr);
2005-07-07 23:21:43 +00:00
Result.eraseComponent();
2004-12-13 23:41:37 +00:00
if (!Result.isEmpty()) {
2005-07-07 23:21:43 +00:00
Result.appendComponent(ExeName);
2005-07-07 18:21:42 +00:00
if (Result.canExecute())
2004-12-19 18:00:09 +00:00
return Result;
2002-12-23 23:50:16 +00:00
}
return sys::Path();
2002-12-23 23:50:16 +00:00
}