From e7540ddef042595ef3f04b1ceeb9c8b18c3a4d90 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 16 Apr 2020 00:33:29 -0700 Subject: [PATCH] Properply rebuilds hash after a hot compile --- IDE/src/Compiler/CompilerBase.bf | 12 ++++++++---- IDE/src/IDEApp.bf | 17 +++++++++++++---- IDE/src/Project.bf | 2 ++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/IDE/src/Compiler/CompilerBase.bf b/IDE/src/Compiler/CompilerBase.bf index 24cba0bd..310b78ae 100644 --- a/IDE/src/Compiler/CompilerBase.bf +++ b/IDE/src/Compiler/CompilerBase.bf @@ -62,13 +62,17 @@ namespace IDE.Compiler ProjectSourceCommand command = new ProjectSourceCommand(); command.mProjectSource = projectSource; command.mSourceString = new String(); - command.mSourceHash = sourceHash; - + var wantsHash; - if (!(sourceHash case .None)) - wantsHash = false; IDEApp.sApp.FindProjectSourceContent(projectSource, out command.mSourceCharIdData, false, command.mSourceString, wantsHash ? &command.mSourceHash : null); + if (!(sourceHash case .None)) + { + if (command.mSourceHash != sourceHash) + projectSource.mWasBuiltWithOldHash = true; + command.mSourceHash = sourceHash; + } + if (gApp.mBfBuildCompiler == this) { if (gApp.mDbgVersionedCompileDir != null) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index abf97c5e..89f33416 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -7982,17 +7982,26 @@ namespace IDE } else // Actual build { - if ((projectSource.HasChangedSinceLastCompile) || (projectSource.mLoadFailed) || (forceQueue)) + bool wantsHashRefresh = false; + if ((hotProject == null) && (projectSource.mWasBuiltWithOldHash)) + wantsHashRefresh = true; + + if ((projectSource.HasChangedSinceLastCompile) || (projectSource.mLoadFailed) || (forceQueue) || (wantsHashRefresh)) { // mHasChangedSinceLastCompile is safe to set 'false' here since it just determines whether or not // we rebuild the TypeDefs from the sources. It isn't affected by any compilation errors. projectSource.mHasChangedSinceLastCompile = false; + projectSource.mWasBuiltWithOldHash = false; SourceHash sourceHash = .None; - if ((hotProject != null) && (!mWorkspace.mCompileInstanceList.IsEmpty)) + + if (hotProject != null) { - let compileInstance = mWorkspace.GetProjectSourceCompileInstance(projectSource, 0); - sourceHash = compileInstance.mSourceHash; + if (!mWorkspace.mCompileInstanceList.IsEmpty) + { + let compileInstance = mWorkspace.GetProjectSourceCompileInstance(projectSource, 0); + sourceHash = compileInstance.mSourceHash; + } } bfCompiler.QueueProjectSource(projectSource, sourceHash, !bfCompiler.mIsResolveOnly); diff --git a/IDE/src/Project.bf b/IDE/src/Project.bf index 35c5baa7..0eb35816 100644 --- a/IDE/src/Project.bf +++ b/IDE/src/Project.bf @@ -13,6 +13,7 @@ using IDE.ui; using IDE.Util; using System.Threading; using System.Diagnostics; +using IDE.util; namespace IDE { @@ -276,6 +277,7 @@ namespace IDE public FileEditData mEditData; public bool mHasChangedSinceLastCompile = true; + public bool mWasBuiltWithOldHash; public bool mHasChangedSinceLastSuccessfulCompile = true; public bool mLoadFailed; public bool HasChangedSinceLastCompile