Add functionality to the platforms to figure out the proper name for a dynamic library on the system given a basename

This will do things like,
given mylibrary,
return

libmylibrary.dylib on OSX
mylibrary.dll on Windows

and so on for other platforms
It is currently implemented for Windows, Darwin, and Linux. Other platforms should fill in accordingly

llvm-svn: 246131
This commit is contained in:
Enrico Granata 2015-08-27 00:53:57 +00:00
parent c0499c9848
commit 6e25aeea96
8 changed files with 52 additions and 0 deletions

View File

@ -268,6 +268,9 @@ class ModuleCache;
virtual const char *
GetHostname ();
virtual ConstString
GetFullNameForDylib (ConstString basename);
virtual const char *
GetDescription () = 0;

View File

@ -854,3 +854,14 @@ PlatformLinux::ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags)
flags_platform |= map_anon;
return flags_platform;
}
ConstString
PlatformLinux::GetFullNameForDylib (ConstString basename)
{
if (basename.IsEmpty())
return basename;
StreamString stream;
stream.Printf("lib%s.so", basename.GetCString());
return ConstString(stream.GetData());
}

View File

@ -111,6 +111,9 @@ namespace platform_linux {
uint64_t
ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags) override;
ConstString
GetFullNameForDylib (ConstString basename) override;
private:
DISALLOW_COPY_AND_ASSIGN (PlatformLinux);
};

View File

@ -1531,3 +1531,15 @@ PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std:
options.push_back(sysroot_spec.GetPath());
}
}
ConstString
PlatformDarwin::GetFullNameForDylib (ConstString basename)
{
if (basename.IsEmpty())
return basename;
StreamString stream;
stream.Printf("lib%s.dylib", basename.GetCString());
return ConstString(stream.GetData());
}

View File

@ -84,6 +84,9 @@ public:
bool
SupportsModules () override { return true; }
lldb_private::ConstString
GetFullNameForDylib (lldb_private::ConstString basename) override;
protected:

View File

@ -743,3 +743,14 @@ PlatformWindows::GetEnvironment(StringList &env)
return Host::GetEnvironment(env);
}
ConstString
PlatformWindows::GetFullNameForDylib (ConstString basename)
{
if (basename.IsEmpty())
return basename;
StreamString stream;
stream.Printf("%s.dll", basename.GetCString());
return ConstString(stream.GetData());
}

View File

@ -156,6 +156,9 @@ public:
CalculateTrapHandlerSymbolNames () override
{
}
ConstString
GetFullNameForDylib (ConstString basename) override;
protected:
lldb::PlatformSP m_remote_platform_sp;

View File

@ -947,6 +947,12 @@ Platform::GetHostname ()
return m_name.c_str();
}
ConstString
Platform::GetFullNameForDylib (ConstString basename)
{
return basename;
}
bool
Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir)
{