X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=main.c;h=bef80723632b9176167b9cf3d4ee939aecca124e;hp=195574ea1538c737b65aeb0f7bb4207a5d3066c8;hb=6759c3633b0d2d18f776d5798af889566d86f00e;hpb=f103544c95f7bda51446ab5f34d15a84fbf3d1bb diff --git a/main.c b/main.c index 195574e..bef8072 100644 --- a/main.c +++ b/main.c @@ -22,18 +22,368 @@ */ #include "gmqcc.h" +uint32_t opts_flags[1 + (COUNT_FLAGS / 32)]; +uint32_t opts_warn [1 + (COUNT_WARNINGS / 32)]; + +uint32_t opts_O = 1; +const char *opts_output = "progs.dat"; +int opts_standard = COMPILER_GMQCC; +bool opts_debug = false; +bool opts_memchk = false; + +typedef struct { char *filename; int type; } argitem; +VECTOR_MAKE(argitem, items); + +#define TYPE_QC 0 +#define TYPE_ASM 1 +#define TYPE_SRC 2 + +static const char *app_name; + +static int usage() { + printf("usage: %s [options] [files...]", app_name); + printf("options:\n" + " -h, --help show this help message\n" + " -debug turns on compiler debug messages\n" + " -memchk turns on compiler memory leak check\n"); + printf(" -o, --output=file output file, defaults to progs.dat\n" + " -a filename add an asm file to be assembled\n" + " -s filename add a progs.src file to be used\n"); + printf(" -f enable a flag\n" + " -fno- disable a flag\n" + " -std standard select one of the following standards\n" + " -std=qcc original QuakeC\n" + " -std=fteqcc fteqcc QuakeC\n" + " -std=gmqcc this compiler (default)\n"); + printf(" -W enable a warning\n" + " -Wno- disable a warning\n" + " -Wall enable all warnings\n"); + printf("\n"); + printf("flags:\n" + " -fdarkplaces-string-table-bug\n" + " patch the string table to work with some bugged darkplaces versions\n" + " -fomit-nullbytes\n" + " omits certain null-bytes for a smaller output - requires a patched engine\n" + ); + return -1; +} + +static bool options_setflag_all(const char *name, bool on, uint32_t *flags, const opts_flag_def *list, size_t listsize) { + size_t i; + + for (i = 0; i < listsize; ++i) { + if (!strcmp(name, list[i].name)) { + longbit lb = list[i].bit; +#if 0 + if (on) + flags[lb.idx] |= (1<<(lb.bit)); + else + flags[lb.idx] &= ~(1<<(lb.bit)); +#else + if (on) + flags[0] |= (1<