diff options
Diffstat (limited to 'tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp')
-rw-r--r-- | tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp index add8acb4a5..09fb9695e9 100644 --- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp +++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp @@ -1 +1,48 @@ #include "AutoGenerated.inc" +#include "llvm/System/Path.h" + +namespace llvmc { + extern char *ProgramName; +} + +// Returns the platform specific directory separator via #ifdefs. +static std::string GetDirSeparator(void) { + return "/"; +} + +namespace hooks { +std::string GetBinDir (void) { + // Construct a Path object from the program name. + llvm::sys::Path ProgramFullName(llvmc::ProgramName, + strlen(llvmc::ProgramName)); + + // Get the dir name for the program. It's last component should be 'bin'. + std::string BinDir = ProgramFullName.getDirname(); + + return BinDir + GetDirSeparator(); +} + +std::string GetInstallDir (void) { + llvm::sys::Path BinDirPath = llvm::sys::Path(GetBinDir()); + + // Go one more level up to get the install dir. + std::string InstallDir = BinDirPath.getDirname(); + + return InstallDir + GetDirSeparator(); +} + +std::string GetStdHeadersDir (void) { + return GetInstallDir() + "include"; +} + +std::string GetStdAsmHeadersDir (void) { + return GetInstallDir() + "inc"; +} +std::string GetStdLinkerScriptsDir (void) { + return GetInstallDir() + "lkr"; +} + +std::string GetStdLibsDir (void) { + return GetInstallDir() + "lib"; +} +} |