1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Working on properly rebuilding target even if we restart ide

This commit is contained in:
Brian Fiete 2019-09-28 09:48:37 -07:00
parent 3eeeaf647e
commit 959da9884c
10 changed files with 289 additions and 126 deletions

View file

@ -10,6 +10,7 @@ namespace IDE
{ {
class BuildContext class BuildContext
{ {
public int32 mUpdateCnt;
public Project mHotProject; public Project mHotProject;
public Workspace.Options mWorkspaceOptions; public Workspace.Options mWorkspaceOptions;
public Dictionary<Project, String> mImpLibMap = new .() ~ public Dictionary<Project, String> mImpLibMap = new .() ~
@ -567,113 +568,144 @@ namespace IDE
} }
} }
if (project.mNeedsTargetRebuild) /*if (File.Delete(targetPath).Failed(true))
{ {
/*if (File.Delete(targetPath).Failed(true)) OutputLine("Failed to delete {0}", targetPath);
{ return false;
OutputLine("Failed to delete {0}", targetPath); }*/
return false;
}*/
switch (options.mBuildOptions.mCLibType) switch (options.mBuildOptions.mCLibType)
{ {
case .None: case .None:
linkLine.Append("-nodefaultlib "); linkLine.Append("-nodefaultlib ");
case .Dynamic: case .Dynamic:
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt "); //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt ");
linkLine.Append("-defaultlib:msvcrt "); linkLine.Append("-defaultlib:msvcrt ");
case .Static: case .Static:
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmt " : "-defaultlib:libcmt "); //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmt " : "-defaultlib:libcmt ");
linkLine.Append("-defaultlib:libcmt "); linkLine.Append("-defaultlib:libcmt ");
case .DynamicDebug: case .DynamicDebug:
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprtd " : "-defaultlib:msvcrtd "); //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprtd " : "-defaultlib:msvcrtd ");
linkLine.Append("-defaultlib:msvcrtd "); linkLine.Append("-defaultlib:msvcrtd ");
case .StaticDebug: case .StaticDebug:
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmtd " : "-defaultlib:libcmtd "); //linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmtd " : "-defaultlib:libcmtd ");
linkLine.Append("-defaultlib:libcmtd "); linkLine.Append("-defaultlib:libcmtd ");
case .SystemMSVCRT: case .SystemMSVCRT:
linkLine.Append("-nodefaultlib "); linkLine.Append("-nodefaultlib ");
String minRTModName = scope String(); String minRTModName = scope String();
if ((project.mGeneralOptions.mTargetType == .BeefWindowsApplication) || if ((project.mGeneralOptions.mTargetType == .BeefWindowsApplication) ||
(project.mGeneralOptions.mTargetType == .C_WindowsApplication)) (project.mGeneralOptions.mTargetType == .C_WindowsApplication))
minRTModName.Append("g"); minRTModName.Append("g");
if (options.mBuildOptions.mBeefLibType == .DynamicDebug) if (options.mBuildOptions.mBeefLibType == .DynamicDebug)
minRTModName.Append("d"); minRTModName.Append("d");
if (!minRTModName.IsEmpty) if (!minRTModName.IsEmpty)
minRTModName.Insert(0, "_"); minRTModName.Insert(0, "_");
if (workspaceOptions.mMachineType == .x86)
linkLine.Append(gApp.mInstallDir, @"lib\x86\msvcrt.lib Beef", IDEApp.sRTVersionStr,"MinRT32", minRTModName, ".lib ");
else
linkLine.Append(gApp.mInstallDir, @"lib\x64\msvcrt.lib Beef", IDEApp.sRTVersionStr,"MinRT64", minRTModName, ".lib ");
linkLine.Append("ntdll.lib user32.lib kernel32.lib gdi32.lib winmm.lib shell32.lib ole32.lib rpcrt4.lib version.lib comdlg32.lib chkstk.obj -ignore:4049 -ignore:4217 ");
}
linkLine.Append("-nologo ");
//linkLine.Append("-fixed ");
// Incremental just seems to be slower for Beef. Test on larger projects to verify
linkLine.Append("-incremental:no ");
if (options.mBuildOptions.mStackSize > 0)
linkLine.AppendF("-stack:{} ", options.mBuildOptions.mStackSize);
linkLine.Append("-pdb:");
let pdbName = scope String();
GetPdbPath(targetPath, workspaceOptions, options, pdbName);
IDEUtils.AppendWithOptionalQuotes(linkLine, pdbName);
linkLine.Append(" ");
//TODO: Only add -debug if we have some debug info?
//if (isDebug)
if (workspaceOptions.mEmitDebugInfo != .No)
linkLine.Append("-debug ");
if (workspaceOptions.mBfOptimizationLevel.IsOptimized())
//linkLine.Append("-opt:ref -verbose ");
linkLine.Append("-opt:ref ");
else
linkLine.Append("-opt:noref ");
if (workspaceOptions.mMachineType == .x86) if (workspaceOptions.mMachineType == .x86)
{ linkLine.Append(gApp.mInstallDir, @"lib\x86\msvcrt.lib Beef", IDEApp.sRTVersionStr,"MinRT32", minRTModName, ".lib ");
for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths)
{
linkLine.AppendF("-libpath:\"{0}\" ", libPath);
}
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x86\" ");
}
else else
linkLine.Append(gApp.mInstallDir, @"lib\x64\msvcrt.lib Beef", IDEApp.sRTVersionStr,"MinRT64", minRTModName, ".lib ");
linkLine.Append("ntdll.lib user32.lib kernel32.lib gdi32.lib winmm.lib shell32.lib ole32.lib rpcrt4.lib version.lib comdlg32.lib chkstk.obj -ignore:4049 -ignore:4217 ");
}
linkLine.Append("-nologo ");
//linkLine.Append("-fixed ");
// Incremental just seems to be slower for Beef. Test on larger projects to verify
linkLine.Append("-incremental:no ");
if (options.mBuildOptions.mStackSize > 0)
linkLine.AppendF("-stack:{} ", options.mBuildOptions.mStackSize);
linkLine.Append("-pdb:");
let pdbName = scope String();
GetPdbPath(targetPath, workspaceOptions, options, pdbName);
IDEUtils.AppendWithOptionalQuotes(linkLine, pdbName);
linkLine.Append(" ");
//TODO: Only add -debug if we have some debug info?
//if (isDebug)
if (workspaceOptions.mEmitDebugInfo != .No)
linkLine.Append("-debug ");
if (workspaceOptions.mBfOptimizationLevel.IsOptimized())
//linkLine.Append("-opt:ref -verbose ");
linkLine.Append("-opt:ref ");
else
linkLine.Append("-opt:noref ");
if (workspaceOptions.mMachineType == .x86)
{
for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths)
{ {
for (var libPath in gApp.mSettings.mVSSettings.mLib64Paths) linkLine.AppendF("-libpath:\"{0}\" ", libPath);
{
linkLine.AppendF("-libpath:\"{0}\" ", libPath);
}
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x64\" ");
} }
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x86\" ");
String targetDir = scope String(); }
Path.GetDirectoryPath(targetPath, targetDir); else
linkLine.Append("-libpath:"); {
IDEUtils.AppendWithOptionalQuotes(linkLine, targetDir); for (var libPath in gApp.mSettings.mVSSettings.mLib64Paths)
linkLine.Append(" ");
if (options.mBuildOptions.mOtherLinkFlags.Length != 0)
{ {
var linkFlags = scope String(); linkLine.AppendF("-libpath:\"{0}\" ", libPath);
gApp.ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags);
linkLine.Append(linkFlags, " ");
} }
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x64\" ");
}
let winOptions = project.mWindowsOptions; String targetDir = scope String();
Path.GetDirectoryPath(targetPath, targetDir);
linkLine.Append("-libpath:");
IDEUtils.AppendWithOptionalQuotes(linkLine, targetDir);
linkLine.Append(" ");
if (options.mBuildOptions.mOtherLinkFlags.Length != 0)
{
var linkFlags = scope String();
gApp.ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags);
linkLine.Append(linkFlags, " ");
}
let winOptions = project.mWindowsOptions;
String projectBuildDir = scope String();
gApp.GetProjectBuildDir(project, projectBuildDir);
String cacheStr = scope String();
void AddBuildFileDependency(StringView filePath)
{
int64 fileTime = 0;
if (!filePath.IsEmpty)
fileTime = File.GetLastWriteTime(filePath).GetValueOrDefault().ToFileTime();
cacheStr.AppendF("{}\t{}\n", filePath, fileTime);
}
cacheStr.AppendF("Args\t{}\n", linkLine);
cacheStr.AppendF("Toolset\t{}\n", workspaceOptions.mToolsetType);
AddBuildFileDependency(project.mWindowsOptions.mIconFile);
AddBuildFileDependency(project.mWindowsOptions.mManifestFile);
cacheStr.AppendF("Description\t{}\n", project.mWindowsOptions.mDescription);
cacheStr.AppendF("Comments\t{}\n", project.mWindowsOptions.mComments);
cacheStr.AppendF("Company\t{}\n", project.mWindowsOptions.mCompany);
cacheStr.AppendF("Product\t{}\n", project.mWindowsOptions.mProduct);
cacheStr.AppendF("Copyright\t{}\n", project.mWindowsOptions.mCopyright);
cacheStr.AppendF("FileVersion\t{}\n", project.mWindowsOptions.mFileVersion);
cacheStr.AppendF("ProductVersion\t{}\n", project.mWindowsOptions.mProductVersion);
String prevCacheStr = scope .();
gApp.mBfBuildCompiler.GetBuildValue(projectBuildDir, "Link", prevCacheStr);
if (prevCacheStr != cacheStr)
{
project.mNeedsTargetRebuild = true;
gApp.mBfBuildCompiler.SetBuildValue(projectBuildDir, "Link", cacheStr);
gApp.mBfBuildCompiler.WriteBuildCache(projectBuildDir);
}
if (project.mNeedsTargetRebuild)
{
if ((!String.IsNullOrWhiteSpace(project.mWindowsOptions.mIconFile)) || if ((!String.IsNullOrWhiteSpace(project.mWindowsOptions.mIconFile)) ||
(!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) || (!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) ||
(winOptions.HasVersionInfo())) (winOptions.HasVersionInfo()))
{ {
String projectBuildDir = scope String();
gApp.GetProjectBuildDir(project, projectBuildDir);
String resOutPath = scope String(); String resOutPath = scope String();
resOutPath.Append(projectBuildDir, "\\Resource.res"); resOutPath.Append(projectBuildDir, "\\Resource.res");

View file

@ -70,6 +70,15 @@ namespace IDE.Compiler
[StdCall, CLink] [StdCall, CLink]
static extern void BfCompiler_ClearBuildCache(void* bfCompiler); static extern void BfCompiler_ClearBuildCache(void* bfCompiler);
[StdCall, CLink]
static extern void BfCompiler_SetBuildValue(void* bfCompiler, char8* cacheDir, char8* key, char8* value);
[StdCall, CLink]
static extern char8* BfCompiler_GetBuildValue(void* bfCompiler, char8* cacheDir, char8* key);
[StdCall, CLink]
static extern void BfCompiler_WriteBuildCache(void* bfCompiler, char8* cacheDir);
[StdCall, CLink] [StdCall, CLink]
static extern char8* BfCompiler_GetOutputFileNames(void* bfCompiler, void* bfProject, out bool hadOutputChanges); static extern char8* BfCompiler_GetOutputFileNames(void* bfCompiler, void* bfProject, out bool hadOutputChanges);
@ -591,6 +600,22 @@ namespace IDE.Compiler
BfCompiler_ClearBuildCache(mNativeBfCompiler); BfCompiler_ClearBuildCache(mNativeBfCompiler);
} }
public void SetBuildValue(String cacheDir, String key, String value)
{
BfCompiler_SetBuildValue(mNativeBfCompiler, cacheDir, key, value);
}
public void GetBuildValue(String cacheDir, String key, String outValue)
{
char8* cStr = BfCompiler_GetBuildValue(mNativeBfCompiler, cacheDir, key);
outValue.Append(cStr);
}
public void WriteBuildCache(String cacheDir)
{
BfCompiler_WriteBuildCache(mNativeBfCompiler, cacheDir);
}
public bool GetHasHotPendingDataChanges() public bool GetHasHotPendingDataChanges()
{ {
return BfCompiler_GetHasHotPendingDataChanges(mNativeBfCompiler); return BfCompiler_GetHasHotPendingDataChanges(mNativeBfCompiler);

View file

@ -85,6 +85,8 @@ namespace IDE
{ {
var editWidgetContent = (SourceEditWidgetContent)mEditWidget.mEditWidgetContent; var editWidgetContent = (SourceEditWidgetContent)mEditWidget.mEditWidgetContent;
mFileDeleted = !editWidgetContent.Reload(mFilePath, mQueuedContent); mFileDeleted = !editWidgetContent.Reload(mFilePath, mQueuedContent);
if (editWidgetContent.mSourceViewPanel.mLoadedHash.GetKind() == mLoadedHash.GetKind())
editWidgetContent.mSourceViewPanel.mLoadedHash = mLoadedHash;
mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId; mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
} }
return true; return true;

View file

@ -390,6 +390,11 @@ namespace IDE
{ {
mProject = project; mProject = project;
} }
public ~this()
{
}
} }
public enum ArgsFileKind public enum ArgsFileKind
@ -7319,6 +7324,13 @@ namespace IDE
if (ignoreCommand) if (ignoreCommand)
{ {
// Nothing // Nothing
if (let targetCompletedCmd = next as TargetCompletedCmd)
{
String projectBuildDir = scope String();
gApp.GetProjectBuildDir(targetCompletedCmd.mProject, projectBuildDir);
gApp.mBfBuildCompiler.SetBuildValue(projectBuildDir, "Link", "FAILED");
gApp.mBfBuildCompiler.WriteBuildCache(projectBuildDir);
}
} }
else if (next is ProcessBfCompileCmd) else if (next is ProcessBfCompileCmd)
{ {
@ -11105,6 +11117,8 @@ namespace IDE
if (mBuildContext != null) if (mBuildContext != null)
{ {
mBuildContext.mUpdateCnt++;
bool isCompiling = (!mExecutionInstances.IsEmpty) || (!mExecutionQueue.IsEmpty); bool isCompiling = (!mExecutionInstances.IsEmpty) || (!mExecutionQueue.IsEmpty);
if (mBuildContext.mScriptManager != null) if (mBuildContext.mScriptManager != null)
{ {
@ -11429,7 +11443,13 @@ namespace IDE
if (editData.mQueuedContent == null) if (editData.mQueuedContent == null)
editData.mQueuedContent = new String(); editData.mQueuedContent = new String();
editData.mQueuedContent.Clear(); editData.mQueuedContent.Clear();
if (LoadTextFile(fileName, editData.mQueuedContent, false) case .Err(let err)) if (LoadTextFile(fileName, editData.mQueuedContent, false, scope() =>
{
if (editData.mLoadedHash.GetKind() != .None)
{
editData.mLoadedHash = SourceHash.Create(editData.mLoadedHash.GetKind(), editData.mQueuedContent);
}
}) case .Err(let err))
{ {
if (err case .FileOpenError(.SharingViolation)) if (err case .FileOpenError(.SharingViolation))
{ {

View file

@ -952,15 +952,7 @@ namespace IDE.ui
for (var propEntry in propEntries) for (var propEntry in propEntries)
{ {
if (propEntry.HasChanged()) if (propEntry.HasChanged())
{ {
if (propEntry.mProperties != null)
{
bool wantsExeRebuild = false;
propEntry.mProperties.Get<bool>("RebuildTarget", out wantsExeRebuild);
if (wantsExeRebuild)
mProject.mNeedsTargetRebuild = true;
}
configDataHadChange = true; configDataHadChange = true;
propEntry.ApplyValue(); propEntry.ApplyValue();
} }

View file

@ -312,7 +312,7 @@ namespace IDE.ui
g.DrawString("Source Changed", GS!(200), GS!(-1.3f), FontAlign.Centered, GS!(120)); g.DrawString("Source Changed", GS!(200), GS!(-1.3f), FontAlign.Centered, GS!(120));
} }
void DrawStatusBox(StringView str) void DrawStatusBox(StringView str, int32 updateCnt = -1)
{ {
if (mStatusBoxUpdateCnt == -1) if (mStatusBoxUpdateCnt == -1)
mStatusBoxUpdateCnt = 0; mStatusBoxUpdateCnt = 0;
@ -325,7 +325,11 @@ namespace IDE.ui
completionRect.Inflate(-1, -1); completionRect.Inflate(-1, -1);
//float pulseSpeed = Math.Min(mStatusBoxUpdateCnt * 0.001f, 0.2f); //float pulseSpeed = Math.Min(mStatusBoxUpdateCnt * 0.001f, 0.2f);
float pulseSpeed = 0.2f; float pulseSpeed = 0.2f;
if (updateCnt != -1)
pulseSpeed = Math.Max(0.14f, pulseSpeed - updateCnt * 0.00005f);
float pulsePct = -Math.Cos(Math.Max(mStatusBoxUpdateCnt - 30, 0) * pulseSpeed); float pulsePct = -Math.Cos(Math.Max(mStatusBoxUpdateCnt - 30, 0) * pulseSpeed);
if (updateCnt != -1)
pulsePct *= Math.Max(0.4f, 1.0f - updateCnt * 0.0004f);
using (g.PushColor(Color.FromHSV(0.1f, 0.5f, (float)Math.Max(pulsePct * 0.15f + 0.3f, 0.3f)))) using (g.PushColor(Color.FromHSV(0.1f, 0.5f, (float)Math.Max(pulsePct * 0.15f + 0.3f, 0.3f))))
g.FillRect(completionRect.mX, completionRect.mY, completionRect.mWidth, completionRect.mHeight); g.FillRect(completionRect.mX, completionRect.mY, completionRect.mWidth, completionRect.mHeight);
@ -356,7 +360,7 @@ namespace IDE.ui
} }
else if ((gApp.mBuildContext != null) && (!completionPct.HasValue)) else if ((gApp.mBuildContext != null) && (!completionPct.HasValue))
{ {
DrawStatusBox("Custom Build Commands..."); DrawStatusBox("Custom Build Commands...", gApp.mBuildContext.mUpdateCnt);
} }
else else
mStatusBoxUpdateCnt = -1; mStatusBoxUpdateCnt = -1;

View file

@ -44,7 +44,7 @@
//#define DBG_FORCE_SYNCHRONIZED //#define DBG_FORCE_SYNCHRONIZED
// This is used for the Release DLL thunk and the build.dat file // 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 #undef DEBUG
@ -85,7 +85,8 @@ void BfCodeGenDirectoryData::Read()
return; return;
#endif #endif
while (!fileStream.Eof()) int numFiles = fileStream.ReadInt32();
for (int fileIdx = 0; fileIdx < numFiles; fileIdx++)
{ {
String fileName = fileStream.ReadAscii32SizedString(); String fileName = fileStream.ReadAscii32SizedString();
BfCodeGenFileData fileData; BfCodeGenFileData fileData;
@ -95,6 +96,14 @@ void BfCodeGenDirectoryData::Read()
mFileMap[fileName] = fileData; 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); mFileTime = GetFileTimeWrite(fileName);
} }
@ -129,6 +138,7 @@ void BfCodeGenDirectoryData::Write()
fileStream.Write(BF_CODEGEN_VERSION); fileStream.Write(BF_CODEGEN_VERSION);
fileStream.WriteT(mCodeGen->mBackendHash); fileStream.WriteT(mCodeGen->mBackendHash);
fileStream.Write((int)mFileMap.size());
for (auto& pair : mFileMap) for (auto& pair : mFileMap)
{ {
fileStream.Write(pair.mKey); fileStream.Write(pair.mKey);
@ -137,6 +147,13 @@ void BfCodeGenDirectoryData::Write()
fileStream.Write(&pair.mValue.mLastWasObjectWrite, sizeof(bool)); 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(); fileStream.Close();
mFileTime = GetFileTimeWrite(fileName); mFileTime = GetFileTimeWrite(fileName);
} }
@ -161,6 +178,7 @@ void BfCodeGenDirectoryData::Verify()
void BfCodeGenDirectoryData::Clear() void BfCodeGenDirectoryData::Clear()
{ {
mFileMap.Clear(); mFileMap.Clear();
mBuildSettings.Clear();
} }
bool BfCodeGenDirectoryData::CheckCache(const StringImpl& fileName, Val128 hash, Val128* outOrderedHash, bool disallowObjectWrite) bool BfCodeGenDirectoryData::CheckCache(const StringImpl& fileName, Val128 hash, Val128* outOrderedHash, bool disallowObjectWrite)
@ -211,6 +229,21 @@ void BfCodeGenDirectoryData::FileFailed()
mFileFailed = true; 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() void BfCodeGenRequest::DbgSaveData()
@ -285,22 +318,8 @@ void BfCodeGenThread::RunLoop()
#ifndef CODEGEN_DISABLE_CACHE #ifndef CODEGEN_DISABLE_CACHE
{ {
AutoCrit autoCrit(mCodeGen->mCacheCritSect); AutoCrit autoCrit(mCodeGen->mCacheCritSect);
dirCache = mCodeGen->GetDirCache(cacheDir);
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;
}
//For testing only! //For testing only!
/*{ /*{
@ -872,6 +891,27 @@ void BfCodeGen::WriteObjectFile(BfModule* bfModule, const StringImpl& outFileNam
#endif #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) void BfCodeGen::RequestComplete(BfCodeGenRequest* request)
{ {
mCompletionCount++; 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() void BfCodeGen::Cancel()
{ {
for (auto thread : mThreads) for (auto thread : mThreads)

View file

@ -111,6 +111,7 @@ class BfCodeGenDirectoryData
public: public:
BfCodeGen* mCodeGen; BfCodeGen* mCodeGen;
Dictionary<String, BfCodeGenFileData> mFileMap; Dictionary<String, BfCodeGenFileData> mFileMap;
Dictionary<String, String> mBuildSettings;
String mDirectoryName; String mDirectoryName;
bool mDirty; bool mDirty;
bool mVerified; bool mVerified;
@ -137,6 +138,8 @@ public:
void SetHash(const StringImpl& fileName, Val128 hash, Val128 orderedHash, bool isObjectWrite); void SetHash(const StringImpl& fileName, Val128 hash, Val128 orderedHash, bool isObjectWrite);
void ClearHash(const StringImpl& fileName); void ClearHash(const StringImpl& fileName);
void FileFailed(); void FileFailed();
String GetValue(const StringImpl& key);
void SetValue(const StringImpl& key, const StringImpl& value);
}; };
class BfCodeGenFileEntry class BfCodeGenFileEntry
@ -202,6 +205,7 @@ public:
void ClearBuildCache(); void ClearBuildCache();
void RequestComplete(BfCodeGenRequest* request); void RequestComplete(BfCodeGenRequest* request);
void ProcessErrors(BfPassInstance* passInstance, bool canceled); void ProcessErrors(BfPassInstance* passInstance, bool canceled);
BfCodeGenDirectoryData* GetDirCache(const StringImpl& cacheDir);
public: public:
BfCodeGen(); BfCodeGen();
@ -209,7 +213,10 @@ public:
void ResetStats(); void ResetStats();
void UpdateStats(); 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(); void Cancel();
bool Finish(); bool Finish();
}; };

View file

@ -7790,6 +7790,23 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_ClearBuildCache(BfCompiler* bfCompiler)
bfCompiler->ClearBuildCache(); 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) BF_EXPORT void BF_CALLTYPE BfCompiler_Delete(BfCompiler* bfCompiler)
{ {
delete bfCompiler; delete bfCompiler;
@ -8210,3 +8227,4 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_ForceRebuild(BfCompiler* bfCompiler)
{ {
bfCompiler->mOptions.mForceRebuildIdx++; bfCompiler->mOptions.mForceRebuildIdx++;
} }

View file

@ -10937,7 +10937,10 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
{ {
// Just leave the new items // Just leave the new items
projectList.RemoveRange(0, typeProjectsCounts); 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 else
{ {