From a376e6f86d0ce95fcf729e54514086cba1305a48 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 28 Apr 2007 05:40:22 +0000 Subject: [PATCH] make control of progdefs.h generation saner --- tools/qfcc/include/options.h | 1 + tools/qfcc/source/options.c | 30 ++++++++++++++++++++++-------- tools/qfcc/source/qfcc.c | 4 ++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tools/qfcc/include/options.h b/tools/qfcc/include/options.h index 068c16c02..f9fef1838 100644 --- a/tools/qfcc/include/options.h +++ b/tools/qfcc/include/options.h @@ -76,6 +76,7 @@ typedef struct { // that qboolean save_temps; // save temporary files qboolean files_dat; // generate files.dat + qboolean progdefs_h; // generate progdefs.h qboolean traditional; // behave more like qcc qboolean advanced; // behold the power of Ruamoko qboolean compile; // serparate compilation mode diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index 872e219c3..a537a0246 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -58,23 +58,34 @@ const char **source_files; static int num_files; static int files_size; +// keep me sane when adding long options :P +enum { + start_opts = 255, // not used, just for starting the enum. + OPT_ADVANCED, + OPT_CPP, + OPT_INCLUDE, + OPT_PROGDEFS, + OPT_TRADITIONAL, +}; + static struct option const long_options[] = { - {"advanced", no_argument, 0, 258}, + {"advanced", no_argument, 0, OPT_ADVANCED}, {"code", required_argument, 0, 'C'}, - {"cpp", required_argument, 0, 256}, + {"cpp", required_argument, 0, OPT_CPP}, {"define", required_argument, 0, 'D'}, {"files", no_argument, 0, 'F'}, {"help", no_argument, 0, 'h'}, - {"include", required_argument, 0, 259}, + {"include", required_argument, 0, OPT_INCLUDE}, {"notice", required_argument, 0, 'N'}, {"output-file", required_argument, 0, 'o'}, + {"progdefs", no_argument, 0, OPT_PROGDEFS}, {"progs-src", required_argument, 0, 'P'}, {"quiet", no_argument, 0, 'q'}, {"relocatable", no_argument, 0, 'r'}, {"save-temps", no_argument, 0, 'S'}, {"source", required_argument, 0, 's'}, {"strip-path", required_argument, 0, 'p'}, - {"traditional", no_argument, 0, 257}, + {"traditional", no_argument, 0, OPT_TRADITIONAL}, {"undefine", required_argument, 0, 'U'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, @@ -310,6 +321,9 @@ DecodeArgs (int argc, char **argv) case 'F': options.files_dat = true; break; + case OPT_PROGDEFS: + options.progdefs_h = true; + break; case 'q': // quiet options.verbosity -= 1; break; @@ -319,12 +333,12 @@ DecodeArgs (int argc, char **argv) case 'g': // debug options.code.debug = true; break; - case 257: // traditional + case OPT_TRADITIONAL: options.traditional = true; options.advanced = false; options.code.progsversion = PROG_ID_VERSION; break; - case 258: // advanced + case OPT_ADVANCED: options.traditional = false; options.advanced = true; options.code.progsversion = PROG_VERSION; @@ -468,7 +482,7 @@ DecodeArgs (int argc, char **argv) free (opts); } break; - case 256: // --cpp= + case OPT_CPP: // --cpp= cpp_name = save_string (optarg); break; case 'S': // save temps @@ -482,7 +496,7 @@ DecodeArgs (int argc, char **argv) options.preprocess_only = 1; add_cpp_def ("-E"); break; - case 259: // include-file + case OPT_INCLUDE: // include-file add_cpp_def (nva ("%s", "-include")); add_cpp_def (nva ("%s", optarg)); break; diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 58a0da778..0afb4be51 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -649,7 +649,7 @@ separate_compile (void) finish_compilation (); // write progdefs.h - if (options.code.progsversion == PROG_ID_VERSION) + if (options.progdefs_h) crc = WriteProgdefs ("progdefs.h"); WriteData (crc); @@ -866,7 +866,7 @@ progs_src_compile (void) } // write progdefs.h - if (options.code.progsversion == PROG_ID_VERSION) + if (options.progdefs_h) crc = WriteProgdefs ("progdefs.h"); // write data file