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
|
@ -10,6 +10,7 @@ namespace IDE
|
|||
{
|
||||
class BuildContext
|
||||
{
|
||||
public int32 mUpdateCnt;
|
||||
public Project mHotProject;
|
||||
public Workspace.Options mWorkspaceOptions;
|
||||
public Dictionary<Project, String> mImpLibMap = new .() ~
|
||||
|
@ -567,113 +568,144 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
if (project.mNeedsTargetRebuild)
|
||||
{
|
||||
/*if (File.Delete(targetPath).Failed(true))
|
||||
{
|
||||
OutputLine("Failed to delete {0}", targetPath);
|
||||
return false;
|
||||
}*/
|
||||
/*if (File.Delete(targetPath).Failed(true))
|
||||
{
|
||||
OutputLine("Failed to delete {0}", targetPath);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
switch (options.mBuildOptions.mCLibType)
|
||||
{
|
||||
case .None:
|
||||
linkLine.Append("-nodefaultlib ");
|
||||
case .Dynamic:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt ");
|
||||
linkLine.Append("-defaultlib:msvcrt ");
|
||||
case .Static:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmt " : "-defaultlib:libcmt ");
|
||||
linkLine.Append("-defaultlib:libcmt ");
|
||||
case .DynamicDebug:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprtd " : "-defaultlib:msvcrtd ");
|
||||
linkLine.Append("-defaultlib:msvcrtd ");
|
||||
case .StaticDebug:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmtd " : "-defaultlib:libcmtd ");
|
||||
linkLine.Append("-defaultlib:libcmtd ");
|
||||
case .SystemMSVCRT:
|
||||
linkLine.Append("-nodefaultlib ");
|
||||
switch (options.mBuildOptions.mCLibType)
|
||||
{
|
||||
case .None:
|
||||
linkLine.Append("-nodefaultlib ");
|
||||
case .Dynamic:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt ");
|
||||
linkLine.Append("-defaultlib:msvcrt ");
|
||||
case .Static:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmt " : "-defaultlib:libcmt ");
|
||||
linkLine.Append("-defaultlib:libcmt ");
|
||||
case .DynamicDebug:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprtd " : "-defaultlib:msvcrtd ");
|
||||
linkLine.Append("-defaultlib:msvcrtd ");
|
||||
case .StaticDebug:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:libcpmtd " : "-defaultlib:libcmtd ");
|
||||
linkLine.Append("-defaultlib:libcmtd ");
|
||||
case .SystemMSVCRT:
|
||||
linkLine.Append("-nodefaultlib ");
|
||||
|
||||
String minRTModName = scope String();
|
||||
if ((project.mGeneralOptions.mTargetType == .BeefWindowsApplication) ||
|
||||
(project.mGeneralOptions.mTargetType == .C_WindowsApplication))
|
||||
minRTModName.Append("g");
|
||||
if (options.mBuildOptions.mBeefLibType == .DynamicDebug)
|
||||
minRTModName.Append("d");
|
||||
if (!minRTModName.IsEmpty)
|
||||
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 ");
|
||||
String minRTModName = scope String();
|
||||
if ((project.mGeneralOptions.mTargetType == .BeefWindowsApplication) ||
|
||||
(project.mGeneralOptions.mTargetType == .C_WindowsApplication))
|
||||
minRTModName.Append("g");
|
||||
if (options.mBuildOptions.mBeefLibType == .DynamicDebug)
|
||||
minRTModName.Append("d");
|
||||
if (!minRTModName.IsEmpty)
|
||||
minRTModName.Insert(0, "_");
|
||||
|
||||
if (workspaceOptions.mMachineType == .x86)
|
||||
{
|
||||
for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths)
|
||||
{
|
||||
linkLine.AppendF("-libpath:\"{0}\" ", libPath);
|
||||
}
|
||||
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\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)
|
||||
{
|
||||
for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths)
|
||||
{
|
||||
for (var libPath in gApp.mSettings.mVSSettings.mLib64Paths)
|
||||
{
|
||||
linkLine.AppendF("-libpath:\"{0}\" ", libPath);
|
||||
}
|
||||
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x64\" ");
|
||||
linkLine.AppendF("-libpath:\"{0}\" ", libPath);
|
||||
}
|
||||
|
||||
String targetDir = scope String();
|
||||
Path.GetDirectoryPath(targetPath, targetDir);
|
||||
linkLine.Append("-libpath:");
|
||||
IDEUtils.AppendWithOptionalQuotes(linkLine, targetDir);
|
||||
linkLine.Append(" ");
|
||||
|
||||
if (options.mBuildOptions.mOtherLinkFlags.Length != 0)
|
||||
linkLine.Append("-libpath:\"", gApp.mInstallDir, "lib\\x86\" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var libPath in gApp.mSettings.mVSSettings.mLib64Paths)
|
||||
{
|
||||
var linkFlags = scope String();
|
||||
gApp.ResolveConfigString(workspaceOptions, project, options, options.mBuildOptions.mOtherLinkFlags, "link flags", linkFlags);
|
||||
linkLine.Append(linkFlags, " ");
|
||||
linkLine.AppendF("-libpath:\"{0}\" ", libPath);
|
||||
}
|
||||
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)) ||
|
||||
(!String.IsNullOrWhiteSpace(project.mWindowsOptions.mManifestFile)) ||
|
||||
(winOptions.HasVersionInfo()))
|
||||
{
|
||||
String projectBuildDir = scope String();
|
||||
gApp.GetProjectBuildDir(project, projectBuildDir);
|
||||
|
||||
{
|
||||
String resOutPath = scope String();
|
||||
resOutPath.Append(projectBuildDir, "\\Resource.res");
|
||||
|
||||
|
|
|
@ -70,6 +70,15 @@ namespace IDE.Compiler
|
|||
[StdCall, CLink]
|
||||
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]
|
||||
static extern char8* BfCompiler_GetOutputFileNames(void* bfCompiler, void* bfProject, out bool hadOutputChanges);
|
||||
|
||||
|
@ -591,6 +600,22 @@ namespace IDE.Compiler
|
|||
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()
|
||||
{
|
||||
return BfCompiler_GetHasHotPendingDataChanges(mNativeBfCompiler);
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace IDE
|
|||
{
|
||||
var editWidgetContent = (SourceEditWidgetContent)mEditWidget.mEditWidgetContent;
|
||||
mFileDeleted = !editWidgetContent.Reload(mFilePath, mQueuedContent);
|
||||
if (editWidgetContent.mSourceViewPanel.mLoadedHash.GetKind() == mLoadedHash.GetKind())
|
||||
editWidgetContent.mSourceViewPanel.mLoadedHash = mLoadedHash;
|
||||
mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -390,6 +390,11 @@ namespace IDE
|
|||
{
|
||||
mProject = project;
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public enum ArgsFileKind
|
||||
|
@ -7319,6 +7324,13 @@ namespace IDE
|
|||
if (ignoreCommand)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
@ -11105,6 +11117,8 @@ namespace IDE
|
|||
|
||||
if (mBuildContext != null)
|
||||
{
|
||||
mBuildContext.mUpdateCnt++;
|
||||
|
||||
bool isCompiling = (!mExecutionInstances.IsEmpty) || (!mExecutionQueue.IsEmpty);
|
||||
if (mBuildContext.mScriptManager != null)
|
||||
{
|
||||
|
@ -11429,7 +11443,13 @@ namespace IDE
|
|||
if (editData.mQueuedContent == null)
|
||||
editData.mQueuedContent = new String();
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -952,15 +952,7 @@ namespace IDE.ui
|
|||
for (var propEntry in propEntries)
|
||||
{
|
||||
if (propEntry.HasChanged())
|
||||
{
|
||||
if (propEntry.mProperties != null)
|
||||
{
|
||||
bool wantsExeRebuild = false;
|
||||
propEntry.mProperties.Get<bool>("RebuildTarget", out wantsExeRebuild);
|
||||
if (wantsExeRebuild)
|
||||
mProject.mNeedsTargetRebuild = true;
|
||||
}
|
||||
|
||||
{
|
||||
configDataHadChange = true;
|
||||
propEntry.ApplyValue();
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ namespace IDE.ui
|
|||
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)
|
||||
mStatusBoxUpdateCnt = 0;
|
||||
|
@ -325,7 +325,11 @@ namespace IDE.ui
|
|||
completionRect.Inflate(-1, -1);
|
||||
//float pulseSpeed = Math.Min(mStatusBoxUpdateCnt * 0.001f, 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);
|
||||
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))))
|
||||
g.FillRect(completionRect.mX, completionRect.mY, completionRect.mWidth, completionRect.mHeight);
|
||||
|
||||
|
@ -356,7 +360,7 @@ namespace IDE.ui
|
|||
}
|
||||
else if ((gApp.mBuildContext != null) && (!completionPct.HasValue))
|
||||
{
|
||||
DrawStatusBox("Custom Build Commands...");
|
||||
DrawStatusBox("Custom Build Commands...", gApp.mBuildContext.mUpdateCnt);
|
||||
}
|
||||
else
|
||||
mStatusBoxUpdateCnt = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue