mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
Use FindExecutable as a fall-back search method.
Allows us to find executables that are in the same directory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include "llvm/CompilerDriver/BuiltinOptions.h"
|
#include "llvm/CompilerDriver/BuiltinOptions.h"
|
||||||
|
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include "llvm/Support/SystemUtils.h"
|
||||||
#include "llvm/System/Program.h"
|
#include "llvm/System/Program.h"
|
||||||
#include "llvm/System/TimeValue.h"
|
#include "llvm/System/TimeValue.h"
|
||||||
|
|
||||||
@@ -24,13 +25,23 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvmc;
|
using namespace llvmc;
|
||||||
|
|
||||||
|
namespace llvmc {
|
||||||
|
|
||||||
|
extern int Main(int argc, char** argv);
|
||||||
|
extern const char* ProgramName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int ExecuteProgram(const std::string& name,
|
int ExecuteProgram(const std::string& name,
|
||||||
const StrVector& args) {
|
const StrVector& args) {
|
||||||
sys::Path prog = sys::Program::FindProgramByName(name);
|
sys::Path prog = sys::Program::FindProgramByName(name);
|
||||||
|
|
||||||
if (prog.isEmpty())
|
if (prog.isEmpty()) {
|
||||||
throw std::runtime_error("Can't find program '" + name + "'");
|
prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main);
|
||||||
|
if (prog.isEmpty())
|
||||||
|
throw std::runtime_error("Can't find program '" + name + "'");
|
||||||
|
}
|
||||||
if (!prog.canExecute())
|
if (!prog.canExecute())
|
||||||
throw std::runtime_error("Program '" + name + "' is not executable.");
|
throw std::runtime_error("Program '" + name + "' is not executable.");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user