1
#include "AutoGenerated.inc"
3
#include "llvm/System/Path.h"
4
#include "llvm/Support/raw_ostream.h"
9
extern char *ProgramName;
14
// Returns the platform specific directory separator via #ifdefs.
15
// FIXME: This currently work on linux and windows only. It does not
16
// work on other unices.
17
static std::string GetDirSeparator() {
18
#if __linux__ || __APPLE__
26
// Get preprocessor define for the part.
27
// It is __partname format in lower case.
29
GetLowerCasePartDefine(void) {
31
if (AutoGeneratedParameter_p.empty()) {
34
Partname = AutoGeneratedParameter_p;
37
std::string LowerCase;
38
for (unsigned i = 0; i <= Partname.size(); i++) {
39
LowerCase.push_back(std::tolower(Partname[i]));
42
return "__" + LowerCase;
46
GetUpperCasePartDefine(void) {
48
if (AutoGeneratedParameter_p.empty()) {
51
Partname = AutoGeneratedParameter_p;
54
std::string UpperCase;
55
for (unsigned i = 0; i <= Partname.size(); i++) {
56
UpperCase.push_back(std::toupper(Partname[i]));
59
return "__" + UpperCase;
63
// Get the dir where c16 executables reside.
64
std::string GetBinDir() {
65
// Construct a Path object from the program name.
66
void *P = (void*) (intptr_t) GetBinDir;
67
sys::Path ProgramFullPath
68
= sys::Path::GetMainExecutable(llvmc::ProgramName, P);
70
// Get the dir name for the program. It's last component should be 'bin'.
71
std::string BinDir = ProgramFullPath.getDirname();
73
// llvm::errs() << "BinDir: " << BinDir << '\n';
74
return BinDir + GetDirSeparator();
77
// Get the Top-level Installation dir for c16.
78
std::string GetInstallDir() {
79
sys::Path BinDirPath = sys::Path(GetBinDir());
81
// Go one more level up to get the install dir.
82
std::string InstallDir = BinDirPath.getDirname();
84
return InstallDir + GetDirSeparator();
87
// Get the dir where the c16 header files reside.
88
std::string GetStdHeadersDir() {
89
return GetInstallDir() + "include";
92
// Get the dir where the assembler header files reside.
93
std::string GetStdAsmHeadersDir() {
94
return GetInstallDir() + "inc";
97
// Get the dir where the linker scripts reside.
98
std::string GetStdLinkerScriptsDir() {
99
return GetInstallDir() + "lkr";
102
// Get the dir where startup code, intrinsics and lib reside.
103
std::string GetStdLibsDir() {
104
return GetInstallDir() + "lib";