Skip to content

Commit

Permalink
ide; improvements to Debug Precompile/Compile/GenerateSymbols. added …
Browse files Browse the repository at this point in the history
…Debug Pre/Compile for project node (.main.ec file) and fixed Debug GenSymbols. calling Compile/Build before Debug Pre/Compile/GenSym. improved 'just print' output. closes #777
  • Loading branch information
redj authored and jerstlouis committed May 20, 2013
1 parent b244397 commit ad4918f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 38 deletions.
2 changes: 1 addition & 1 deletion ide/src/debugger/Debugger.ec
Expand Up @@ -1419,7 +1419,7 @@ class Debugger
if(gdbHandle)
{
// TODO: Improve this limit
static char string[MAX_F_STRING*3];
static char string[MAX_F_STRING*4];
va_list args;
va_start(args, format);
vsnprintf(string, sizeof(string), format, args);
Expand Down
5 changes: 0 additions & 5 deletions ide/src/ide.ec
Expand Up @@ -1586,11 +1586,6 @@ class IDEWorkSpace : Window
return false;
}

bool ShouldStopBuild()
{
return projectView.stopBuild;
}

void DocumentSaved(Window document, char * fileName)
{
ideSettings.AddRecentFile(fileName);
Expand Down
57 changes: 33 additions & 24 deletions ide/src/project/Project.ec
Expand Up @@ -742,7 +742,12 @@ char * GetConfigName(ProjectConfig config)
return config ? config.name : "Common";
}

public enum SingleFileCompileMode { normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject };
public enum SingleFileCompileMode
{
normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject;

property bool eC_ToolsDebug { get { return this == debugCompile || this == debugGenerateSymbols || this == debugPrecompile; } }
};

class Project : struct
{
Expand Down Expand Up @@ -1398,10 +1403,10 @@ private:
}
}

void ProcessPipeOutputRaw(DualPipe f)
bool ProcessPipeOutputRaw(DualPipe f)
{
char line[65536];
while(!f.Eof() && !ide.ShouldStopBuild())
while(!f.Eof() && !ide.projectView.stopBuild)
{
bool result = true;
double lastTime = GetTime();
Expand All @@ -1425,11 +1430,12 @@ private:
}
//if(!result) Sleep(1.0 / PEEK_RESOLUTION);
}
if(ide.ShouldStopBuild())
if(ide.projectView.stopBuild)
{
ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
f.Terminate();
}
return !ide.projectView.stopBuild;
}

bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, List<ProjectNode> onlyNodes,
Expand Down Expand Up @@ -1495,7 +1501,7 @@ private:
testLen = Max(testLen, windres.size);
testLen++;

while(!f.Eof() && !ide.ShouldStopBuild())
while(!f.Eof() && !ide.projectView.stopBuild)
{
bool result = true;
double lastTime = GetTime();
Expand Down Expand Up @@ -1848,7 +1854,7 @@ private:
}
//if(!result) Sleep(1.0 / PEEK_RESOLUTION);
}
if(ide.ShouldStopBuild())
if(ide.projectView.stopBuild)
{
ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
f.Terminate();
Expand Down Expand Up @@ -1893,7 +1899,7 @@ private:
delete strip;
delete ar;

return numErrors == 0;
return numErrors == 0 && !ide.projectView.stopBuild;
}

void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
Expand Down Expand Up @@ -1945,6 +1951,8 @@ private:
bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";

