09fb9695e9addb135dfd93bf77cdc7e0befa5217
[oota-llvm.git] / tools / llvmc / example / mcc16 / plugins / PIC16Base / PluginMain.cpp
1 #include "AutoGenerated.inc"
2 #include "llvm/System/Path.h"
3
4 namespace llvmc {
5   extern char *ProgramName;
6 }
7
8 // Returns the platform specific directory separator via #ifdefs.
9 static std::string GetDirSeparator(void) {
10   return "/";
11 }
12
13 namespace hooks {
14 std::string GetBinDir (void) {
15   // Construct a Path object from the program name.  
16   llvm::sys::Path ProgramFullName(llvmc::ProgramName, 
17                                   strlen(llvmc::ProgramName));
18
19   // Get the dir name for the program. It's last component should be 'bin'.
20   std::string BinDir = ProgramFullName.getDirname();
21
22   return BinDir + GetDirSeparator();
23 }
24
25 std::string GetInstallDir (void) {
26   llvm::sys::Path BinDirPath = llvm::sys::Path(GetBinDir());
27
28   // Go one more level up to get the install dir.
29   std::string InstallDir  = BinDirPath.getDirname();
30   
31   return InstallDir + GetDirSeparator();
32 }
33
34 std::string GetStdHeadersDir (void) {
35   return GetInstallDir() + "include";
36 }
37
38 std::string GetStdAsmHeadersDir (void) {
39   return GetInstallDir() + "inc";
40 }
41 std::string GetStdLinkerScriptsDir (void) {
42   return GetInstallDir() + "lkr";
43 }
44
45 std::string GetStdLibsDir (void) {
46   return GetInstallDir() + "lib";
47 }
48 }