2009-06-07 07:08:01 +00:00
|
|
|
#include "AutoGenerated.inc"
|
2009-07-02 17:35:38 +00:00
|
|
|
|
2009-07-01 16:10:29 +00:00
|
|
|
#include "llvm/System/Path.h"
|
2009-07-02 17:35:38 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
2009-07-01 16:10:29 +00:00
|
|
|
|
|
|
|
namespace llvmc {
|
|
|
|
extern char *ProgramName;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the platform specific directory separator via #ifdefs.
|
|
|
|
static std::string GetDirSeparator(void) {
|
|
|
|
return "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace hooks {
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where c16 executables reside.
|
2009-07-01 16:10:29 +00:00
|
|
|
std::string GetBinDir (void) {
|
|
|
|
// Construct a Path object from the program name.
|
2009-07-02 17:35:38 +00:00
|
|
|
void *P = (void*) (intptr_t) GetBinDir;
|
|
|
|
sys::Path ProgramFullPath
|
|
|
|
= sys::Path::GetMainExecutable(llvmc::ProgramName, P);
|
2009-07-01 16:10:29 +00:00
|
|
|
|
|
|
|
// Get the dir name for the program. It's last component should be 'bin'.
|
2009-07-02 17:35:38 +00:00
|
|
|
std::string BinDir = ProgramFullPath.getDirname();
|
2009-07-01 16:10:29 +00:00
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// llvm::errs() << "BinDir: " << BinDir << '\n';
|
2009-07-01 16:10:29 +00:00
|
|
|
return BinDir + GetDirSeparator();
|
|
|
|
}
|
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the Top-level Installation dir for c16.
|
2009-07-01 16:10:29 +00:00
|
|
|
std::string GetInstallDir (void) {
|
2009-07-02 17:35:38 +00:00
|
|
|
sys::Path BinDirPath = sys::Path(GetBinDir());
|
2009-07-01 16:10:29 +00:00
|
|
|
|
|
|
|
// Go one more level up to get the install dir.
|
|
|
|
std::string InstallDir = BinDirPath.getDirname();
|
|
|
|
|
|
|
|
return InstallDir + GetDirSeparator();
|
|
|
|
}
|
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where the c16 header files reside.
|
2009-07-01 16:10:29 +00:00
|
|
|
std::string GetStdHeadersDir (void) {
|
|
|
|
return GetInstallDir() + "include";
|
|
|
|
}
|
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where the assembler header files reside.
|
2009-07-01 16:10:29 +00:00
|
|
|
std::string GetStdAsmHeadersDir (void) {
|
|
|
|
return GetInstallDir() + "inc";
|
|
|
|
}
|
2009-07-02 17:35:38 +00:00
|
|
|
|
|
|
|
// Get the dir where the linker scripts reside.
|
2009-07-01 16:10:29 +00:00
|
|
|
std::string GetStdLinkerScriptsDir (void) {
|
|
|
|
return GetInstallDir() + "lkr";
|
|
|
|
}
|
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where startup code, intrinsics and lib reside.
|
2009-07-01 16:10:29 +00:00
|
|
|
std::string GetStdLibsDir (void) {
|
|
|
|
return GetInstallDir() + "lib";
|
|
|
|
}
|
|
|
|
}
|