]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Language type selection at command line.
authorDale Weiler <killfieldengine@gmail.com>
Sun, 22 Apr 2012 02:55:30 +0000 (22:55 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Sun, 22 Apr 2012 02:55:30 +0000 (22:55 -0400)
gmqcc.h
main.c
util.c

diff --git a/gmqcc.h b/gmqcc.h
index ba53228215bff807ba03d690581f4a4abc17e858..e874ad454ac3f06e052e95b259cc40d0224af244 100644 (file)
--- 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 bc1a037d0e698b01c0fdf6e4c35a33b30abe8775..4828f26fd850bb91fcd4927d68a303ab60d099e1 100644 (file)
--- 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 b44d1c163eb33ba703129b27c3768e7dc242d854..136b12a6e92124ee107d1abd379a67f732efdbc3 100644 (file)
--- 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).