From: Dale Weiler Date: Sun, 22 Apr 2012 02:55:30 +0000 (-0400) Subject: Language type selection at command line. X-Git-Tag: 0.1-rc1~643 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=4d001da04e2531fb4eacb5d7f6868d33c58d6d05;p=xonotic%2Fgmqcc.git Language type selection at command line. --- diff --git a/gmqcc.h b/gmqcc.h index ba53228..e874ad4 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -476,6 +476,12 @@ void asm_parse(FILE *); //====================================================================== //============================= main.c ================================= //====================================================================== +enum { + COMPILER_QCC, /* circa QuakeC */ + COMPILER_FTEQCC, /* fteqcc QuakeC */ + COMPILER_QCCX, /* qccx QuakeC */ + COMPILER_GMQCC /* this QuakeC */ +}; extern int opts_debug; extern int opts_memchk; #endif diff --git a/main.c b/main.c index bc1a037..4828f26 100644 --- a/main.c +++ b/main.c @@ -26,8 +26,9 @@ typedef struct { char *name, type; } argitem; VECTOR_MAKE(argitem, items); /* global options */ -int opts_debug = 0; -int opts_memchk = 0; +int opts_debug = 0; +int opts_memchk = 0; +int opts_compiler = COMPILER_GMQCC; static const int usage(const char *const app) { printf("usage:\n"); @@ -40,7 +41,12 @@ static const int usage(const char *const app) { printf(" additional flags:\n"); printf(" -debug -- turns on compiler debug messages\n"); printf(" -memchk -- turns on compiler memory leak check\n"); - + printf(" -help -- prints this help/usage text\n"); + printf(" -std -- select the QuakeC compile type (types below):\n"); + printf(" -std=qcc -- original QuakeC\n"); + printf(" -std=ftqecc -- fteqcc QuakeC\n"); + printf(" -std=qccx -- qccx QuakeC\n"); + printf(" -std=gmqcc -- this compiler QuakeC (default selection)\n"); return -1; } @@ -64,6 +70,23 @@ int main(int argc, char **argv) { default: if (!strncmp(&argv[1][1], "debug" , 5)) { opts_debug = 1; break; } if (!strncmp(&argv[1][1], "memchk", 6)) { opts_memchk = 1; break; } + if (!strncmp(&argv[1][1], "help", 4)) { + return usage(app); + break; + } + /* compiler type selection */ + if (!strncmp(&argv[1][1], "std=qcc" , 7 )) { opts_compiler = COMPILER_QCC; break; } + if (!strncmp(&argv[1][1], "std=fteqcc", 10)) { opts_compiler = COMPILER_FTEQCC; break; } + if (!strncmp(&argv[1][1], "std=qccx", 8 )) { opts_compiler = COMPILER_QCCX; break; } + if (!strncmp(&argv[1][1], "std=gmqcc", 9 )) { opts_compiler = COMPILER_GMQCC; break; } + if (!strncmp(&argv[1][1], "std=", 4 )) { + printf("invalid std selection, supported types:\n"); + printf(" -std=qcc -- original QuakeC\n"); + printf(" -std=ftqecc -- fteqcc QuakeC\n"); + printf(" -std=qccx -- qccx QuakeC\n"); + printf(" -std=gmqcc -- this compiler QuakeC (default selection)\n"); + return 0; + } return usage(app); } @@ -78,6 +101,7 @@ int main(int argc, char **argv) { if (opts_memchk && !opts_debug) printf("Warning: cannot enable -memchk, without -debug.\n"); + util_debug("COM", "starting ...\n"); /* multi file multi path compilation system */ for (; itr < items_elements; itr++) { switch (items_data[itr].type) { @@ -94,7 +118,8 @@ int main(int argc, char **argv) { break; } } - + + util_debug("COM", "cleaning ...\n"); /* clean list */ for (itr = 0; itr < items_elements; itr++) mem_d(items_data[itr].name); diff --git a/util.c b/util.c index b44d1c1..136b12a 100644 --- a/util.c +++ b/util.c @@ -68,19 +68,15 @@ void util_meminfo() { Total allocations: %llu\n\ Total deallocations: %llu\n\ Total allocated: %llu (bytes)\n\ - Total deallocated: %llu (bytes)\n", + Total deallocated: %llu (bytes)\n\ + Leaks found: lost %llu (bytes) in %d allocations\n", mem_at, mem_dt, - mem_ab, mem_db + mem_ab, mem_db, + (mem_ab - mem_db), + (mem_at - mem_dt) ); } -//#ifndef mem_d -//#define mem_d(x) util_memory_d((x), __LINE__, __FILE__) -//#endif -//#ifndef mem_a -//#define mem_a(x) util_memory_a((x), __LINE__, __FILE__) -//#endif - /* * Some string utility functions, because strdup uses malloc, and we want * to track all memory (without replacing malloc).