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.
|
2009-08-12 22:10:57 +00:00
|
|
|
static std::string GetDirSeparator() {
|
2009-08-27 12:02:34 +00:00
|
|
|
#ifdef _WIN32
|
2009-07-09 08:17:55 +00:00
|
|
|
return "\\";
|
2009-08-27 12:02:34 +00:00
|
|
|
#else
|
|
|
|
return "/";
|
2009-07-09 08:17:55 +00:00
|
|
|
#endif
|
2009-07-01 16:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace hooks {
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where c16 executables reside.
|
2009-08-12 22:10:57 +00:00
|
|
|
std::string GetBinDir() {
|
2009-07-01 16:10:29 +00:00
|
|
|
// 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-08-12 22:10:57 +00:00
|
|
|
std::string GetInstallDir() {
|
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-08-12 22:10:57 +00:00
|
|
|
std::string GetStdHeadersDir() {
|
2009-07-01 16:10:29 +00:00
|
|
|
return GetInstallDir() + "include";
|
|
|
|
}
|
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where the assembler header files reside.
|
2009-08-12 22:10:57 +00:00
|
|
|
std::string GetStdAsmHeadersDir() {
|
2009-07-01 16:10:29 +00:00
|
|
|
return GetInstallDir() + "inc";
|
|
|
|
}
|
2009-07-02 17:35:38 +00:00
|
|
|
|
|
|
|
// Get the dir where the linker scripts reside.
|
2009-08-12 22:10:57 +00:00
|
|
|
std::string GetStdLinkerScriptsDir() {
|
2009-07-01 16:10:29 +00:00
|
|
|
return GetInstallDir() + "lkr";
|
|
|
|
}
|
|
|
|
|
2009-07-02 17:35:38 +00:00
|
|
|
// Get the dir where startup code, intrinsics and lib reside.
|
2009-08-12 22:10:57 +00:00
|
|
|
std::string GetStdLibsDir() {
|
2009-07-01 16:10:29 +00:00
|
|
|
return GetInstallDir() + "lib";
|
|
|
|
}
|
|
|
|
}
|