/* * Copyright (C) 2012 * Dale Weiler * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * 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; bool opts_dump = false; static bool opts_output_wasset = 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<