1 #include "AutoGenerated.inc"
3 #include "llvm/System/Path.h"
4 #include "llvm/Support/raw_ostream.h"
9 extern char *ProgramName;
12 // Returns the platform specific directory separator via #ifdefs.
13 // FIXME: This currently work on linux and windows only. It does not
14 // work on other unices.
15 static std::string GetDirSeparator(void) {
24 // Get the dir where c16 executables reside.
25 std::string GetBinDir (void) {
26 // Construct a Path object from the program name.
27 void *P = (void*) (intptr_t) GetBinDir;
28 sys::Path ProgramFullPath
29 = sys::Path::GetMainExecutable(llvmc::ProgramName, P);
31 // Get the dir name for the program. It's last component should be 'bin'.
32 std::string BinDir = ProgramFullPath.getDirname();
34 // llvm::errs() << "BinDir: " << BinDir << '\n';
35 return BinDir + GetDirSeparator();
38 // Get the Top-level Installation dir for c16.
39 std::string GetInstallDir (void) {
40 sys::Path BinDirPath = sys::Path(GetBinDir());
42 // Go one more level up to get the install dir.
43 std::string InstallDir = BinDirPath.getDirname();
45 return InstallDir + GetDirSeparator();
48 // Get the dir where the c16 header files reside.
49 std::string GetStdHeadersDir (void) {
50 return GetInstallDir() + "include";
53 // Get the dir where the assembler header files reside.
54 std::string GetStdAsmHeadersDir (void) {
55 return GetInstallDir() + "inc";
58 // Get the dir where the linker scripts reside.
59 std::string GetStdLinkerScriptsDir (void) {
60 return GetInstallDir() + "lkr";
63 // Get the dir where startup code, intrinsics and lib reside.
64 std::string GetStdLibsDir (void) {
65 return GetInstallDir() + "lib";