bool eC_Debug = mode.eC_ToolsDebug;
bool singleProjectOnlyNode = onlyNodes && onlyNodes.count == 1 && onlyNodes[0].type == project;
int numJobs = compiler.numJobs;
char command[MAX_F_STRING*4];
char * compilerName;
Expand Down Expand Up @@ -2002,7 +2010,7 @@ private:
ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
else
{
if(mode == cObject || mode == normal)
if(!eC_Debug)
node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, mode == cObject ? true : false);
node.GetTargets(config, namesInfo, objDirExp.dir, makeTargets);
}
Expand Down Expand Up @@ -2048,33 +2056,37 @@ private:
bitDepth ? " ARCH=" : "",
bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
/*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
compilerName, (mode == debugCompile || mode == debugGenerateSymbols || mode == debugPrecompile) ? "--always-make " : "", numJobs,
compiler.ccacheEnabled ? "CCACHE=y " : "",
compiler.distccEnabled ? "DISTCC=y " : "",
(String)makeTargets, topNode.path, (justPrint || (mode != normal && mode != cObject)) ? " -n" : "", makeFilePath);
compilerName, eC_Debug ? "--always-make " : "", numJobs,
(compiler.ccacheEnabled && !eC_Debug) ? "CCACHE=y " : "",
(compiler.distccEnabled && !eC_Debug) ? "DISTCC=y " : "",
(String)makeTargets, topNode.path, (justPrint || eC_Debug) ? " -n" : "", makeFilePath);
if(justPrint)
ide.outputView.buildBox.Logf("%s\n", command);

if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
{
bool found = false;
bool error = false;
if(mode != normal && mode != cObject)
if(eC_Debug)
{
char line[65536];
if(justPrint)
ide.outputView.buildBox.Logf($"\nMake outputs the following list of commands to choose from:\n");
while(!f.Eof())
{
bool result = true;
while(result)
{
if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
{
if(justPrint)
ide.outputView.buildBox.Logf("%s\n", line);
if(!error && !found && strstr(line, "echo ") == line)
{
strcpy(command, line+5);
error = true;
}
if(!error && !found && strstr(line, "ide ") == line)
if(!error && (singleProjectOnlyNode || !found) && strstr(line, "ide ") == line)
{
strcpy(command, line);
found = true;
Expand All @@ -2086,15 +2098,14 @@ private:
result = true;
}
else if(justPrint)
{
ProcessPipeOutputRaw(f);
result = true;
}
result = ProcessPipeOutputRaw(f);
else
result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNodes, compiler, config, bitDepth);
delete f;
if(error || (justPrint && found))
if(error)
ide.outputView.buildBox.Logf("%s\n", command);
else if(justPrint && found)
ide.outputView.buildBox.Logf($"\nThe following command was chosen to be executed:\n%s\n", command);
else if(found)
Execute(command);
}
Expand Down Expand Up @@ -2230,9 +2241,9 @@ private:
delete target;
}

void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
bool Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
{
Build(false, nodes, compiler, config, bitDepth, justPrint, mode);
return Build(false, nodes, compiler, config, bitDepth, justPrint, mode);
}
#endif

Expand Down Expand Up @@ -3032,9 +3043,7 @@ private:
f.Puts("objdir:\n");
f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
f.Puts("\t$(if $(ECERE_SDK_SRC),$(if $(wildcard $(call escspace,$(ECERE_SDK_SRC)/crossplatform.mk)),,@$(call echo,Ecere SDK Source Warning: The value of ECERE_SDK_SRC is pointing to an incorrect ($(ECERE_SDK_SRC)/crossplatform.mk) location.)),)\n");
f.Puts("\t$(if $(ECERE_SDK_SRC),,$(if $(ECP_DEBUG),@$(call echo,ECC Debug Warning: Please define ECERE_SDK_SRC before using ECP_DEBUG),))\n");
f.Puts("\t$(if $(ECERE_SDK_SRC),,$(if $(ECC_DEBUG),@$(call echo,ECC Debug Warning: Please define ECERE_SDK_SRC before using ECC_DEBUG),))\n");
f.Puts("\t$(if $(ECERE_SDK_SRC),,$(if $(ECS_DEBUG),@$(call echo,ECC Debug Warning: Please define ECERE_SDK_SRC before using ECS_DEBUG),))\n");
f.Puts("\t$(if $(ECERE_SDK_SRC),,$(if $(ECP_DEBUG)$(ECC_DEBUG)$(ECS_DEBUG),@$(call echo,ECC Debug Warning: Please define ECERE_SDK_SRC before using ECP_DEBUG, ECC_DEBUG or ECS_DEBUG),))\n");
//f.Puts("# PRE-BUILD COMMANDS\n");
if(options && options.prebuildCommands)
{
Expand Down
28 changes: 27 additions & 1 deletion ide/src/project/ProjectNode.ec
Expand Up @@ -2301,12 +2301,12 @@ private:

void GetTargets(ProjectConfig prjConfig, Map<String, NameCollisionInfo> namesInfo, char * objDir, DynamicString output)
{
char moduleName[MAX_FILENAME];
if(type == file)
{
bool headerAltFailed = false;
bool collision;
char extension[MAX_EXTENSION];
char moduleName[MAX_FILENAME];
NameCollisionInfo info;
Project prj = property::project;
Map<String, String> headerToSource { [ { "eh", "ec" }, { "h", "c" }, { "hh", "cc" }, { "hpp", "cpp" }, { "hxx", "cxx" } ] };
Expand Down Expand Up @@ -2359,6 +2359,32 @@ private:
output.concat("\"");
}
}
else if(type == project && ContainsFilesWithExtension("ec"))
{
Project prj = property::project;

strcpy(moduleName, prj.moduleName);
strcat(moduleName, ".main.ec");
output.concat(" \"");
output.concat(objDir);
output.concat("/");
output.concat(moduleName);
output.concat("\"");

ChangeExtension(moduleName, "c", moduleName);
output.concat(" \"");
output.concat(objDir);
output.concat("/");
output.concat(moduleName);
output.concat("\"");

ChangeExtension(moduleName, "o", moduleName);
output.concat(" \"");
output.concat(objDir);
output.concat("/");
output.concat(moduleName);
output.concat("\"");
}
else if(files)
{
for(child : files)
Expand Down
28 changes: 21 additions & 7 deletions ide/src/project/ProjectView.ec
Expand Up @@ -230,6 +230,8 @@ class ProjectView : Window
{
MenuDivider { pop };
MenuItem { pop, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = na;
MenuItem { pop, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = na;
MenuItem { pop, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = na;
}
MenuDivider { pop };
MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
Expand Down Expand Up @@ -796,7 +798,7 @@ class ProjectView : Window
if(config)
{
config.compilingModified = false;
if(!ide.ShouldStopBuild())
if(!stopBuild)
config.linkingModified = false;

config.symbolGenModified = false;
Expand Down Expand Up @@ -1112,11 +1114,9 @@ class ProjectView : Window

buildInProgress = compilingFile;
ide.AdjustBuildMenus();
project.Compile(nodes, compiler, config, bitDepth, justPrint, mode);
result = project.Compile(nodes, compiler, config, bitDepth, justPrint, mode);
buildInProgress = none;
ide.AdjustBuildMenus();

result = true;
}
delete compiler;
}
Expand Down Expand Up @@ -1394,7 +1394,11 @@ class ProjectView : Window
{
List<ProjectNode> nodes { };
nodes.Add(node);
Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
if(node.type == project)
ProjectBuild(selection, mods);
ide.Update(null);
if(!stopBuild)
Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
delete nodes;
}
return true;
Expand All @@ -1408,7 +1412,12 @@ class ProjectView : Window
{
List<ProjectNode> nodes { };
nodes.Add(node);
Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
if(node.type == project)
ProjectBuild(selection, mods);
else
Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
if(!stopBuild)
Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
delete nodes;
}
return true;
Expand All @@ -1422,7 +1431,12 @@ class ProjectView : Window
{
List<ProjectNode> nodes { };
nodes.Add(node);
Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
if(node.type == project)
ProjectBuild(selection, mods);
else
Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
if(!stopBuild)
Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
delete nodes;
}
return true;
Expand Down

0 comments on commit ad4918f

Please sign in to comment.