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() {
22 // Get the dir where c16 executables reside.
23 std::string GetBinDir() {
24 // Construct a Path object from the program name.
25 void *P = (void*) (intptr_t) GetBinDir;
26 sys::Path ProgramFullPath
27 = sys::Path::GetMainExecutable(llvmc::ProgramName, P);
29 // Get the dir name for the program. It's last component should be 'bin'.
30 std::string BinDir = ProgramFullPath.getDirname();
32 // llvm::errs() << "BinDir: " << BinDir << '\n';
33 return BinDir + GetDirSeparator();
36 // Get the Top-level Installation dir for c16.
37 std::string GetInstallDir() {
38 sys::Path BinDirPath = sys::Path(GetBinDir());
40 // Go one more level up to get the install dir.
41 std::string InstallDir = BinDirPath.getDirname();
43 return InstallDir + GetDirSeparator();
46 // Get the dir where the c16 header files reside.
47 std::string GetStdHeadersDir() {
48 return GetInstallDir() + "include";
51 // Get the dir where the assembler header files reside.
52 std::string GetStdAsmHeadersDir() {
53 return GetInstallDir() + "inc";
56 // Get the dir where the linker scripts reside.
57 std::string GetStdLinkerScriptsDir() {
58 return GetInstallDir() + "lkr";
61 // Get the dir where startup code, intrinsics and lib reside.
62 std::string GetStdLibsDir() {
63 return GetInstallDir() + "lib";