Fixed handling of -c option.wq
[oota-llvm.git] / tools / llvmc / example / mcc16 / plugins / PIC16Base / PluginMain.cpp
1 #include "AutoGenerated.inc"
2
3 #include "llvm/System/Path.h"
4 #include "llvm/Support/raw_ostream.h"
5
6 using namespace llvm;
7
8 namespace llvmc {
9   extern char *ProgramName;
10 }
11
12 // Returns the platform specific directory separator via #ifdefs.
13 static std::string GetDirSeparator(void) {
14   return "/";
15 }
16
17 namespace hooks {
18 // Get the dir where c16 executables reside.
19 std::string GetBinDir (void) {
20   // Construct a Path object from the program name.  
21   void *P = (void*) (intptr_t) GetBinDir;
22   sys::Path ProgramFullPath 
23     = sys::Path::GetMainExecutable(llvmc::ProgramName, P);
24
25   // Get the dir name for the program. It's last component should be 'bin'.
26   std::string BinDir = ProgramFullPath.getDirname();
27
28   // llvm::errs() << "BinDir: " << BinDir << '\n';
29   return BinDir + GetDirSeparator();
30 }
31
32 // Get the Top-level Installation dir for c16.
33 std::string GetInstallDir (void) {
34   sys::Path BinDirPath = sys::Path(GetBinDir());
35
36   // Go one more level up to get the install dir.
37   std::string InstallDir  = BinDirPath.getDirname();
38   
39   return InstallDir + GetDirSeparator();
40 }
41
42 // Get the dir where the c16 header files reside.
43 std::string GetStdHeadersDir (void) {
44   return GetInstallDir() + "include";
45 }
46
47 // Get the dir where the assembler header files reside.
48 std::string GetStdAsmHeadersDir (void) {
49   return GetInstallDir() + "inc";
50 }
51
52 // Get the dir where the linker scripts reside.
53 std::string GetStdLinkerScriptsDir (void) {
54   return GetInstallDir() + "lkr";
55 }
56
57 // Get the dir where startup code, intrinsics and lib reside.
58 std::string GetStdLibsDir (void) {
59   return GetInstallDir() + "lib";
60 }
61 }