Abstract cleaning of files and add code that deletes files from Debug subdirectory
This commit is contained in:
parent
9cf39703dc
commit
e6406f681d
|
@ -182,21 +182,8 @@ int cmTryCompileCommand::CoreTryCompileCode(
|
||||||
// if They specified clean then we clean up what we can
|
// if They specified clean then we clean up what we can
|
||||||
if (srcFileSignature && clean)
|
if (srcFileSignature && clean)
|
||||||
{
|
{
|
||||||
cmDirectory dir;
|
|
||||||
dir.Load(binaryDirectory);
|
|
||||||
size_t fileNum;
|
|
||||||
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
|
|
||||||
{
|
|
||||||
if (strcmp(dir.GetFile(fileNum),".") &&
|
|
||||||
strcmp(dir.GetFile(fileNum),".."))
|
|
||||||
{
|
|
||||||
std::string fullPath = binaryDirectory;
|
|
||||||
fullPath += "/";
|
|
||||||
fullPath += dir.GetFile(fileNum);
|
|
||||||
cmSystemTools::RemoveFile(fullPath.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmListFileCache::GetInstance()->FlushCache(outFileName.c_str());
|
cmListFileCache::GetInstance()->FlushCache(outFileName.c_str());
|
||||||
|
cmTryCompileCommand::CleanupFiles(binaryDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -219,6 +206,34 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmTryCompileCommand::CleanupFiles(const char* binDir, bool recursive)
|
||||||
|
{
|
||||||
|
if ( !binDir )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
if ( recursive )
|
||||||
|
{
|
||||||
|
std::string bdir = binDir;
|
||||||
|
bdir += "/Debug";
|
||||||
|
cmTryCompileCommand::CleanupFiles(bdir.c_str(), false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cmDirectory dir;
|
||||||
|
dir.Load(binDir);
|
||||||
|
size_t fileNum;
|
||||||
|
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
|
||||||
|
{
|
||||||
|
if (strcmp(dir.GetFile(fileNum),".") &&
|
||||||
|
strcmp(dir.GetFile(fileNum),".."))
|
||||||
|
{
|
||||||
|
std::string fullPath = binDir;
|
||||||
|
fullPath += "/";
|
||||||
|
fullPath += dir.GetFile(fileNum);
|
||||||
|
cmSystemTools::RemoveFile(fullPath.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -62,10 +62,16 @@ public:
|
||||||
*/
|
*/
|
||||||
static int CoreTryCompileCode(
|
static int CoreTryCompileCode(
|
||||||
cmMakefile *mf, std::vector<std::string> const& argv, bool clean);
|
cmMakefile *mf, std::vector<std::string> const& argv, bool clean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This deletes all the files created by TRY_COMPILE or TRY_RUN
|
||||||
|
* code. This way we do not have to rely on the timing and
|
||||||
|
* dependencies of makefiles.
|
||||||
|
*/
|
||||||
|
static void CleanupFiles(const char* binDir, bool recursive=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More documentation.
|
* More documentation. */
|
||||||
*/
|
|
||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
|
|
@ -109,24 +109,10 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we created a directory etc, then cleanup after ourselves
|
// if we created a directory etc, then cleanup after ourselves
|
||||||
cmDirectory dir;
|
|
||||||
dir.Load(binaryDirectory.c_str());
|
|
||||||
size_t fileNum;
|
|
||||||
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
|
|
||||||
{
|
|
||||||
if (strcmp(dir.GetFile(fileNum),".") &&
|
|
||||||
strcmp(dir.GetFile(fileNum),".."))
|
|
||||||
{
|
|
||||||
std::string fullPath = binaryDirectory;
|
|
||||||
fullPath += "/";
|
|
||||||
fullPath += dir.GetFile(fileNum);
|
|
||||||
cmSystemTools::RemoveFile(fullPath.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::string cacheFile = binaryDirectory;
|
std::string cacheFile = binaryDirectory;
|
||||||
cacheFile += "/CMakeLists.txt";
|
cacheFile += "/CMakeLists.txt";
|
||||||
cmListFileCache::GetInstance()->FlushCache(cacheFile.c_str());
|
cmListFileCache::GetInstance()->FlushCache(cacheFile.c_str());
|
||||||
|
cmTryCompileCommand::CleanupFiles(binaryDirectory.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue