Use /data/local/tmp as temp directory on android
If no temp directory specified by the user on android then fall back to /data/local/tmp what is always present on the device. It removes the dependency of specifying TMPDIR for executing platform commands on android. Differential revision: http://reviews.llvm.org/D9569 llvm-svn: 236843
This commit is contained in:
parent
679c2c3639
commit
f3a243297b
|
@ -117,6 +117,7 @@ class HostInfoBase
|
|||
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
|
||||
static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
|
||||
static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
|
||||
static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
|
||||
static bool ComputeHeaderDirectory(FileSpec &file_spec);
|
||||
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
|
||||
static bool ComputeClangDirectory(FileSpec &file_spec);
|
||||
|
|
|
@ -25,6 +25,7 @@ class HostInfoAndroid : public HostInfoLinux
|
|||
|
||||
protected:
|
||||
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
|
||||
static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
|
||||
};
|
||||
|
||||
} // end of namespace lldb_private
|
||||
|
|
|
@ -87,3 +87,15 @@ HostInfoAndroid::ResolveLibraryPath(const std::string& module_path, const ArchSp
|
|||
|
||||
return FileSpec();
|
||||
}
|
||||
|
||||
bool
|
||||
HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec)
|
||||
{
|
||||
if (HostInfoLinux::ComputeTempFileBaseDirectory(file_spec))
|
||||
return true;
|
||||
|
||||
// If the default mechanism for computing the temp directory failed then
|
||||
// fall back to /data/local/tmp
|
||||
file_spec = FileSpec("/data/local/tmp", false);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ bool
|
|||
HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec)
|
||||
{
|
||||
FileSpec temp_file_spec;
|
||||
if (!ComputeGlobalTempFileDirectory(temp_file_spec))
|
||||
if (!HostInfo::ComputeGlobalTempFileDirectory(temp_file_spec))
|
||||
return false;
|
||||
|
||||
std::string pid_str;
|
||||
|
@ -342,21 +342,33 @@ HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec)
|
|||
}
|
||||
|
||||
bool
|
||||
HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec)
|
||||
HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec)
|
||||
{
|
||||
file_spec.Clear();
|
||||
|
||||
const char *tmpdir_cstr = getenv("TMPDIR");
|
||||
if (tmpdir_cstr == NULL)
|
||||
if (tmpdir_cstr == nullptr)
|
||||
{
|
||||
tmpdir_cstr = getenv("TMP");
|
||||
if (tmpdir_cstr == NULL)
|
||||
if (tmpdir_cstr == nullptr)
|
||||
tmpdir_cstr = getenv("TEMP");
|
||||
}
|
||||
if (!tmpdir_cstr)
|
||||
return false;
|
||||
|
||||
FileSpec temp_file_spec(tmpdir_cstr, false);
|
||||
file_spec = FileSpec(tmpdir_cstr, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec)
|
||||
{
|
||||
file_spec.Clear();
|
||||
|
||||
FileSpec temp_file_spec;
|
||||
if (!HostInfo::ComputeTempFileBaseDirectory(temp_file_spec))
|
||||
return false;
|
||||
|
||||
temp_file_spec.AppendPathComponent("lldb");
|
||||
if (!FileSystem::MakeDirectory(temp_file_spec.GetPath().c_str(), eFilePermissionsDirectoryDefault).Success())
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue