From 03bf08c0be1a47cfc0a64d3b7f9139a3a9244796 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 18 Jul 2010 10:01:57 +0000 Subject: [PATCH] Added -ffiletimes argument, which will cause fteqcc to ignore the compile if there were no changes. May be incompatible with some other features. git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3557 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc.h | 1 + engine/qclib/qcc_pr_comp.c | 1 + engine/qclib/qccmain.c | 43 ++++++++++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/engine/qclib/qcc.h b/engine/qclib/qcc.h index a7fb406ad..4aa5b986b 100644 --- a/engine/qclib/qcc.h +++ b/engine/qclib/qcc.h @@ -477,6 +477,7 @@ extern pbool flag_hashonly; extern pbool flag_fasttrackarrays; extern pbool flag_assume_integer; extern pbool flag_msvcstyle; +extern pbool flag_filetimes; extern pbool opt_overlaptemps; extern pbool opt_shortenifnots; diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 687bbb01c..d7efd25dd 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -76,6 +76,7 @@ pbool flag_hashonly; //Allows use of only #constant for precompiler constants, pbool flag_fasttrackarrays; //Faster arrays, dynamically detected, activated only in supporting engines. pbool flag_msvcstyle; //MSVC style warnings, so msvc's ide works properly pbool flag_assume_integer; //5 - is that an integer or a float? qcc says float. but we support int too, so maybe we want that instead? +pbool flag_filetimes; pbool opt_overlaptemps; //reduce numpr_globals by reuse of temps. When they are not needed they are freed for reuse. The way this is implemented is better than frikqcc's. (This is the single most important optimisation) pbool opt_assignments; //STORE_F isn't used if an operation wrote to a temp. diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index 123d7f79e..949c8dc10 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -2,6 +2,7 @@ #define PROGSUSED #include "qcc.h" +#include int mkdir(const char *path); char QCC_copyright[1024]; @@ -232,6 +233,7 @@ compiler_flag_t compiler_flag[] = { {&flag_hashonly, FLAG_MIDCOMPILE,"hashonly", "Hash-only constants", "Allows use of only #constant for precompiler constants, allows certain preqcc using mods to compile"}, {&opt_logicops, FLAG_MIDCOMPILE,"lo", "Logic ops", "This changes the behaviour of your code. It generates additional if operations to early-out in if statements. With this flag, the line if (0 && somefunction()) will never call the function. It can thus be considered an optimisation. However, due to the change of behaviour, it is not considered so by fteqcc. Note that due to inprecisions with floats, this flag can cause runaway loop errors within the player walk and run functions (without iffloat also enabled). This code is advised:\nplayer_stand1:\n if (self.velocity_x || self.velocity_y)\nplayer_run\n if (!(self.velocity_x || self.velocity_y))"}, {&flag_msvcstyle, FLAG_MIDCOMPILE,"msvcstyle", "MSVC-style errors", "Generates warning and error messages in a format that msvc understands, to facilitate ide integration."}, + {&flag_filetimes, 0, "filetimes", "Check Filetimes", "Recompiles the progs only if the file times are modified."}, {&flag_fasttrackarrays, FLAG_MIDCOMPILE|FLAG_ASDEFAULT,"fastarrays","fast arrays where possible", "Generates extra instructions inside array handling functions to detect engine and use extension opcodes only in supporting engines.\nAdds a global which is set by the engine if the engine supports the extra opcodes. Note that this applies to all arrays or none."}, {&flag_assume_integer, FLAG_MIDCOMPILE,"assumeint", "Assume Integers", "Numerical constants are assumed to be integers, instead of floats."}, {NULL} @@ -3108,6 +3110,36 @@ newstyle: } #endif + if (flag_filetimes) + { + struct stat s, os; + pbool modified = false; + + if (stat(destfile, &os) != -1) + { + while (pr_file_p=QCC_COM_Parse(pr_file_p)) + { + struct stat s; + if (stat(qcc_token, &s) == -1 || s.st_mtime > os.st_mtime) + { + printf("%s changed\n", qcc_token); + modified = true; + break; + } + } + if (!modified) + { + printf("No changes\n"); + qcc_compileactive = false; + return; + } + else + { + pr_file_p = qccmsrc; + } + } + } + printf ("outputfile: %s\n", destfile); pr_dumpasm = false; @@ -3156,7 +3188,7 @@ void QCC_ContinueCompile(void) strcpy (qccmfilename, qccmsourcedir); while(1) { - if (!strncmp(s, "..\\", 3)) + if (!strncmp(s, "..\\", 3) || !strncmp(s, "../", 3)) { s2 = qccmfilename + strlen(qccmfilename)-2; while (s2>=qccmfilename) @@ -3168,10 +3200,13 @@ void QCC_ContinueCompile(void) } s2--; } - s+=3; - continue; + if (s2>=qccmfilename) + { + s+=3; + continue; + } } - if (!strncmp(s, ".\\", 2)) + if (!strncmp(s, ".\\", 2) || !strncmp(s, "./", 2)) { s+=2; continue;