Refactor resource path code into own function.
This is a preparation because we want to ship module configuration files in the future in the cling resource directory (Clang VFS overlay files and modulemaps). This means that we will need to know this path in a few other places (e.g. where we specify the -ivfsoverlayPATH arguments and potential -fmodule-map-file=PATH args) It also makes this giant function a bit easier on the eyes.
This commit is contained in:
parent
15a4056c56
commit
7efc518a7e
@ -168,7 +168,31 @@ namespace {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static std::string getResourceDir(const char* llvmdir) {
|
||||
if (!llvmdir) {
|
||||
// FIXME: The first arg really does need to be argv[0] on FreeBSD.
|
||||
//
|
||||
// Note: The second arg is not used for Apple, FreeBSD, Linux,
|
||||
// or cygwin, and can only be used on systems which support
|
||||
// the use of dladdr().
|
||||
//
|
||||
// Note: On linux and cygwin this uses /proc/self/exe to find the path
|
||||
// Note: On Apple it uses _NSGetExecutablePath().
|
||||
// Note: On FreeBSD it uses getprogpath().
|
||||
// Note: Otherwise it uses dladdr().
|
||||
//
|
||||
return CompilerInvocation::GetResourcesPath(
|
||||
"cling", (void*)intptr_t(GetExecutablePath));
|
||||
} else {
|
||||
std::string resourcePath;
|
||||
llvm::SmallString<512> tmp(llvmdir);
|
||||
llvm::sys::path::append(tmp, "lib", "clang", CLANG_VERSION_STRING);
|
||||
resourcePath.assign(&tmp[0], tmp.size());
|
||||
return resourcePath;
|
||||
}
|
||||
}
|
||||
|
||||
///\brief Adds standard library -I used by whatever compiler is found in PATH.
|
||||
static void AddHostArguments(llvm::StringRef clingBin,
|
||||
std::vector<const char*>& args,
|
||||
@ -315,27 +339,7 @@ namespace {
|
||||
#endif // _MSC_VER
|
||||
|
||||
if (!opts.ResourceDir && !opts.NoBuiltinInc) {
|
||||
std::string resourcePath;
|
||||
if (!llvmdir) {
|
||||
// FIXME: The first arg really does need to be argv[0] on FreeBSD.
|
||||
//
|
||||
// Note: The second arg is not used for Apple, FreeBSD, Linux,
|
||||
// or cygwin, and can only be used on systems which support
|
||||
// the use of dladdr().
|
||||
//
|
||||
// Note: On linux and cygwin this uses /proc/self/exe to find the path
|
||||
// Note: On Apple it uses _NSGetExecutablePath().
|
||||
// Note: On FreeBSD it uses getprogpath().
|
||||
// Note: Otherwise it uses dladdr().
|
||||
//
|
||||
resourcePath
|
||||
= CompilerInvocation::GetResourcesPath("cling",
|
||||
(void*)intptr_t(GetExecutablePath));
|
||||
} else {
|
||||
llvm::SmallString<512> tmp(llvmdir);
|
||||
llvm::sys::path::append(tmp, "lib", "clang", CLANG_VERSION_STRING);
|
||||
resourcePath.assign(&tmp[0], tmp.size());
|
||||
}
|
||||
std::string resourcePath = getResourceDir(llvmdir);
|
||||
|
||||
// FIXME: Handle cases, where the cling is part of a library/framework.
|
||||
// There we can't rely on the find executable logic.
|
||||
|
Loading…
x
Reference in New Issue
Block a user