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

Fixed 'Start Without Debugging' vs 'Start Without Compiling'

This commit is contained in:
Brian Fiete 2020-05-13 12:28:20 -07:00
parent 25b8cdc808
commit 9010d8ed47
4 changed files with 109 additions and 45 deletions

View file

@ -8,6 +8,22 @@ using IDE.util;
namespace IDE namespace IDE
{ {
enum CompileKind
{
case Normal;
case RunAfter;
case DebugAfter;
case Test;
public bool WantsRunAfter
{
get
{
return (this == .RunAfter) || (this == .DebugAfter);
}
}
}
class BuildContext class BuildContext
{ {
public int32 mUpdateCnt; public int32 mUpdateCnt;
@ -949,7 +965,7 @@ namespace IDE
return true; return true;
} }
public bool QueueProjectCompile(Project project, Project hotProject, IDEApp.BuildCompletedCmd completedCompileCmd, List<String> hotFileNames, bool runAfter) public bool QueueProjectCompile(Project project, Project hotProject, IDEApp.BuildCompletedCmd completedCompileCmd, List<String> hotFileNames, CompileKind compileKind)
{ {
project.mLastDidBuild = false; project.mLastDidBuild = false;
@ -1045,7 +1061,7 @@ namespace IDE
if (hotProject == null) if (hotProject == null)
{ {
switch (QueueProjectCustomBuildCommands(project, targetPath, runAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPreBuildCmds)) switch (QueueProjectCustomBuildCommands(project, targetPath, compileKind.WantsRunAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPreBuildCmds))
{ {
case .NoCommands: case .NoCommands:
case .HadCommands: case .HadCommands:
@ -1056,7 +1072,7 @@ namespace IDE
void DoPostBuild() void DoPostBuild()
{ {
switch (QueueProjectCustomBuildCommands(project, targetPath, runAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPostBuildCmds)) switch (QueueProjectCustomBuildCommands(project, targetPath, compileKind.WantsRunAfter ? options.mBuildOptions.mBuildCommandsOnRun : options.mBuildOptions.mBuildCommandsOnCompile, options.mBuildOptions.mPostBuildCmds))
{ {
case .NoCommands: case .NoCommands:
case .HadCommands: case .HadCommands:

View file

@ -265,7 +265,8 @@ namespace IDE
Add("Show Watches", new => gApp.ShowWatches); Add("Show Watches", new => gApp.ShowWatches);
Add("Show Workspace Explorer", new => gApp.ShowWorkspacePanel); Add("Show Workspace Explorer", new => gApp.ShowWorkspacePanel);
Add("Start Debugging", new => gApp.[Friend]RunWithCompiling); Add("Start Debugging", new => gApp.[Friend]RunWithCompiling);
Add("Start Without Debugging", new => gApp.[Friend]RunWithoutCompiling); Add("Start Without Debugging", new => gApp.[Friend]RunWithoutDebugging);
Add("Start Without Compiling", new => gApp.[Friend]RunWithoutCompiling);
Add("Step Into", new => gApp.[Friend]StepInto); Add("Step Into", new => gApp.[Friend]StepInto);
Add("Step Out", new => gApp.[Friend]StepOut); Add("Step Out", new => gApp.[Friend]StepOut);
Add("Step Over", new => gApp.[Friend]StepOver); Add("Step Over", new => gApp.[Friend]StepOver);

View file

@ -362,7 +362,7 @@ namespace IDE
class ProcessBfCompileCmd : ExecutionCmd class ProcessBfCompileCmd : ExecutionCmd
{ {
public BfPassInstance mBfPassInstance; public BfPassInstance mBfPassInstance;
public bool mRunAfter; public CompileKind mCompileKind;
public Project mHotProject; public Project mHotProject;
public Stopwatch mStopwatch ~ delete _; public Stopwatch mStopwatch ~ delete _;
public Profiler mProfiler; public Profiler mProfiler;
@ -424,6 +424,7 @@ namespace IDE
public int32 mParallelGroup = -1; public int32 mParallelGroup = -1;
public bool mIsTargetRun; public bool mIsTargetRun;
public String mStdInData ~ delete _; public String mStdInData ~ delete _;
public RunFlags mRunFlags;
} }
public List<ExecutionCmd> mExecutionQueue = new List<ExecutionCmd>() ~ DeleteContainerAndItems!(_); public List<ExecutionCmd> mExecutionQueue = new List<ExecutionCmd>() ~ DeleteContainerAndItems!(_);
@ -3959,7 +3960,7 @@ namespace IDE
void RunWithStep() void RunWithStep()
{ {
mTargetStartWithStep = true; mTargetStartWithStep = true;
CompileAndRun(); CompileAndRun(true);
} }
[IDECommand] [IDECommand]
@ -4043,7 +4044,7 @@ namespace IDE
else else
{ {
mTargetStartWithStep = false; mTargetStartWithStep = false;
CompileAndRun(); CompileAndRun(true);
} }
} }
@ -4061,6 +4062,28 @@ namespace IDE
} }
} }
[IDECommand]
void RunWithoutDebugging()
{
if (mDebugger.mIsRunning)
{
if (mDebugger.IsPaused())
{
DebuggerUnpaused();
mDebugger.Continue();
}
}
else if (AreTestsRunning())
{
// Ignore
}
else
{
mTargetStartWithStep = false;
CompileAndRun(false);
}
}
[IDECommand] [IDECommand]
void RunToCursor() void RunToCursor()
{ {
@ -4094,7 +4117,7 @@ namespace IDE
else else
{ {
mTargetStartWithStep = false; mTargetStartWithStep = false;
CompileAndRun(); CompileAndRun(true);
} }
} }
@ -5059,6 +5082,7 @@ namespace IDE
subMenu = root.AddMenuItem("&Debug"); subMenu = root.AddMenuItem("&Debug");
AddMenuItem(subMenu, "&Start Debugging", "Start Debugging", new => UpdateMenuItem_DebugStopped_HasWorkspace); AddMenuItem(subMenu, "&Start Debugging", "Start Debugging", new => UpdateMenuItem_DebugStopped_HasWorkspace);
AddMenuItem(subMenu, "Start Wit&hout Debugging", "Start Without Debugging", new => UpdateMenuItem_DebugStopped_HasWorkspace); AddMenuItem(subMenu, "Start Wit&hout Debugging", "Start Without Debugging", new => UpdateMenuItem_DebugStopped_HasWorkspace);
AddMenuItem(subMenu, "Start With&out Compiling", "Start Without Compiling", new => UpdateMenuItem_DebugStopped_HasWorkspace);
AddMenuItem(subMenu, "&Launch Process...", "Launch Process", new => UpdateMenuItem_DebugStopped); AddMenuItem(subMenu, "&Launch Process...", "Launch Process", new => UpdateMenuItem_DebugStopped);
AddMenuItem(subMenu, "&Attach to Process...", "Attach to Process", new => UpdateMenuItem_DebugStopped); AddMenuItem(subMenu, "&Attach to Process...", "Attach to Process", new => UpdateMenuItem_DebugStopped);
AddMenuItem(subMenu, "&Stop Debugging", "Stop Debugging", new => UpdateMenuItem_DebugNotPaused); AddMenuItem(subMenu, "&Stop Debugging", "Stop Debugging", new => UpdateMenuItem_DebugNotPaused);
@ -7410,7 +7434,9 @@ namespace IDE
public enum RunFlags public enum RunFlags
{ {
None, None,
ShellCommand = 1 ShellCommand = 1,
NoRedirect = 2,
NoWait = 4,
} }
public ExecutionInstance DoRun(String inFileName, String args, String workingDir, ArgsFileKind useArgsFile, Dictionary<String, String> envVars = null, String stdInData = null, RunFlags runFlags = .None) public ExecutionInstance DoRun(String inFileName, String args, String workingDir, ArgsFileKind useArgsFile, Dictionary<String, String> envVars = null, String stdInData = null, RunFlags runFlags = .None)
@ -7426,11 +7452,14 @@ namespace IDE
startInfo.SetFileName(fileName); startInfo.SetFileName(fileName);
startInfo.SetWorkingDirectory(workingDir); startInfo.SetWorkingDirectory(workingDir);
startInfo.SetArguments(args); startInfo.SetArguments(args);
startInfo.RedirectStandardOutput = true; if ((!runFlags.HasFlag(.NoRedirect)) && (!runFlags.HasFlag(.NoWait)))
startInfo.RedirectStandardError = true; {
if (stdInData != null) startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true; startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true; if (stdInData != null)
startInfo.RedirectStandardInput = true;
startInfo.CreateNoWindow = true;
}
if (runFlags.HasFlag(.ShellCommand)) if (runFlags.HasFlag(.ShellCommand))
{ {
@ -7450,7 +7479,6 @@ namespace IDE
} }
var executionInstance = new ExecutionInstance(); var executionInstance = new ExecutionInstance();
mExecutionInstances.Add(executionInstance);
if (useArgsFile != .None) if (useArgsFile != .None)
{ {
@ -7511,6 +7539,14 @@ namespace IDE
return executionInstance; return executionInstance;
} }
if (runFlags.HasFlag(.NoWait))
{
delete process;
delete executionInstance;
return null;
}
mExecutionInstances.Add(executionInstance);
executionInstance.mStopwatch.Start(); executionInstance.mStopwatch.Start();
executionInstance.mProcess = process; executionInstance.mProcess = process;
@ -7764,7 +7800,7 @@ namespace IDE
compileInstance.mCompileResult = .Failure; compileInstance.mCompileResult = .Failure;
} }
ProcessBeefCompileResults(processCompileCmd.mBfPassInstance, processCompileCmd.mRunAfter, processCompileCmd.mHotProject, processCompileCmd.mStopwatch); ProcessBeefCompileResults(processCompileCmd.mBfPassInstance, processCompileCmd.mCompileKind, processCompileCmd.mHotProject, processCompileCmd.mStopwatch);
if (mHotResolveState != .None) if (mHotResolveState != .None)
{ {
if (compileInstance.mCompileResult == .Success) if (compileInstance.mCompileResult == .Success)
@ -7794,7 +7830,7 @@ namespace IDE
if (!buildFailed) if (!buildFailed)
{ {
var startDebugCmd = (StartDebugCmd)next; var startDebugCmd = (StartDebugCmd)next;
if (DebugProject(startDebugCmd.mWasCompiled)) if (StartupProject(true, startDebugCmd.mWasCompiled))
{ {
OutputLine("Debugger started"); OutputLine("Debugger started");
} }
@ -7805,9 +7841,12 @@ namespace IDE
else if (next is ExecutionQueueCmd) else if (next is ExecutionQueueCmd)
{ {
var executionQueueCmd = (ExecutionQueueCmd)next; var executionQueueCmd = (ExecutionQueueCmd)next;
var executionInstance = DoRun(executionQueueCmd.mFileName, executionQueueCmd.mArgs, executionQueueCmd.mWorkingDir, executionQueueCmd.mUseArgsFile, executionQueueCmd.mEnvVars, executionQueueCmd.mStdInData); var executionInstance = DoRun(executionQueueCmd.mFileName, executionQueueCmd.mArgs, executionQueueCmd.mWorkingDir, executionQueueCmd.mUseArgsFile, executionQueueCmd.mEnvVars, executionQueueCmd.mStdInData, executionQueueCmd.mRunFlags);
executionInstance.mParallelGroup = executionQueueCmd.mParallelGroup; if (executionInstance != null)
executionInstance.mIsTargetRun = executionQueueCmd.mIsTargetRun; {
executionInstance.mParallelGroup = executionQueueCmd.mParallelGroup;
executionInstance.mIsTargetRun = executionQueueCmd.mIsTargetRun;
}
} }
else if (next is BuildCompletedCmd) else if (next is BuildCompletedCmd)
{ {
@ -9419,7 +9458,7 @@ namespace IDE
} }
} }
void ProcessBeefCompileResults(BfPassInstance passInstance, bool runAfter, Project hotProject, Stopwatch startStopWatch) void ProcessBeefCompileResults(BfPassInstance passInstance, CompileKind compileKind, Project hotProject, Stopwatch startStopWatch)
{ {
bool didCompileSucceed = true; bool didCompileSucceed = true;
if (passInstance != null) if (passInstance != null)
@ -9555,7 +9594,7 @@ namespace IDE
for (var project in orderedProjectList) for (var project in orderedProjectList)
{ {
if (!mBuildContext.QueueProjectCompile(project, hotProject, completedCompileCmd, hotFileNames, runAfter)) if (!mBuildContext.QueueProjectCompile(project, hotProject, completedCompileCmd, hotFileNames, compileKind))
success = false; success = false;
} }
@ -9583,15 +9622,22 @@ namespace IDE
if (!success) if (!success)
CompileFailed(); CompileFailed();
if ((runAfter) && (success)) if (success)
{ {
var options = GetCurWorkspaceOptions(); var options = GetCurWorkspaceOptions();
var startDebugCmd = new StartDebugCmd(); if (compileKind == .DebugAfter)
startDebugCmd.mWasCompiled = true; {
startDebugCmd.mOnlyIfNotFailed = true; var startDebugCmd = new StartDebugCmd();
startDebugCmd.mHotCompileEnabled = options.mAllowHotSwapping; startDebugCmd.mWasCompiled = true;
mExecutionQueue.Add(startDebugCmd); startDebugCmd.mOnlyIfNotFailed = true;
startDebugCmd.mHotCompileEnabled = options.mAllowHotSwapping;
mExecutionQueue.Add(startDebugCmd);
}
else if (compileKind == .RunAfter)
{
StartupProject(false, true);
}
} }
if (startStopWatch != null) if (startStopWatch != null)
@ -9604,7 +9650,7 @@ namespace IDE
mExecutionQueue.Add(completedCompileCmd); mExecutionQueue.Add(completedCompileCmd);
} }
bool CompileAndRun() bool CompileAndRun(bool debug)
{ {
if (AreTestsRunning()) if (AreTestsRunning())
return false; return false;
@ -9615,7 +9661,7 @@ namespace IDE
{ {
if (var processCompileCmd = mExecutionQueue.Back as ProcessBfCompileCmd) if (var processCompileCmd = mExecutionQueue.Back as ProcessBfCompileCmd)
{ {
processCompileCmd.mRunAfter = true; processCompileCmd.mCompileKind = debug ? .DebugAfter : .RunAfter;
} }
return false; return false;
@ -9626,7 +9672,7 @@ namespace IDE
mOutputPanel.Clear(); mOutputPanel.Clear();
OutputLine("Compiling..."); OutputLine("Compiling...");
if (!Compile(.RunAfter)) if (!Compile(debug ? .DebugAfter : .RunAfter))
return false; return false;
return true; return true;
} }
@ -9666,13 +9712,6 @@ namespace IDE
} }
} }
enum CompileKind
{
Normal,
RunAfter,
Test
}
public void AutoGenerateStartupCode(Project project) public void AutoGenerateStartupCode(Project project)
{ {
// We have to save this to ensure any new project is actually created. Maybe overkill, // We have to save this to ensure any new project is actually created. Maybe overkill,
@ -9882,7 +9921,7 @@ namespace IDE
} }
var workspaceOptions = GetCurWorkspaceOptions(); var workspaceOptions = GetCurWorkspaceOptions();
if (compileKind == .RunAfter) if ((compileKind == .RunAfter) || (compileKind == .DebugAfter))
{ {
if (workspaceOptions.mBuildKind == .Test) if (workspaceOptions.mBuildKind == .Test)
{ {
@ -9995,7 +10034,7 @@ namespace IDE
SaveClangFiles(); SaveClangFiles();
if (compileKind == .RunAfter) if ((compileKind == .RunAfter) || (compileKind == .DebugAfter))
{ {
DeleteAndNullify!(mCompileAndRunStopwatch); DeleteAndNullify!(mCompileAndRunStopwatch);
mCompileAndRunStopwatch = new Stopwatch(); mCompileAndRunStopwatch = new Stopwatch();
@ -10016,7 +10055,7 @@ namespace IDE
ProcessBfCompileCmd processCompileCmd = new ProcessBfCompileCmd(); ProcessBfCompileCmd processCompileCmd = new ProcessBfCompileCmd();
processCompileCmd.mBfPassInstance = passInstance; processCompileCmd.mBfPassInstance = passInstance;
processCompileCmd.mRunAfter = compileKind == .RunAfter; processCompileCmd.mCompileKind = compileKind;
processCompileCmd.mHotProject = hotProject; processCompileCmd.mHotProject = hotProject;
processCompileCmd.mStopwatch = new Stopwatch(); processCompileCmd.mStopwatch = new Stopwatch();
processCompileCmd.mStopwatch.Start(); processCompileCmd.mStopwatch.Start();
@ -10050,7 +10089,7 @@ namespace IDE
//mDebugger.LoadDebugVisualizers(scope String(mInstallDir, "BeefDbgVis.toml")); //mDebugger.LoadDebugVisualizers(scope String(mInstallDir, "BeefDbgVis.toml"));
} }
bool DebugProject(bool wasCompiled) bool StartupProject(bool doDebug, bool wasCompiled)
{ {
mProfilePanel.Clear(); mProfilePanel.Clear();
@ -10131,6 +10170,13 @@ namespace IDE
return false; return false;
} }
if (!doDebug)
{
let runCmd = QueueRun(launchPath, arguments, workingDir, .None);
runCmd.mRunFlags |= .NoWait;
return true;
}
if (!mDebugger.OpenFile(launchPath, targetPath, arguments, workingDir, envBlock, wasCompiled, workspaceOptions.mAllowHotSwapping)) if (!mDebugger.OpenFile(launchPath, targetPath, arguments, workingDir, envBlock, wasCompiled, workspaceOptions.mAllowHotSwapping))
{ {
DeleteAndNullify!(mCompileAndRunStopwatch); DeleteAndNullify!(mCompileAndRunStopwatch);
@ -10663,7 +10709,7 @@ namespace IDE
if (mLaunchData.mPaused) if (mLaunchData.mPaused)
RunWithStep(); RunWithStep();
else else
CompileAndRun(); CompileAndRun(true);
} }
else else
LaunchDialog.DoLaunch(null, mLaunchData.mTargetPath, mLaunchData.mArgs ?? "", mLaunchData.mWorkingDir ?? "", "", mLaunchData.mPaused, true); LaunchDialog.DoLaunch(null, mLaunchData.mTargetPath, mLaunchData.mArgs ?? "", mLaunchData.mWorkingDir ?? "", "", mLaunchData.mPaused, true);
@ -11027,7 +11073,7 @@ namespace IDE
if (hotResult.IsEmpty) if (hotResult.IsEmpty)
{ {
//OutputLineSmart("Hot type data changes have been resolved"); //OutputLineSmart("Hot type data changes have been resolved");
ProcessBeefCompileResults(null, false, mWorkspace.mStartupProject, null); ProcessBeefCompileResults(null, .Normal, mWorkspace.mStartupProject, null);
} }
else else
{ {
@ -12550,7 +12596,7 @@ namespace IDE
else else
{ {
mTargetStartWithStep = false; mTargetStartWithStep = false;
CompileAndRun(); CompileAndRun(true);
mRunTestDelay = 200; mRunTestDelay = 200;
} }
} }

View file

@ -500,6 +500,7 @@ namespace IDE
Add("Show Workspace Explorer", "Ctrl+Alt+S"); Add("Show Workspace Explorer", "Ctrl+Alt+S");
Add("Start Debugging", "F5"); Add("Start Debugging", "F5");
Add("Start Without Debugging", "Ctrl+F5"); Add("Start Without Debugging", "Ctrl+F5");
Add("Start Without Compiling", "Alt+F5");
Add("Step Into", "F11"); Add("Step Into", "F11");
Add("Step Out", "Shift+F11"); Add("Step Out", "Shift+F11");
Add("Step Over", "F10"); Add("Step Over", "F10");