Skip to content

Commit

Permalink
ecp, ecc, ecs; just some debug code and re-ordering for easy ecp/ecc …
Browse files Browse the repository at this point in the history
…compare.
  • Loading branch information
redj committed Jun 12, 2013
1 parent 1430c5c commit 8c72bc7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 29 deletions.
21 changes: 16 additions & 5 deletions compiler/ecc/ecc.ec
Expand Up @@ -278,6 +278,17 @@ class CompilerApp : Application
argc++;
}*/

#ifdef _DEBUG
printf("\nArguments given:\n");
for(c=1; c<argc; c++)
printf(" %s", argv[c]);
printf("\n\n");
for(c=1; c<argc; c++)
PrintLn("Arg", c, ": ", argv[c]);
printf("\n");
//getch();
#endif

for(c = 1; c<argc; c++)
{
char * arg = argv[c];
Expand Down Expand Up @@ -432,11 +443,6 @@ class CompilerApp : Application
if(!valid)
{
printf($"Syntax:\n ecc [-t <target platform>] [-cpp <c preprocessor>] [-o <output>] [-symbols <outputdir>] [-I<includedir>]* [-isystem <sysincludedir>]* [-D<definition>]* -c <input>\n");
#ifdef _DEBUG
printf($"\nArguments given:");
for(c = 1; c<argc; c++)
printf(" %s", argv[c]);
#endif
}
else
{
Expand Down Expand Up @@ -484,6 +490,10 @@ class CompilerApp : Application

snprintf(command, sizeof(command), "%s%s -x c -E %s\"%s\"", cppCommand, cppOptions ? cppOptions : "", buildingBootStrap ? "" : "-include stdint.h -include sys/types.h ", GetSourceFile());
command[sizeof(command)-1] = 0;
#ifdef _DEBUG
PrintLn("ECC Executing:");
PrintLn(command);
#endif
if((cppOutput = DualPipeOpen({ output = true }, command)))
{
char impFile[MAX_LOCATION];
Expand Down Expand Up @@ -730,6 +740,7 @@ class CompilerApp : Application
OutputIntlStrings();

#if defined(_DEBUG) && defined(__WIN32__)
PrintLn("Done.");
if(exitCode || GetNumWarnings())
getch();
#endif
Expand Down
45 changes: 27 additions & 18 deletions compiler/ecp/ecp.ec
Expand Up @@ -1319,6 +1319,17 @@ class PrecompApp : Application
argc++;
}*/

#ifdef _DEBUG
printf("\nArguments given:\n");
for(c=1; c<argc; c++)
printf(" %s", argv[c]);
printf("\n\n");
for(c=1; c<argc; c++)
PrintLn("Arg", c, ": ", argv[c]);
printf("\n");
//getch();
#endif

for(c = 1; c<argc; c++)
{
char * arg = argv[c];
Expand Down Expand Up @@ -1426,7 +1437,7 @@ class PrecompApp : Application
{
if(c + 1 < argc)
{
SetDefaultNameSpace(argv[c+1]); //defaultNameSpace = argv[c+1];
SetDefaultNameSpace(argv[c+1]);
//defaultNameSpaceLen = strlen(argv[c+1]);
c++;
}
Expand Down Expand Up @@ -1455,31 +1466,25 @@ class PrecompApp : Application
SetOutputFile(defaultSymFile);
}
}

if(!valid)
{
printf($"Syntax:\n ecp [-t <target platform>] [-cpp <c preprocessor>] [-o <output>] [-symbols <outputdir>] [-I<includedir>]* [-isystem <sysincludedir>]* [-D<definition>]* -c <input>\n");
#ifdef _DEBUG
printf($"\nArguments given:");
for(c = 1; c<argc; c++)
printf(" %s", argv[c]);
#endif
}
else
{
DualPipe cppOutput;
// TODO: Improve this
char command[MAX_F_STRING*3];
DualPipe cppOutput;

SetGlobalData(&globalData);
SetExcludedSymbols(&_excludedSymbols);
SetGlobalContext(globalContext);
SetTopContext(globalContext);
SetCurrentContext(globalContext);
SetExcludedSymbols(&_excludedSymbols);
SetGlobalData(&globalData);
SetTopContext(globalContext);
SetDefines(&::defines);
SetImports(&imports);
SetPrecompDefines(&precompDefines);
SetInPreCompiler(true);
SetPrecompDefines(&precompDefines);
SetTargetPlatform(targetPlatform);
SetTargetBits(targetBits);
SetEchoOn(false);
Expand All @@ -1502,10 +1507,13 @@ class PrecompApp : Application
if(FileExists(outputFilePath))
DeleteFile(outputFilePath);
}

snprintf(command, sizeof(command), "%s%s -x c -E \"%s\"", cppCommand, cppOptions ? cppOptions : "", GetSourceFile());
command[sizeof(command)-1] = 0;

#ifdef _DEBUG
PrintLn("ECP Executing:");
PrintLn(command);
#endif
if((cppOutput = DualPipeOpen({ output = true }, command)))
{
int exitCode;
Expand Down Expand Up @@ -1539,7 +1547,7 @@ class PrecompApp : Application
SetYydebug(false);
delete fileInput;
SetFileInput(null);

ast = GetAST();
if(!exitCode)
{
Expand All @@ -1566,7 +1574,7 @@ class PrecompApp : Application
::defines.Free(FreeModuleDefine);
imports.Free(FreeModuleImport);

precompDefines.Free(FreeDefinition);
precompDefines.Free(FreeDefinition);

FreeTypeData(privateModule);
FreeIncludeFiles();
Expand All @@ -1585,8 +1593,9 @@ class PrecompApp : Application
*/
SetSymbolsDir(null); // Free symbols dir

#ifdef _DEBUG
#if defined(_DEBUG) && defined(__WIN32__)
// CheckMemory();
PrintLn("Done.");
getch();
#endif
}
Expand Down
16 changes: 11 additions & 5 deletions compiler/ecs/ecs.ec
Expand Up @@ -1633,6 +1633,17 @@ class SymbolgenApp : Application
}
*/

#ifdef _DEBUG
printf("\nArguments given:\n");
for(c=1; c<argc; c++)
printf(" %s", argv[c]);
printf("\n\n");
for(c=1; c<argc; c++)
PrintLn("Arg", c, ": ", argv[c]);
printf("\n");
//getch();
#endif

for(c = 1; c<argc; c++)
{
char * arg = argv[c];
Expand Down Expand Up @@ -1698,11 +1709,6 @@ class SymbolgenApp : Application
if(!valid)
{
printf($"Syntax:\n ecs [-t <target platform>] <input>[, <input>]* -o <output>\n");
#ifdef _DEBUG
printf($"\nArguments given:");
for(c = 1; c<argc; c++)
printf(" %s", argv[c]);
#endif
}
else
{
Expand Down
8 changes: 7 additions & 1 deletion ecere/src/sys/DualPipe.c
Expand Up @@ -343,7 +343,13 @@ _DualPipe * _DualPipeOpen(PipeOpenMode mode, char * commandLine, char * env, voi
close(hInput[PIPE_READ]);
}

numTokens = __ecereNameSpace__ecere__sys__Tokenize(commandLineCopy, sizeof(tokens) / sizeof(tokens[0]) - 1, tokens, false);
#if 0 //#ifdef _DEBUG
fprintf(stderr, "\n_DualPipeOpen (in child): %s\n\n", commandLineCopy);
#endif
numTokens = __ecereNameSpace__ecere__sys__Tokenize(commandLineCopy, sizeof(tokens) / sizeof(tokens[0]) - 1, tokens, forArgsPassing);
#if 0 //#ifdef _DEBUG
{ int c; for(c=0; c<numTokens; c++) fprintf(stderr, "argv[%d]: %s\n", c, tokens[c]); fprintf(stderr, "\n"); }
#endif
tokens[numTokens] = null;
if(env)
{
Expand Down

0 comments on commit 8c72bc7

Please sign in to comment.