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 static std::string GetDirSeparator(void) {
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);
25 // Get the dir name for the program. It's last component should be 'bin'.
26 std::string BinDir = ProgramFullPath.getDirname();
28 // llvm::errs() << "BinDir: " << BinDir << '\n';
29 return BinDir + GetDirSeparator();
32 // Get the Top-level Installation dir for c16.
33 std::string GetInstallDir (void) {
34 sys::Path BinDirPath = sys::Path(GetBinDir());
36 // Go one more level up to get the install dir.
37 std::string InstallDir = BinDirPath.getDirname();
39 return InstallDir + GetDirSeparator();
42 // Get the dir where the c16 header files reside.
43 std::string GetStdHeadersDir (void) {
44 return GetInstallDir() + "include";
47 // Get the dir where the assembler header files reside.
48 std::string GetStdAsmHeadersDir (void) {
49 return GetInstallDir() + "inc";
52 // Get the dir where the linker scripts reside.
53 std::string GetStdLinkerScriptsDir (void) {
54 return GetInstallDir() + "lkr";
57 // Get the dir where startup code, intrinsics and lib reside.
58 std::string GetStdLibsDir (void) {
59 return GetInstallDir() + "lib";