X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=main.c;h=6b751e3e03e7048788167dbd2bf4764c65e8505d;hp=b8117f042806bef33b12f0e8663dd12ca74ad4ae;hb=8dccf69060478c5665052dddaa6845d9e5d34f6c;hpb=477e80f1fb79c5d74a97ad5ed756f03cc21445f4 diff --git a/main.c b/main.c index b8117f0..6b751e3 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 + * Copyright (C) 2012 * Dale Weiler * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -21,17 +21,332 @@ * SOFTWARE. */ #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<