mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Working on properly rebuilding target even if we restart ide
This commit is contained in:
parent
3eeeaf647e
commit
959da9884c
10 changed files with 289 additions and 126 deletions
|
@ -44,7 +44,7 @@
|
|||
//#define DBG_FORCE_SYNCHRONIZED
|
||||
|
||||
// This is used for the Release DLL thunk and the build.dat file
|
||||
#define BF_CODEGEN_VERSION 13
|
||||
#define BF_CODEGEN_VERSION 14
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
|
@ -85,7 +85,8 @@ void BfCodeGenDirectoryData::Read()
|
|||
return;
|
||||
#endif
|
||||
|
||||
while (!fileStream.Eof())
|
||||
int numFiles = fileStream.ReadInt32();
|
||||
for (int fileIdx = 0; fileIdx < numFiles; fileIdx++)
|
||||
{
|
||||
String fileName = fileStream.ReadAscii32SizedString();
|
||||
BfCodeGenFileData fileData;
|
||||
|
@ -95,6 +96,14 @@ void BfCodeGenDirectoryData::Read()
|
|||
mFileMap[fileName] = fileData;
|
||||
}
|
||||
|
||||
int numValues = fileStream.ReadInt32();
|
||||
for (int valIdx = 0; valIdx < numValues; valIdx++)
|
||||
{
|
||||
String key = fileStream.ReadAscii32SizedString();
|
||||
String value = fileStream.ReadAscii32SizedString();
|
||||
mBuildSettings[key] = value;
|
||||
}
|
||||
|
||||
mFileTime = GetFileTimeWrite(fileName);
|
||||
}
|
||||
|
||||
|
@ -129,6 +138,7 @@ void BfCodeGenDirectoryData::Write()
|
|||
fileStream.Write(BF_CODEGEN_VERSION);
|
||||
fileStream.WriteT(mCodeGen->mBackendHash);
|
||||
|
||||
fileStream.Write((int)mFileMap.size());
|
||||
for (auto& pair : mFileMap)
|
||||
{
|
||||
fileStream.Write(pair.mKey);
|
||||
|
@ -137,6 +147,13 @@ void BfCodeGenDirectoryData::Write()
|
|||
fileStream.Write(&pair.mValue.mLastWasObjectWrite, sizeof(bool));
|
||||
}
|
||||
|
||||
fileStream.Write((int)mBuildSettings.size());
|
||||
for (auto& pair : mBuildSettings)
|
||||
{
|
||||
fileStream.Write(pair.mKey);
|
||||
fileStream.Write(pair.mValue);
|
||||
}
|
||||
|
||||
fileStream.Close();
|
||||
mFileTime = GetFileTimeWrite(fileName);
|
||||
}
|
||||
|
@ -161,6 +178,7 @@ void BfCodeGenDirectoryData::Verify()
|
|||
void BfCodeGenDirectoryData::Clear()
|
||||
{
|
||||
mFileMap.Clear();
|
||||
mBuildSettings.Clear();
|
||||
}
|
||||
|
||||
bool BfCodeGenDirectoryData::CheckCache(const StringImpl& fileName, Val128 hash, Val128* outOrderedHash, bool disallowObjectWrite)
|
||||
|
@ -211,6 +229,21 @@ void BfCodeGenDirectoryData::FileFailed()
|
|||
mFileFailed = true;
|
||||
}
|
||||
|
||||
String BfCodeGenDirectoryData::GetValue(const StringImpl& key)
|
||||
{
|
||||
String* valuePtr = NULL;
|
||||
if (mBuildSettings.TryGetValue(key, &valuePtr))
|
||||
{
|
||||
return *valuePtr;
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
void BfCodeGenDirectoryData::SetValue(const StringImpl& key, const StringImpl& value)
|
||||
{
|
||||
mBuildSettings[key] = value;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void BfCodeGenRequest::DbgSaveData()
|
||||
|
@ -285,22 +318,8 @@ void BfCodeGenThread::RunLoop()
|
|||
|
||||
#ifndef CODEGEN_DISABLE_CACHE
|
||||
{
|
||||
AutoCrit autoCrit(mCodeGen->mCacheCritSect);
|
||||
|
||||
BfCodeGenDirectoryData** dirCachePtr = NULL;
|
||||
if (mCodeGen->mDirectoryCache.TryAdd(cacheDir, NULL, &dirCachePtr))
|
||||
{
|
||||
dirCache = new BfCodeGenDirectoryData();
|
||||
*dirCachePtr = dirCache;
|
||||
dirCache->mCodeGen = mCodeGen;
|
||||
dirCache->mDirectoryName = cacheDir;
|
||||
if (!mCodeGen->mDisableCacheReads)
|
||||
dirCache->Read();
|
||||
}
|
||||
else
|
||||
{
|
||||
dirCache = *dirCachePtr;
|
||||
}
|
||||
AutoCrit autoCrit(mCodeGen->mCacheCritSect);
|
||||
dirCache = mCodeGen->GetDirCache(cacheDir);
|
||||
|
||||
//For testing only!
|
||||
/*{
|
||||
|
@ -872,6 +891,27 @@ void BfCodeGen::WriteObjectFile(BfModule* bfModule, const StringImpl& outFileNam
|
|||
#endif
|
||||
}
|
||||
|
||||
String BfCodeGen::GetBuildValue(const StringImpl& buildDir, const StringImpl& key)
|
||||
{
|
||||
AutoCrit autoCrit(mCacheCritSect);
|
||||
BfCodeGenDirectoryData* dirCache = GetDirCache(buildDir);
|
||||
return dirCache->GetValue(key);
|
||||
}
|
||||
|
||||
void BfCodeGen::SetBuildValue(const StringImpl& buildDir, const StringImpl & key, const StringImpl & value)
|
||||
{
|
||||
AutoCrit autoCrit(mCacheCritSect);
|
||||
BfCodeGenDirectoryData* dirCache = GetDirCache(buildDir);
|
||||
dirCache->SetValue(key, value);
|
||||
}
|
||||
|
||||
void BfCodeGen::WriteBuildCache(const StringImpl& buildDir)
|
||||
{
|
||||
AutoCrit autoCrit(mCacheCritSect);
|
||||
BfCodeGenDirectoryData* dirCache = GetDirCache(buildDir);
|
||||
dirCache->Write();
|
||||
}
|
||||
|
||||
void BfCodeGen::RequestComplete(BfCodeGenRequest* request)
|
||||
{
|
||||
mCompletionCount++;
|
||||
|
@ -936,6 +976,26 @@ void BfCodeGen::ProcessErrors(BfPassInstance* passInstance, bool canceled)
|
|||
}
|
||||
}
|
||||
|
||||
BfCodeGenDirectoryData * BfCodeGen::GetDirCache(const StringImpl & cacheDir)
|
||||
{
|
||||
BfCodeGenDirectoryData* dirCache = NULL;
|
||||
BfCodeGenDirectoryData** dirCachePtr = NULL;
|
||||
if (mDirectoryCache.TryAdd(cacheDir, NULL, &dirCachePtr))
|
||||
{
|
||||
dirCache = new BfCodeGenDirectoryData();
|
||||
*dirCachePtr = dirCache;
|
||||
dirCache->mCodeGen = this;
|
||||
dirCache->mDirectoryName = cacheDir;
|
||||
if (!mDisableCacheReads)
|
||||
dirCache->Read();
|
||||
}
|
||||
else
|
||||
{
|
||||
dirCache = *dirCachePtr;
|
||||
}
|
||||
return dirCache;
|
||||
}
|
||||
|
||||
void BfCodeGen::Cancel()
|
||||
{
|
||||
for (auto thread : mThreads)
|
||||
|
|
|
@ -111,6 +111,7 @@ class BfCodeGenDirectoryData
|
|||
public:
|
||||
BfCodeGen* mCodeGen;
|
||||
Dictionary<String, BfCodeGenFileData> mFileMap;
|
||||
Dictionary<String, String> mBuildSettings;
|
||||
String mDirectoryName;
|
||||
bool mDirty;
|
||||
bool mVerified;
|
||||
|
@ -137,6 +138,8 @@ public:
|
|||
void SetHash(const StringImpl& fileName, Val128 hash, Val128 orderedHash, bool isObjectWrite);
|
||||
void ClearHash(const StringImpl& fileName);
|
||||
void FileFailed();
|
||||
String GetValue(const StringImpl& key);
|
||||
void SetValue(const StringImpl& key, const StringImpl& value);
|
||||
};
|
||||
|
||||
class BfCodeGenFileEntry
|
||||
|
@ -202,6 +205,7 @@ public:
|
|||
void ClearBuildCache();
|
||||
void RequestComplete(BfCodeGenRequest* request);
|
||||
void ProcessErrors(BfPassInstance* passInstance, bool canceled);
|
||||
BfCodeGenDirectoryData* GetDirCache(const StringImpl& cacheDir);
|
||||
|
||||
public:
|
||||
BfCodeGen();
|
||||
|
@ -209,7 +213,10 @@ public:
|
|||
|
||||
void ResetStats();
|
||||
void UpdateStats();
|
||||
void WriteObjectFile(BfModule* module, const StringImpl& outFileName, const BfCodeGenOptions& options);
|
||||
void WriteObjectFile(BfModule* module, const StringImpl& outFileName, const BfCodeGenOptions& options);
|
||||
String GetBuildValue(const StringImpl& buildDir, const StringImpl& key);
|
||||
void SetBuildValue(const StringImpl& buildDir, const StringImpl& key, const StringImpl& value);
|
||||
void WriteBuildCache(const StringImpl& buildDir);
|
||||
void Cancel();
|
||||
bool Finish();
|
||||
};
|
||||
|
|
|
@ -7790,6 +7790,23 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_ClearBuildCache(BfCompiler* bfCompiler)
|
|||
bfCompiler->ClearBuildCache();
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE BfCompiler_SetBuildValue(BfCompiler* bfCompiler, char* cacheDir, char* key, char* value)
|
||||
{
|
||||
bfCompiler->mCodeGen.SetBuildValue(cacheDir, key, value);
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetBuildValue(BfCompiler* bfCompiler, char* cacheDir, char* key)
|
||||
{
|
||||
String& outString = *gTLStrReturn.Get();
|
||||
outString = bfCompiler->mCodeGen.GetBuildValue(cacheDir, key);
|
||||
return outString.c_str();
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE BfCompiler_WriteBuildCache(BfCompiler* bfCompiler, char* cacheDir)
|
||||
{
|
||||
bfCompiler->mCodeGen.WriteBuildCache(cacheDir);
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE BfCompiler_Delete(BfCompiler* bfCompiler)
|
||||
{
|
||||
delete bfCompiler;
|
||||
|
@ -8210,3 +8227,4 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_ForceRebuild(BfCompiler* bfCompiler)
|
|||
{
|
||||
bfCompiler->mOptions.mForceRebuildIdx++;
|
||||
}
|
||||
|
||||
|
|
|
@ -10937,7 +10937,10 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
{
|
||||
// Just leave the new items
|
||||
projectList.RemoveRange(0, typeProjectsCounts);
|
||||
std::sort(projectList.begin(), projectList.end());
|
||||
std::sort(projectList.begin(), projectList.end(), [](BfProject* lhs, BfProject*rhs)
|
||||
{
|
||||
return lhs->mName < rhs->mName;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue