diff --git a/IDEHelper/Backend/BeLibManger.cpp b/IDEHelper/Backend/BeLibManger.cpp index e4571f5d..e429ae9b 100644 --- a/IDEHelper/Backend/BeLibManger.cpp +++ b/IDEHelper/Backend/BeLibManger.cpp @@ -185,6 +185,7 @@ bool BeLibFile::Init(const StringImpl& filePath, bool moveFile) ::DeleteFileA(altName.c_str()); if (!::MoveFileA(filePath.c_str(), altName.c_str())) { + mFilePath = filePath; return false; } } @@ -240,7 +241,7 @@ bool BeLibFile::Finish() } if (!mFileStream.Open(mFilePath, "wb")) - { + { mFailed = true; return false; } @@ -499,10 +500,18 @@ void BeLibManager::Finish() { BP_ZONE("BeLibManager::Finish"); + AutoCrit autoCrit(mCritSect); + for (auto& libPair : mLibFiles) { 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; } mLibFiles.Clear(); diff --git a/IDEHelper/Backend/BeLibManger.h b/IDEHelper/Backend/BeLibManger.h index 7073f6ac..a1634e79 100644 --- a/IDEHelper/Backend/BeLibManger.h +++ b/IDEHelper/Backend/BeLibManger.h @@ -105,6 +105,7 @@ class BeLibManager public: CritSect mCritSect; Dictionary mLibFiles; + Array mErrors; public: BeLibManager(); diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index 450aa122..745fd450 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -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