1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Properly handling lib failures

This commit is contained in:
Brian Fiete 2020-01-22 15:25:37 -08:00
parent 293387e41f
commit d67e03f137
3 changed files with 22 additions and 3 deletions

View file

@ -185,6 +185,7 @@ bool BeLibFile::Init(const StringImpl& filePath, bool moveFile)
::DeleteFileA(altName.c_str()); ::DeleteFileA(altName.c_str());
if (!::MoveFileA(filePath.c_str(), altName.c_str())) if (!::MoveFileA(filePath.c_str(), altName.c_str()))
{ {
mFilePath = filePath;
return false; return false;
} }
} }
@ -240,7 +241,7 @@ bool BeLibFile::Finish()
} }
if (!mFileStream.Open(mFilePath, "wb")) if (!mFileStream.Open(mFilePath, "wb"))
{ {
mFailed = true; mFailed = true;
return false; return false;
} }
@ -499,10 +500,18 @@ void BeLibManager::Finish()
{ {
BP_ZONE("BeLibManager::Finish"); BP_ZONE("BeLibManager::Finish");
AutoCrit autoCrit(mCritSect);
for (auto& libPair : mLibFiles) for (auto& libPair : mLibFiles)
{ {
auto libFile = libPair.mValue; auto libFile = libPair.mValue;
libFile->Finish(); if (!libFile->mFilePath.IsEmpty())
{
if (!libFile->Finish())
{
mErrors.Add(StrFormat("Failed to write lib file '%s'", libFile->mFilePath.c_str()));
}
}
delete libFile; delete libFile;
} }
mLibFiles.Clear(); mLibFiles.Clear();

View file

@ -105,6 +105,7 @@ class BeLibManager
public: public:
CritSect mCritSect; CritSect mCritSect;
Dictionary<String, BeLibFile*> mLibFiles; Dictionary<String, BeLibFile*> mLibFiles;
Array<String> mErrors;
public: public:
BeLibManager(); BeLibManager();

View file

@ -6486,7 +6486,16 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
} }
} }
BeLibManager::Get()->Finish(); auto libManager = BeLibManager::Get();
libManager->Finish();
if (!libManager->mErrors.IsEmpty())
{
for (auto& error : libManager->mErrors)
mPassInstance->Fail(error);
// We need to rebuild everything just to force that lib to get repopulated
mOptions.mForceRebuildIdx++;
}
libManager->mErrors.Clear();
} }
#endif #endif