2001-02-24 06:58:54 +00:00
|
|
|
/*
|
|
|
|
qfcc.c
|
|
|
|
|
|
|
|
QuakeForge Code Compiler (main program)
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 id Software, Inc.
|
2001-10-26 06:43:56 +00:00
|
|
|
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
License along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
2001-12-08 20:40:50 +00:00
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2001-07-17 05:02:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
2002-01-05 19:13:20 +00:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
# include <fcntl.h>
|
|
|
|
#endif
|
2001-07-17 05:02:34 +00:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-11-15 03:54:35 +00:00
|
|
|
#ifdef HAVE_PROCESS_H
|
|
|
|
# include <process.h>
|
|
|
|
#endif
|
2001-07-17 05:02:34 +00:00
|
|
|
|
2001-10-26 22:07:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2001-10-26 08:14:05 +00:00
|
|
|
#include <getopt.h>
|
|
|
|
|
2001-04-01 02:12:57 +00:00
|
|
|
#include <QF/crc.h>
|
2001-04-01 06:40:51 +00:00
|
|
|
#include <QF/hash.h>
|
2001-04-01 02:12:57 +00:00
|
|
|
#include <QF/qendian.h>
|
2001-04-01 03:33:11 +00:00
|
|
|
#include <QF/sys.h>
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
#include "qfcc.h"
|
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
options_t options;
|
2001-10-26 08:14:05 +00:00
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
char *sourcedir;
|
2002-01-17 08:19:53 +00:00
|
|
|
char *progs_src;
|
2001-12-06 19:49:40 +00:00
|
|
|
const char *this_program;
|
2001-10-26 22:07:35 +00:00
|
|
|
|
|
|
|
static struct option const long_options[] = {
|
2001-12-06 19:49:40 +00:00
|
|
|
{"source", required_argument, 0, 's'},
|
2002-01-17 08:19:53 +00:00
|
|
|
{"progs-src", required_argument, 0, 'P'},
|
2002-01-05 19:13:20 +00:00
|
|
|
{"save-temps", no_argument, 0, 'S'},
|
2001-12-06 19:49:40 +00:00
|
|
|
{"quiet", no_argument, 0, 'q'},
|
|
|
|
{"verbose", no_argument, 0, 'v'},
|
|
|
|
{"code", required_argument, 0, 'C'},
|
|
|
|
{"warn", required_argument, 0, 'W'},
|
|
|
|
{"help", no_argument, 0, 'h'},
|
|
|
|
{"version", no_argument, 0, 'V'},
|
2002-01-21 23:30:54 +00:00
|
|
|
{"files", no_argument, 0, 'F'},
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2001-12-06 19:49:40 +00:00
|
|
|
{"define", required_argument, 0, 'D'},
|
|
|
|
{"include", required_argument, 0, 'I'},
|
|
|
|
{"undefine", required_argument, 0, 'U'},
|
2002-02-05 19:35:45 +00:00
|
|
|
{"cpp", required_argument, 0, 256},
|
2001-10-26 22:07:35 +00:00
|
|
|
#endif
|
|
|
|
{NULL, 0, NULL, 0}
|
2001-10-26 08:14:05 +00:00
|
|
|
};
|
2001-03-28 17:17:56 +00:00
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
char destfile[1024];
|
2001-07-14 01:15:40 +00:00
|
|
|
char debugfile[1024];
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2002-02-05 18:40:47 +00:00
|
|
|
typedef struct cpp_arg_s {
|
|
|
|
struct cpp_arg_s *next;
|
|
|
|
const char *arg;
|
|
|
|
} cpp_arg_t;
|
|
|
|
|
|
|
|
cpp_arg_t *cpp_arg_list;
|
|
|
|
cpp_arg_t **cpp_arg_tail = &cpp_arg_list;
|
|
|
|
cpp_arg_t *cpp_def_list;
|
|
|
|
cpp_arg_t **cpp_def_tail = &cpp_def_list;
|
|
|
|
const char **cpp_argv;
|
|
|
|
char *cpp_name = CPP_NAME;
|
2001-12-06 19:49:40 +00:00
|
|
|
static int cpp_argc = 0;
|
2001-10-26 22:07:35 +00:00
|
|
|
#endif
|
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
pr_info_t pr;
|
2001-10-26 17:49:23 +00:00
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
float pr_globals[MAX_REGS];
|
|
|
|
int numpr_globals;
|
|
|
|
|
|
|
|
char strings[MAX_STRINGS];
|
|
|
|
int strofs;
|
|
|
|
|
|
|
|
dstatement_t statements[MAX_STATEMENTS];
|
|
|
|
int numstatements;
|
|
|
|
int statement_linenums[MAX_STATEMENTS];
|
|
|
|
|
2001-10-26 17:49:23 +00:00
|
|
|
function_t *pr_functions;
|
2001-02-24 06:58:54 +00:00
|
|
|
dfunction_t functions[MAX_FUNCTIONS];
|
|
|
|
int numfunctions;
|
|
|
|
|
|
|
|
ddef_t globals[MAX_GLOBALS];
|
|
|
|
int numglobaldefs;
|
2001-12-06 19:49:40 +00:00
|
|
|
int num_localdefs;
|
2001-08-21 18:23:21 +00:00
|
|
|
const char *big_function = 0;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
ddef_t fields[MAX_FIELDS];
|
|
|
|
int numfielddefs;
|
|
|
|
|
|
|
|
char precache_sounds[MAX_SOUNDS][MAX_DATA_PATH];
|
|
|
|
int precache_sounds_block[MAX_SOUNDS];
|
|
|
|
int numsounds;
|
|
|
|
|
|
|
|
char precache_models[MAX_MODELS][MAX_DATA_PATH];
|
|
|
|
int precache_models_block[MAX_SOUNDS];
|
|
|
|
int nummodels;
|
|
|
|
|
|
|
|
char precache_files[MAX_FILES][MAX_DATA_PATH];
|
|
|
|
int precache_files_block[MAX_SOUNDS];
|
|
|
|
int numfiles;
|
|
|
|
|
|
|
|
/*
|
|
|
|
WriteFiles
|
|
|
|
|
|
|
|
Generates files.dat, which contains all of the data files actually used by
|
|
|
|
the game, to be processed by qfiles
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
WriteFiles (void)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
FILE *f;
|
|
|
|
int i;
|
|
|
|
char filename[1024];
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
snprintf (filename, sizeof (filename), "%s%cfiles.dat", sourcedir,
|
|
|
|
PATH_SEPARATOR);
|
2001-02-24 06:58:54 +00:00
|
|
|
f = fopen (filename, "w");
|
|
|
|
if (!f)
|
|
|
|
Error ("Couldn't open %s", filename);
|
|
|
|
|
|
|
|
fprintf (f, "%i\n", numsounds);
|
|
|
|
for (i = 0; i < numsounds; i++)
|
|
|
|
fprintf (f, "%i %s\n", precache_sounds_block[i], precache_sounds[i]);
|
|
|
|
|
|
|
|
fprintf (f, "%i\n", nummodels);
|
|
|
|
for (i = 0; i < nummodels; i++)
|
|
|
|
fprintf (f, "%i %s\n", precache_models_block[i], precache_models[i]);
|
|
|
|
|
|
|
|
fprintf (f, "%i\n", numfiles);
|
|
|
|
for (i = 0; i < numfiles; i++)
|
|
|
|
fprintf (f, "%i %s\n", precache_files_block[i], precache_files[i]);
|
|
|
|
|
|
|
|
fclose (f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CopyString
|
|
|
|
|
|
|
|
Return an offset from the string heap
|
|
|
|
*/
|
2001-04-01 06:40:51 +00:00
|
|
|
static hashtab_t *strings_tab;
|
|
|
|
|
2001-06-04 04:52:14 +00:00
|
|
|
static const char *
|
2001-04-01 06:40:51 +00:00
|
|
|
stings_get_key (void *_str, void *unsued)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
return (char *) _str;
|
2001-04-01 06:40:51 +00:00
|
|
|
}
|
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
int
|
2001-06-04 04:52:14 +00:00
|
|
|
CopyString (const char *str)
|
2001-02-24 06:58:54 +00:00
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
int old;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-04-01 06:40:51 +00:00
|
|
|
if (!strings_tab) {
|
|
|
|
strings_tab = Hash_NewTable (16381, stings_get_key, 0, 0);
|
|
|
|
}
|
2001-02-24 06:58:54 +00:00
|
|
|
old = strofs;
|
|
|
|
strcpy (strings + strofs, str);
|
|
|
|
strofs += strlen (str) + 1;
|
2001-04-01 06:40:51 +00:00
|
|
|
Hash_Add (strings_tab, strings + old);
|
2001-02-24 06:58:54 +00:00
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2001-04-01 06:40:51 +00:00
|
|
|
int
|
2001-06-04 04:52:14 +00:00
|
|
|
ReuseString (const char *str)
|
2001-04-01 06:40:51 +00:00
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
char *s;
|
2001-04-01 06:40:51 +00:00
|
|
|
|
|
|
|
if (!strings_tab)
|
|
|
|
return CopyString (str);
|
|
|
|
s = Hash_Find (strings_tab, str);
|
|
|
|
if (s)
|
|
|
|
return s - strings;
|
|
|
|
return CopyString (str);
|
|
|
|
}
|
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
void
|
|
|
|
InitData (void)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
int i;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
numstatements = 1;
|
|
|
|
strofs = 1;
|
|
|
|
numfunctions = 1;
|
|
|
|
numglobaldefs = 1;
|
|
|
|
numfielddefs = 1;
|
|
|
|
|
|
|
|
def_ret.ofs = OFS_RETURN;
|
|
|
|
for (i = 0; i < MAX_PARMS; i++)
|
|
|
|
def_parms[i].ofs = OFS_PARM0 + 3 * i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WriteData (int crc)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
def_t *def;
|
|
|
|
ddef_t *dd;
|
2001-02-24 06:58:54 +00:00
|
|
|
dprograms_t progs;
|
2001-07-14 01:15:40 +00:00
|
|
|
pr_debug_header_t debug;
|
2001-12-06 19:49:40 +00:00
|
|
|
FILE *h;
|
|
|
|
int i;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-06-20 03:05:50 +00:00
|
|
|
for (def = pr.def_head.def_next; def; def = def->def_next) {
|
2001-06-06 00:12:10 +00:00
|
|
|
if (def->scope)
|
|
|
|
continue;
|
2001-03-28 17:17:56 +00:00
|
|
|
if (def->type->type == ev_func) {
|
2001-12-06 19:49:40 +00:00
|
|
|
// df = &functions[numfunctions];
|
|
|
|
// numfunctions++;
|
2001-02-24 06:58:54 +00:00
|
|
|
} else if (def->type->type == ev_field) {
|
|
|
|
dd = &fields[numfielddefs];
|
|
|
|
numfielddefs++;
|
|
|
|
dd->type = def->type->aux_type->type;
|
2001-04-01 06:40:51 +00:00
|
|
|
dd->s_name = ReuseString (def->name);
|
2001-02-24 06:58:54 +00:00
|
|
|
dd->ofs = G_INT (def->ofs);
|
|
|
|
}
|
|
|
|
|
|
|
|
dd = &globals[numglobaldefs];
|
|
|
|
numglobaldefs++;
|
|
|
|
dd->type = def->type->type;
|
|
|
|
|
2001-10-18 17:15:05 +00:00
|
|
|
if (!def->constant
|
2001-03-28 17:17:56 +00:00
|
|
|
&& def->type->type != ev_func
|
2001-02-24 06:58:54 +00:00
|
|
|
&& def->type->type != ev_field && def->scope == NULL)
|
2001-03-28 17:17:56 +00:00
|
|
|
dd->type |= DEF_SAVEGLOBAL;
|
2001-04-01 06:40:51 +00:00
|
|
|
dd->s_name = ReuseString (def->name);
|
2001-02-24 06:58:54 +00:00
|
|
|
dd->ofs = def->ofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
strofs = (strofs + 3) & ~3;
|
|
|
|
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= 0) {
|
2001-07-03 21:17:02 +00:00
|
|
|
printf ("%6i strofs\n", strofs);
|
|
|
|
printf ("%6i statements\n", numstatements);
|
|
|
|
printf ("%6i functions\n", numfunctions);
|
|
|
|
printf ("%6i globaldefs\n", numglobaldefs);
|
2001-08-21 18:23:21 +00:00
|
|
|
printf ("%6i locals size (%s)\n", num_localdefs, big_function);
|
2001-07-03 21:17:02 +00:00
|
|
|
printf ("%6i fielddefs\n", numfielddefs);
|
|
|
|
printf ("%6i pr_globals\n", numpr_globals);
|
2001-11-15 05:31:15 +00:00
|
|
|
printf ("%6i entityfields\n", pr.size_fields);
|
2001-07-03 21:17:02 +00:00
|
|
|
}
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
h = SafeOpenWrite (destfile);
|
|
|
|
SafeWrite (h, &progs, sizeof (progs));
|
|
|
|
|
2001-10-31 17:55:35 +00:00
|
|
|
progs.ofs_strings = ftell (h);
|
|
|
|
progs.numstrings = strofs;
|
|
|
|
SafeWrite (h, strings, strofs);
|
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
progs.ofs_statements = ftell (h);
|
|
|
|
progs.numstatements = numstatements;
|
|
|
|
for (i = 0; i < numstatements; i++) {
|
|
|
|
statements[i].op = LittleShort (statements[i].op);
|
|
|
|
statements[i].a = LittleShort (statements[i].a);
|
|
|
|
statements[i].b = LittleShort (statements[i].b);
|
|
|
|
statements[i].c = LittleShort (statements[i].c);
|
|
|
|
}
|
|
|
|
SafeWrite (h, statements, numstatements * sizeof (dstatement_t));
|
|
|
|
|
2001-10-31 17:55:35 +00:00
|
|
|
progs.ofs_functions = ftell (h);
|
|
|
|
progs.numfunctions = numfunctions;
|
|
|
|
for (i = 0; i < numfunctions; i++) {
|
2001-12-06 19:49:40 +00:00
|
|
|
functions[i].first_statement =
|
|
|
|
LittleLong (functions[i].first_statement);
|
2001-10-31 17:55:35 +00:00
|
|
|
functions[i].parm_start = LittleLong (functions[i].parm_start);
|
|
|
|
functions[i].s_name = LittleLong (functions[i].s_name);
|
|
|
|
functions[i].s_file = LittleLong (functions[i].s_file);
|
|
|
|
functions[i].numparms = LittleLong (functions[i].numparms);
|
|
|
|
functions[i].locals = LittleLong (functions[i].locals);
|
|
|
|
}
|
|
|
|
SafeWrite (h, functions, numfunctions * sizeof (dfunction_t));
|
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
progs.ofs_globaldefs = ftell (h);
|
|
|
|
progs.numglobaldefs = numglobaldefs;
|
|
|
|
for (i = 0; i < numglobaldefs; i++) {
|
|
|
|
globals[i].type = LittleShort (globals[i].type);
|
|
|
|
globals[i].ofs = LittleShort (globals[i].ofs);
|
|
|
|
globals[i].s_name = LittleLong (globals[i].s_name);
|
|
|
|
}
|
|
|
|
SafeWrite (h, globals, numglobaldefs * sizeof (ddef_t));
|
|
|
|
|
|
|
|
progs.ofs_fielddefs = ftell (h);
|
|
|
|
progs.numfielddefs = numfielddefs;
|
|
|
|
for (i = 0; i < numfielddefs; i++) {
|
|
|
|
fields[i].type = LittleShort (fields[i].type);
|
|
|
|
fields[i].ofs = LittleShort (fields[i].ofs);
|
|
|
|
fields[i].s_name = LittleLong (fields[i].s_name);
|
|
|
|
}
|
|
|
|
SafeWrite (h, fields, numfielddefs * sizeof (ddef_t));
|
|
|
|
|
|
|
|
progs.ofs_globals = ftell (h);
|
|
|
|
progs.numglobals = numpr_globals;
|
|
|
|
for (i = 0; i < numpr_globals; i++)
|
|
|
|
((int *) pr_globals)[i] = LittleLong (((int *) pr_globals)[i]);
|
|
|
|
SafeWrite (h, pr_globals, numpr_globals * 4);
|
|
|
|
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= -1)
|
2001-07-03 21:17:02 +00:00
|
|
|
printf ("%6i TOTAL SIZE\n", (int) ftell (h));
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
progs.entityfields = pr.size_fields;
|
|
|
|
|
2001-10-26 06:43:56 +00:00
|
|
|
progs.version = options.code.progsversion;
|
2001-02-24 06:58:54 +00:00
|
|
|
progs.crc = crc;
|
|
|
|
|
|
|
|
// byte swap the header and write it out
|
|
|
|
for (i = 0; i < sizeof (progs) / 4; i++)
|
|
|
|
((int *) &progs)[i] = LittleLong (((int *) &progs)[i]);
|
|
|
|
|
|
|
|
fseek (h, 0, SEEK_SET);
|
|
|
|
SafeWrite (h, &progs, sizeof (progs));
|
2001-07-18 20:31:55 +00:00
|
|
|
fclose (h);
|
2001-07-14 01:15:40 +00:00
|
|
|
|
2001-10-26 06:43:56 +00:00
|
|
|
if (!options.code.debug) {
|
2001-07-14 01:15:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-18 20:31:55 +00:00
|
|
|
h = SafeOpenRead (destfile);
|
|
|
|
|
2001-07-14 01:15:40 +00:00
|
|
|
debug.version = LittleLong (PROG_DEBUG_VERSION);
|
|
|
|
CRC_Init (&debug.crc);
|
|
|
|
while ((i = fgetc (h)) != EOF)
|
|
|
|
CRC_ProcessByte (&debug.crc, i);
|
2001-02-24 06:58:54 +00:00
|
|
|
fclose (h);
|
2001-07-14 01:15:40 +00:00
|
|
|
debug.crc = LittleShort (debug.crc);
|
|
|
|
debug.you_tell_me_and_we_will_both_know = 0;
|
2001-12-06 19:49:40 +00:00
|
|
|
|
2001-07-14 01:15:40 +00:00
|
|
|
h = SafeOpenWrite (debugfile);
|
|
|
|
SafeWrite (h, &debug, sizeof (debug));
|
|
|
|
|
|
|
|
debug.auxfunctions = LittleLong (ftell (h));
|
|
|
|
debug.num_auxfunctions = LittleLong (num_auxfunctions);
|
|
|
|
for (i = 0; i < num_auxfunctions; i++) {
|
|
|
|
auxfunctions[i].function = LittleLong (auxfunctions[i].function);
|
|
|
|
auxfunctions[i].source_line = LittleLong (auxfunctions[i].source_line);
|
|
|
|
auxfunctions[i].line_info = LittleLong (auxfunctions[i].line_info);
|
|
|
|
auxfunctions[i].local_defs = LittleLong (auxfunctions[i].local_defs);
|
|
|
|
auxfunctions[i].num_locals = LittleLong (auxfunctions[i].num_locals);
|
|
|
|
}
|
|
|
|
SafeWrite (h, auxfunctions, num_auxfunctions * sizeof (auxfunctions[0]));
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-07-14 01:15:40 +00:00
|
|
|
debug.linenos = LittleLong (ftell (h));
|
|
|
|
debug.num_linenos = LittleLong (num_linenos);
|
|
|
|
for (i = 0; i < num_linenos; i++) {
|
|
|
|
linenos[i].fa.addr = LittleLong (linenos[i].fa.addr);
|
|
|
|
linenos[i].line = LittleLong (linenos[i].line);
|
|
|
|
}
|
|
|
|
SafeWrite (h, linenos, num_linenos * sizeof (linenos[0]));
|
|
|
|
|
|
|
|
debug.locals = LittleLong (ftell (h));
|
|
|
|
debug.num_locals = LittleLong (num_locals);
|
|
|
|
for (i = 0; i < num_locals; i++) {
|
|
|
|
locals[i].type = LittleShort (locals[i].type);
|
|
|
|
locals[i].ofs = LittleShort (locals[i].ofs);
|
|
|
|
locals[i].s_name = LittleLong (locals[i].s_name);
|
|
|
|
}
|
|
|
|
SafeWrite (h, locals, num_locals * sizeof (locals[0]));
|
|
|
|
|
|
|
|
fseek (h, 0, SEEK_SET);
|
|
|
|
SafeWrite (h, &debug, sizeof (debug));
|
|
|
|
fclose (h);
|
2001-02-24 06:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
PR_String
|
|
|
|
|
|
|
|
Returns a string suitable for printing (no newlines, max 60 chars length)
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
PR_String (char *string)
|
|
|
|
{
|
|
|
|
static char buf[80];
|
2001-12-06 19:49:40 +00:00
|
|
|
char *s;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
s = buf;
|
|
|
|
*s++ = '"';
|
|
|
|
while (string && *string) {
|
|
|
|
|
|
|
|
if (s == buf + sizeof (buf) - 2)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (*string == '\n') {
|
|
|
|
*s++ = '\\';
|
|
|
|
*s++ = 'n';
|
|
|
|
} else if (*string == '"') {
|
|
|
|
*s++ = '\\';
|
|
|
|
*s++ = '"';
|
|
|
|
} else {
|
|
|
|
*s++ = *string;
|
|
|
|
}
|
|
|
|
string++;
|
|
|
|
|
|
|
|
if (s - buf > 60) {
|
|
|
|
*s++ = '.';
|
|
|
|
*s++ = '.';
|
|
|
|
*s++ = '.';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*s++ = '"';
|
|
|
|
*s++ = 0;
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def_t *
|
|
|
|
PR_DefForFieldOfs (gofs_t ofs)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
def_t *d;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-06-20 03:05:50 +00:00
|
|
|
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
2001-02-24 06:58:54 +00:00
|
|
|
if (d->type->type != ev_field)
|
|
|
|
continue;
|
|
|
|
if (*((int *) &pr_globals[d->ofs]) == ofs)
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Error ("PR_DefForFieldOfs: couldn't find %i", ofs);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
PR_BeginCompilation
|
|
|
|
|
|
|
|
called before compiling a batch of files, clears the pr struct
|
|
|
|
*/
|
|
|
|
void
|
2001-10-24 22:53:27 +00:00
|
|
|
PR_BeginCompilation (void)
|
2001-02-24 06:58:54 +00:00
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
int i;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
numpr_globals = RESERVED_OFS;
|
|
|
|
pr.def_tail = &pr.def_head;
|
|
|
|
|
|
|
|
for (i = 0; i < RESERVED_OFS; i++)
|
|
|
|
pr_global_defs[i] = &def_void;
|
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
// link the function type in so state forward declarations match proper
|
|
|
|
// type
|
2001-02-24 06:58:54 +00:00
|
|
|
pr.types = &type_function;
|
|
|
|
type_function.next = NULL;
|
|
|
|
pr_error_count = 0;
|
|
|
|
}
|
|
|
|
|
2001-06-08 06:32:15 +00:00
|
|
|
void
|
|
|
|
PR_RelocateRefs (def_t *def)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
statref_t *ref;
|
2002-01-18 08:26:37 +00:00
|
|
|
int *d;
|
2001-12-06 19:49:40 +00:00
|
|
|
|
2001-06-08 06:32:15 +00:00
|
|
|
for (ref = def->refs; ref; ref = ref->next) {
|
|
|
|
switch (ref->field) {
|
|
|
|
case 0:
|
|
|
|
ref->statement->a = def->ofs;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ref->statement->b = def->ofs;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ref->statement->c = def->ofs;
|
|
|
|
break;
|
2002-01-18 08:26:37 +00:00
|
|
|
case 4:
|
|
|
|
d = (int*)ref->statement;
|
|
|
|
*d += def->ofs;
|
|
|
|
break;
|
2001-06-08 06:32:15 +00:00
|
|
|
default:
|
2001-12-06 19:49:40 +00:00
|
|
|
abort ();
|
2001-06-08 06:32:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
/*
|
|
|
|
PR_FinishCompilation
|
|
|
|
|
|
|
|
called after all files are compiled to check for errors.
|
|
|
|
Returns false if errors were detected.
|
|
|
|
*/
|
2001-12-06 19:49:40 +00:00
|
|
|
qboolean PR_FinishCompilation (void)
|
2001-02-24 06:58:54 +00:00
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
def_t *d;
|
|
|
|
qboolean errors = false;
|
|
|
|
function_t *f;
|
|
|
|
def_t *def;
|
|
|
|
expr_t e;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
// check to make sure all functions prototyped have code
|
2001-10-26 06:43:56 +00:00
|
|
|
if (options.warnings.undefined_function)
|
2001-08-04 09:11:50 +00:00
|
|
|
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
|
|
|
if (d->type->type == ev_func && !d->scope) { // function args ok
|
2001-10-18 17:41:22 +00:00
|
|
|
if (d->used) {
|
|
|
|
if (!d->initialized) {
|
|
|
|
warning (0, "function %s was called but not defined\n",
|
|
|
|
d->name);
|
|
|
|
}
|
2001-08-04 09:11:50 +00:00
|
|
|
}
|
2001-02-24 06:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-05 08:09:12 +00:00
|
|
|
if (errors)
|
|
|
|
return !errors;
|
|
|
|
|
2001-10-26 06:43:56 +00:00
|
|
|
if (options.code.debug) {
|
2001-07-14 01:15:40 +00:00
|
|
|
e.type = ex_string;
|
|
|
|
e.e.string_val = debugfile;
|
|
|
|
PR_ReuseConstant (&e, PR_GetDef (&type_string, ".debug_file", 0,
|
|
|
|
&numpr_globals));
|
|
|
|
}
|
|
|
|
|
2001-06-20 03:05:50 +00:00
|
|
|
for (def = pr.def_head.def_next; def; def = def->def_next) {
|
2001-12-07 20:10:30 +00:00
|
|
|
if (def->scope || def->absolute)
|
2001-06-08 06:32:15 +00:00
|
|
|
continue;
|
|
|
|
PR_RelocateRefs (def);
|
|
|
|
}
|
|
|
|
|
2001-06-05 08:09:12 +00:00
|
|
|
for (f = pr_functions; f; f = f->next) {
|
|
|
|
if (f->builtin)
|
|
|
|
continue;
|
2001-10-24 06:39:49 +00:00
|
|
|
if (f->def->locals > num_localdefs) {
|
|
|
|
num_localdefs = f->def->locals;
|
2001-08-21 18:23:21 +00:00
|
|
|
big_function = f->def->name;
|
|
|
|
}
|
2001-06-05 08:09:12 +00:00
|
|
|
f->dfunc->parm_start = numpr_globals;
|
|
|
|
for (def = f->def->scope_next; def; def = def->scope_next) {
|
2001-12-07 20:10:30 +00:00
|
|
|
if (def->absolute)
|
|
|
|
continue;
|
2001-06-05 23:52:34 +00:00
|
|
|
def->ofs += numpr_globals;
|
2001-06-08 06:32:15 +00:00
|
|
|
PR_RelocateRefs (def);
|
2001-06-05 08:09:12 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-14 01:15:40 +00:00
|
|
|
numpr_globals += num_localdefs;
|
2001-06-05 08:09:12 +00:00
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
return !errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
PR_WriteProgdefs
|
|
|
|
|
|
|
|
Writes the global and entity structures out.
|
|
|
|
Returns a crc of the header, to be stored in the progs file for comparison
|
|
|
|
at load time.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
PR_WriteProgdefs (char *filename)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
def_t *d;
|
|
|
|
FILE *f;
|
|
|
|
unsigned short crc;
|
|
|
|
int c;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= 1)
|
2001-07-03 21:17:02 +00:00
|
|
|
printf ("writing %s\n", filename);
|
2001-02-24 06:58:54 +00:00
|
|
|
f = fopen (filename, "w");
|
|
|
|
|
|
|
|
// print global vars until the first field is defined
|
2001-12-06 19:49:40 +00:00
|
|
|
fprintf (f,
|
|
|
|
"\n/* file generated by qcc, do not modify */\n\ntypedef struct\n{\tint\tpad[%i];\n",
|
|
|
|
RESERVED_OFS);
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-06-20 03:05:50 +00:00
|
|
|
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
2001-02-24 06:58:54 +00:00
|
|
|
if (!strcmp (d->name, "end_sys_globals"))
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (d->type->type) {
|
|
|
|
case ev_float:
|
|
|
|
fprintf (f, "\tfloat\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
case ev_vector:
|
|
|
|
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
2001-06-20 03:05:50 +00:00
|
|
|
d = d->def_next->def_next->def_next; // skip the elements
|
2001-02-24 06:58:54 +00:00
|
|
|
break;
|
|
|
|
case ev_string:
|
|
|
|
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
|
|
|
break;
|
2001-03-28 17:17:56 +00:00
|
|
|
case ev_func:
|
2001-02-24 06:58:54 +00:00
|
|
|
fprintf (f, "\tfunc_t\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
case ev_entity:
|
|
|
|
fprintf (f, "\tint\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf (f, "\tint\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (f, "} globalvars_t;\n\n");
|
|
|
|
|
|
|
|
// print all fields
|
|
|
|
fprintf (f, "typedef struct\n{\n");
|
2001-06-20 03:05:50 +00:00
|
|
|
for (d = pr.def_head.def_next; d; d = d->def_next) {
|
2001-02-24 06:58:54 +00:00
|
|
|
if (!strcmp (d->name, "end_sys_fields"))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (d->type->type != ev_field)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (d->type->aux_type->type) {
|
|
|
|
case ev_float:
|
|
|
|
fprintf (f, "\tfloat\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
case ev_vector:
|
|
|
|
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
2001-06-20 03:05:50 +00:00
|
|
|
d = d->def_next->def_next->def_next; // skip the elements
|
2001-02-24 06:58:54 +00:00
|
|
|
break;
|
|
|
|
case ev_string:
|
|
|
|
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
|
|
|
break;
|
2001-03-28 17:17:56 +00:00
|
|
|
case ev_func:
|
2001-02-24 06:58:54 +00:00
|
|
|
fprintf (f, "\tfunc_t\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
case ev_entity:
|
|
|
|
fprintf (f, "\tint\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf (f, "\tint\t%s;\n", d->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (f, "} entvars_t;\n\n");
|
|
|
|
|
|
|
|
fclose (f);
|
|
|
|
|
|
|
|
// do a crc of the file
|
|
|
|
CRC_Init (&crc);
|
|
|
|
f = fopen (filename, "r+");
|
|
|
|
while ((c = fgetc (f)) != EOF)
|
|
|
|
CRC_ProcessByte (&crc, (byte) c);
|
|
|
|
|
|
|
|
fprintf (f, "#define PROGHEADER_CRC %i\n", crc);
|
|
|
|
fclose (f);
|
|
|
|
|
|
|
|
return crc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-05 08:09:12 +00:00
|
|
|
void
|
|
|
|
PR_PrintFunction (def_t *def)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
def_t *d;
|
|
|
|
statref_t *r;
|
2001-06-05 08:09:12 +00:00
|
|
|
|
|
|
|
printf ("%s\n", def->name);
|
|
|
|
for (d = def->scope_next; d; d = d->scope_next) {
|
|
|
|
printf ("%s: %d %d %d\n",
|
|
|
|
d->name ? d->name : "<temp>",
|
2001-11-12 23:56:46 +00:00
|
|
|
d->ofs, d->type->type, pr_type_size[d->type->type]);
|
2001-06-05 08:09:12 +00:00
|
|
|
for (r = d->refs; r; r = r->next)
|
2001-12-06 19:49:40 +00:00
|
|
|
printf (" %ld", (long) (r->statement - statements));
|
2001-06-05 08:09:12 +00:00
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-26 08:14:05 +00:00
|
|
|
static void
|
|
|
|
usage (int status)
|
2001-10-26 06:43:56 +00:00
|
|
|
{
|
2001-10-26 22:07:35 +00:00
|
|
|
printf ("%s - QuakeForge Code Compiler\n", this_program);
|
2001-10-26 16:04:38 +00:00
|
|
|
printf ("Usage: %s [options]\n", this_program);
|
2001-12-06 19:49:40 +00:00
|
|
|
printf ("Options:\n"
|
|
|
|
" -s, --source DIR Look for progs.src in DIR instead of \".\"\n"
|
|
|
|
" -q, --quiet Inhibit usual output\n"
|
|
|
|
" -v, --verbose Display more output than usual\n"
|
|
|
|
" -g, Generate debuggin info\n"
|
|
|
|
" -C, --code OPTION,... Set code generation options\n"
|
|
|
|
" -W, --warn OPTION,... Set warning options\n"
|
|
|
|
" -h, --help Display this help and exit\n"
|
|
|
|
" -V, --version Output version information and exit\n\n"
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2002-01-05 19:13:20 +00:00
|
|
|
" -S, --save-temps Do not delete temporary files\n"
|
2001-12-06 19:49:40 +00:00
|
|
|
" -D, --define SYMBOL[=VAL],... Define symbols for the preprocessor\n"
|
|
|
|
" -I, --include DIR,... Set directories for the preprocessor \n"
|
|
|
|
" to search for #includes\n"
|
|
|
|
" -U, --undefine SYMBOL,... Undefine preprocessor symbols\n\n"
|
2001-10-26 22:07:35 +00:00
|
|
|
#endif
|
2001-12-06 19:49:40 +00:00
|
|
|
"For help on options for --code and --warn, see the qfcc(1) manual page\n");
|
2001-10-26 08:14:05 +00:00
|
|
|
exit (status);
|
|
|
|
}
|
2001-10-26 06:43:56 +00:00
|
|
|
|
2002-02-05 18:40:47 +00:00
|
|
|
#ifdef USE_CPP
|
|
|
|
static void
|
|
|
|
add_cpp_arg (const char *arg)
|
|
|
|
{
|
|
|
|
cpp_arg_t *cpp_arg = malloc (sizeof (cpp_arg_t));
|
|
|
|
cpp_arg->next = 0;
|
|
|
|
cpp_arg->arg = arg;
|
|
|
|
*cpp_arg_tail = cpp_arg;
|
|
|
|
cpp_arg_tail = &(*cpp_arg_tail)->next;
|
|
|
|
cpp_argc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_cpp_def (const char *arg)
|
|
|
|
{
|
|
|
|
cpp_arg_t *cpp_def = malloc (sizeof (cpp_arg_t));
|
|
|
|
cpp_def->next = 0;
|
|
|
|
cpp_def->arg = arg;
|
|
|
|
*cpp_def_tail = cpp_def;
|
|
|
|
cpp_def_tail = &(*cpp_def_tail)->next;
|
|
|
|
cpp_argc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
parse_cpp_name ()
|
|
|
|
{
|
|
|
|
char *n;
|
|
|
|
|
|
|
|
n = strdup (cpp_name);
|
|
|
|
while (*n) {
|
|
|
|
while (*n && *n == ' ')
|
|
|
|
n++;
|
|
|
|
add_cpp_arg (n);
|
|
|
|
while (*n && *n != ' ')
|
|
|
|
n++;
|
|
|
|
if (*n)
|
|
|
|
*n++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
build_cpp_args (const char *in_name, const char *out_name)
|
|
|
|
{
|
|
|
|
cpp_arg_t *cpp_arg;
|
|
|
|
cpp_arg_t *cpp_def;
|
|
|
|
const char **arg;
|
|
|
|
|
|
|
|
if (cpp_argv)
|
|
|
|
free (cpp_argv);
|
|
|
|
cpp_argv = (const char **)malloc ((cpp_argc + 1) * sizeof (char**));
|
|
|
|
for (arg = cpp_argv, cpp_arg = cpp_arg_list;
|
|
|
|
cpp_arg;
|
|
|
|
cpp_arg = cpp_arg->next) {
|
|
|
|
if (!strcmp (cpp_arg->arg, "%d")) {
|
|
|
|
for (cpp_def = cpp_def_list; cpp_def; cpp_def = cpp_def->next)
|
|
|
|
*arg++ = cpp_def->arg;
|
|
|
|
} else if (!strcmp (cpp_arg->arg, "%i")) {
|
|
|
|
*arg++ = in_name;
|
|
|
|
} else if (!strcmp (cpp_arg->arg, "%o")) {
|
|
|
|
*arg++ = out_name;
|
|
|
|
} else {
|
|
|
|
*arg++ = cpp_arg->arg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*arg = 0;
|
2002-02-05 19:35:45 +00:00
|
|
|
//for (arg = cpp_argv; *arg; arg++)
|
|
|
|
// printf ("%s ", *arg);
|
|
|
|
//puts ("");
|
2002-02-05 18:40:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-10-26 08:14:05 +00:00
|
|
|
static int
|
|
|
|
DecodeArgs (int argc, char **argv)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
int c;
|
2001-10-26 06:43:56 +00:00
|
|
|
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2002-02-05 18:40:47 +00:00
|
|
|
add_cpp_def ("-D__QFCC__=1");
|
|
|
|
add_cpp_def ("-D__QUAKEC__=1");
|
|
|
|
add_cpp_def ("-D__RUAMOKO__=1");
|
|
|
|
add_cpp_def ("-D__RAUMOKO__=1");
|
2001-10-26 22:07:35 +00:00
|
|
|
#endif
|
|
|
|
|
2001-10-26 08:14:05 +00:00
|
|
|
options.code.progsversion = PROG_VERSION;
|
2001-10-26 22:07:35 +00:00
|
|
|
options.warnings.uninited_variable = true;
|
2002-01-05 19:13:20 +00:00
|
|
|
|
|
|
|
options.save_temps = false;
|
2001-10-26 22:07:35 +00:00
|
|
|
options.verbosity = 0;
|
|
|
|
|
2002-02-05 22:08:19 +00:00
|
|
|
sourcedir = "";
|
2002-01-17 08:19:53 +00:00
|
|
|
progs_src = "progs.src";
|
2001-10-26 08:14:05 +00:00
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
while ((c = getopt_long (argc, argv, "s:" // source dir
|
2002-01-17 08:19:53 +00:00
|
|
|
"P:" // progs.src name
|
2002-01-21 23:30:54 +00:00
|
|
|
"F" // generate files.dat
|
2001-12-06 19:49:40 +00:00
|
|
|
"q" // quiet
|
|
|
|
"v" // verbose
|
|
|
|
"g" // debug
|
|
|
|
"C:" // code options
|
|
|
|
"W:" // warning options
|
|
|
|
"h" // help
|
|
|
|
"V" // version
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2002-01-05 19:13:20 +00:00
|
|
|
"S" // save temps
|
2001-12-06 19:49:40 +00:00
|
|
|
"D:" // define
|
|
|
|
"I:" // set includes
|
|
|
|
"U:" // undefine
|
2001-10-26 22:07:35 +00:00
|
|
|
#endif
|
2001-12-06 19:49:40 +00:00
|
|
|
, long_options, (int *) 0)) != EOF) {
|
2001-10-26 08:14:05 +00:00
|
|
|
switch (c) {
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'h': // help
|
2001-10-26 08:14:05 +00:00
|
|
|
usage (0);
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'V': // version
|
2001-10-26 08:17:04 +00:00
|
|
|
printf ("%s version %s\n", PACKAGE, VERSION);
|
2001-10-26 08:14:05 +00:00
|
|
|
exit (0);
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 's': // src dir
|
2001-10-26 08:14:05 +00:00
|
|
|
sourcedir = strdup (optarg);
|
|
|
|
break;
|
2002-01-17 08:19:53 +00:00
|
|
|
case 'P': // progs-src
|
|
|
|
progs_src = strdup (optarg);
|
|
|
|
break;
|
2002-01-21 23:30:54 +00:00
|
|
|
case 'F':
|
|
|
|
options.files_dat = true;
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'q': // quiet
|
2001-10-26 08:14:05 +00:00
|
|
|
options.verbosity -= 1;
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'v': // verbose
|
2001-10-26 08:14:05 +00:00
|
|
|
options.verbosity += 1;
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'g': // debug
|
2002-01-05 19:13:20 +00:00
|
|
|
options.code.debug = true;
|
2001-11-14 23:17:20 +00:00
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'C':{ // code options
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
2001-10-26 08:14:05 +00:00
|
|
|
|
|
|
|
while (temp) {
|
|
|
|
if (!(strcasecmp (temp, "cow"))) {
|
|
|
|
options.code.cow = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-cow"))) {
|
|
|
|
options.code.cow = false;
|
2001-10-26 16:04:38 +00:00
|
|
|
} else if (!(strcasecmp (temp, "no-cpp"))) {
|
2002-02-05 19:35:45 +00:00
|
|
|
cpp_name = 0;
|
2001-10-26 08:14:05 +00:00
|
|
|
} else if (!(strcasecmp (temp, "debug"))) {
|
|
|
|
options.code.debug = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-debug"))) {
|
|
|
|
options.code.debug = false;
|
|
|
|
} else if (!(strcasecmp (temp, "v6only"))) {
|
|
|
|
options.code.progsversion = PROG_ID_VERSION;
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2002-02-05 18:40:47 +00:00
|
|
|
add_cpp_def ("-D__VERSION6__=1");
|
2001-10-26 22:07:35 +00:00
|
|
|
#endif
|
2001-10-26 08:14:05 +00:00
|
|
|
} else if (!(strcasecmp (temp, "no-v6only"))) {
|
|
|
|
options.code.progsversion = PROG_VERSION;
|
|
|
|
}
|
|
|
|
temp = strtok (NULL, ",");
|
|
|
|
}
|
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'W':{ // warning options
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
2001-10-26 08:14:05 +00:00
|
|
|
|
|
|
|
while (temp) {
|
|
|
|
if (!(strcasecmp (temp, "all"))) {
|
|
|
|
options.warnings.cow = true;
|
|
|
|
options.warnings.undefined_function = true;
|
|
|
|
options.warnings.uninited_variable = true;
|
|
|
|
options.warnings.vararg_integer = true;
|
2001-12-12 22:00:42 +00:00
|
|
|
options.warnings.integer_divide = true;
|
2001-10-26 08:14:05 +00:00
|
|
|
} else if (!(strcasecmp (temp, "none"))) {
|
|
|
|
options.warnings.cow = false;
|
|
|
|
options.warnings.undefined_function = false;
|
|
|
|
options.warnings.uninited_variable = false;
|
|
|
|
options.warnings.vararg_integer = false;
|
2001-12-12 22:00:42 +00:00
|
|
|
options.warnings.integer_divide = false;
|
2001-10-26 08:14:05 +00:00
|
|
|
} else if (!(strcasecmp (temp, "cow"))) {
|
|
|
|
options.warnings.cow = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-cow"))) {
|
|
|
|
options.warnings.cow = false;
|
|
|
|
} else if (!(strcasecmp (temp, "error"))) {
|
|
|
|
options.warnings.promote = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-error"))) {
|
|
|
|
options.warnings.promote = false;
|
|
|
|
} else if (!(strcasecmp (temp, "undef-function"))) {
|
|
|
|
options.warnings.undefined_function = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-undef-function"))) {
|
|
|
|
options.warnings.undefined_function = false;
|
|
|
|
} else if (!(strcasecmp (temp, "uninited-var"))) {
|
|
|
|
options.warnings.uninited_variable = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-uninited-var"))) {
|
|
|
|
options.warnings.uninited_variable = false;
|
|
|
|
} else if (!(strcasecmp (temp, "vararg-integer"))) {
|
|
|
|
options.warnings.vararg_integer = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-vararg-integer"))) {
|
|
|
|
options.warnings.vararg_integer = false;
|
2001-12-12 22:00:42 +00:00
|
|
|
} else if (!(strcasecmp (temp, "integer-divide"))) {
|
|
|
|
options.warnings.integer_divide = true;
|
|
|
|
} else if (!(strcasecmp (temp, "no-integer-divide"))) {
|
|
|
|
options.warnings.integer_divide = false;
|
2001-10-26 08:14:05 +00:00
|
|
|
}
|
|
|
|
temp = strtok (NULL, ",");
|
|
|
|
}
|
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
2001-10-26 22:07:35 +00:00
|
|
|
#ifdef USE_CPP
|
2002-02-05 19:35:45 +00:00
|
|
|
case 256: // --cpp=
|
|
|
|
cpp_name = strdup (optarg);
|
|
|
|
break;
|
2002-01-05 19:13:20 +00:00
|
|
|
case 'S': // save temps
|
|
|
|
options.save_temps = true;
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'D':{ // defines for cpp
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
2001-10-26 22:07:35 +00:00
|
|
|
|
2002-02-05 18:40:47 +00:00
|
|
|
while (temp) {
|
2001-12-06 19:49:40 +00:00
|
|
|
char temp2[1024];
|
2001-10-26 22:07:35 +00:00
|
|
|
|
|
|
|
snprintf (temp2, sizeof (temp2), "%s%s", "-D", temp);
|
2002-02-05 18:40:47 +00:00
|
|
|
add_cpp_def (strdup (temp2));
|
2001-10-26 22:07:35 +00:00
|
|
|
temp = strtok (NULL, ",");
|
2001-12-06 19:49:40 +00:00
|
|
|
}
|
2001-10-26 22:07:35 +00:00
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'I':{ // includes
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
2001-10-26 22:07:35 +00:00
|
|
|
|
2002-02-05 18:40:47 +00:00
|
|
|
while (temp) {
|
2001-12-06 19:49:40 +00:00
|
|
|
char temp2[1024];
|
2001-10-26 22:07:35 +00:00
|
|
|
|
|
|
|
snprintf (temp2, sizeof (temp2), "%s%s", "-I", temp);
|
2002-02-05 18:40:47 +00:00
|
|
|
add_cpp_def (strdup (temp2));
|
2001-10-26 22:07:35 +00:00
|
|
|
temp = strtok (NULL, ",");
|
2001-12-06 19:49:40 +00:00
|
|
|
}
|
2001-10-26 22:07:35 +00:00
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
2001-12-06 19:49:40 +00:00
|
|
|
case 'U':{ // undefines
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
2001-10-26 22:07:35 +00:00
|
|
|
|
2002-02-05 18:40:47 +00:00
|
|
|
while (temp) {
|
2001-12-06 19:49:40 +00:00
|
|
|
char temp2[1024];
|
2001-10-26 22:07:35 +00:00
|
|
|
|
|
|
|
snprintf (temp2, sizeof (temp2), "%s%s", "-U", temp);
|
2002-02-05 18:40:47 +00:00
|
|
|
add_cpp_def (strdup (temp2));
|
2001-10-26 22:07:35 +00:00
|
|
|
temp = strtok (NULL, ",");
|
2001-12-06 19:49:40 +00:00
|
|
|
}
|
2001-10-26 22:07:35 +00:00
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2001-10-26 08:14:05 +00:00
|
|
|
default:
|
|
|
|
usage (1);
|
|
|
|
}
|
2001-10-26 06:43:56 +00:00
|
|
|
}
|
2001-10-26 08:14:05 +00:00
|
|
|
return optind;
|
2001-10-26 06:43:56 +00:00
|
|
|
}
|
2001-12-06 19:49:40 +00:00
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
main
|
|
|
|
|
|
|
|
The nerve center of our little operation
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2001-12-06 19:49:40 +00:00
|
|
|
char *src;
|
|
|
|
char filename[1024];
|
2002-01-21 23:30:54 +00:00
|
|
|
int crc = 0;
|
2001-12-06 19:49:40 +00:00
|
|
|
double start, stop;
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-04-01 03:33:11 +00:00
|
|
|
start = Sys_DoubleTime ();
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-10-26 16:04:38 +00:00
|
|
|
this_program = argv[0];
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-10-26 08:14:05 +00:00
|
|
|
DecodeArgs (argc, argv);
|
2001-08-04 09:11:50 +00:00
|
|
|
|
2002-02-05 22:08:19 +00:00
|
|
|
if (strcmp (sourcedir, "")) {
|
2001-02-24 06:58:54 +00:00
|
|
|
printf ("Source directory: %s\n", sourcedir);
|
|
|
|
}
|
2002-01-17 08:19:53 +00:00
|
|
|
if (strcmp (progs_src, "progs.src")) {
|
|
|
|
printf ("progs.src: %s\n", progs_src);
|
|
|
|
}
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-07-14 02:34:16 +00:00
|
|
|
PR_Opcode_Init_Tables ();
|
2001-06-04 02:41:45 +00:00
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
InitData ();
|
|
|
|
|
2002-02-05 22:08:19 +00:00
|
|
|
if (*sourcedir)
|
|
|
|
snprintf (filename, sizeof (filename), "%s/%s", sourcedir, progs_src);
|
|
|
|
else
|
|
|
|
snprintf (filename, sizeof (filename), "%s", progs_src);
|
2001-02-24 06:58:54 +00:00
|
|
|
LoadFile (filename, (void *) &src);
|
|
|
|
|
2001-10-26 02:32:40 +00:00
|
|
|
if (!(src = Parse (src)))
|
2001-02-24 06:58:54 +00:00
|
|
|
Error ("No destination filename. qfcc --help for info.\n");
|
|
|
|
|
2002-01-04 11:12:52 +00:00
|
|
|
strcpy (destfile, qfcc_com_token);
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= 1) {
|
2001-07-03 21:17:02 +00:00
|
|
|
printf ("outputfile: %s\n", destfile);
|
2001-07-14 01:15:40 +00:00
|
|
|
}
|
2001-10-26 06:43:56 +00:00
|
|
|
if (options.code.debug) {
|
2001-12-06 19:49:40 +00:00
|
|
|
char *s;
|
|
|
|
|
2002-01-04 11:12:52 +00:00
|
|
|
strcpy (debugfile, qfcc_com_token);
|
2001-07-14 01:15:40 +00:00
|
|
|
|
|
|
|
s = debugfile + strlen (debugfile);
|
|
|
|
while (s-- > debugfile) {
|
|
|
|
if (*s == '.')
|
|
|
|
break;
|
|
|
|
if (*s == '/' || *s == '\\') {
|
|
|
|
s = debugfile + strlen (debugfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcpy (s, ".sym");
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= 1)
|
2001-07-14 01:15:40 +00:00
|
|
|
printf ("debug file: %s\n", debugfile);
|
|
|
|
}
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-10-24 22:53:27 +00:00
|
|
|
PR_BeginCompilation ();
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2002-02-05 18:40:47 +00:00
|
|
|
#ifdef USE_CPP
|
|
|
|
parse_cpp_name ();
|
|
|
|
#endif
|
|
|
|
|
2001-02-24 06:58:54 +00:00
|
|
|
// compile all the files
|
2001-10-26 02:32:40 +00:00
|
|
|
while ((src = Parse (src))) {
|
2001-07-17 05:02:34 +00:00
|
|
|
#ifdef USE_CPP
|
2001-11-15 03:54:35 +00:00
|
|
|
# ifndef _WIN32
|
2001-12-06 19:49:40 +00:00
|
|
|
pid_t pid;
|
2002-01-05 19:13:20 +00:00
|
|
|
int tempfd = 0;
|
2001-11-15 03:54:35 +00:00
|
|
|
# endif
|
2001-12-06 19:49:40 +00:00
|
|
|
char *temp1;
|
|
|
|
char *temp2 = strrchr (argv[0], PATH_SEPARATOR);
|
|
|
|
char tempname[1024];
|
2001-07-17 05:02:34 +00:00
|
|
|
#endif
|
2001-12-06 19:49:40 +00:00
|
|
|
int error;
|
2001-10-26 06:43:56 +00:00
|
|
|
|
2001-06-13 18:35:41 +00:00
|
|
|
extern FILE *yyin;
|
2001-12-06 19:49:40 +00:00
|
|
|
int yyparse (void);
|
2001-06-13 18:35:41 +00:00
|
|
|
extern void clear_frame_macros (void);
|
2001-10-26 06:43:56 +00:00
|
|
|
|
2001-12-06 19:49:40 +00:00
|
|
|
// extern int yydebug;
|
|
|
|
// yydebug = 1;
|
2001-06-13 07:16:39 +00:00
|
|
|
|
2002-02-05 22:08:19 +00:00
|
|
|
if (*sourcedir)
|
|
|
|
snprintf (filename, sizeof (filename), "%s%c%s", sourcedir,
|
|
|
|
PATH_SEPARATOR, qfcc_com_token);
|
|
|
|
else
|
|
|
|
snprintf (filename, sizeof (filename), "%s", qfcc_com_token);
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= 2)
|
2001-07-03 21:17:02 +00:00
|
|
|
printf ("compiling %s\n", filename);
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-07-17 05:02:34 +00:00
|
|
|
#ifdef USE_CPP
|
2002-02-05 19:35:45 +00:00
|
|
|
if (cpp_name) {
|
2002-01-05 19:13:20 +00:00
|
|
|
if (options.save_temps) {
|
|
|
|
char *basename = strdup (filename);
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
temp = strrchr (basename, '.');
|
|
|
|
if (temp)
|
|
|
|
*temp = '\0'; // ignore the rest of the string
|
|
|
|
|
2002-02-05 22:08:19 +00:00
|
|
|
temp = strrchr (basename, '/');
|
|
|
|
if (!temp)
|
|
|
|
temp = basename;
|
|
|
|
else
|
|
|
|
temp++;
|
|
|
|
|
|
|
|
if (*sourcedir)
|
|
|
|
snprintf (tempname, sizeof (tempname), "%s%c%s", sourcedir,
|
|
|
|
PATH_SEPARATOR, temp);
|
|
|
|
else
|
|
|
|
snprintf (tempname, sizeof (tempname), "%s.p", temp);
|
2002-01-05 19:13:20 +00:00
|
|
|
free (basename);
|
|
|
|
} else {
|
|
|
|
temp1 = getenv ("TMPDIR");
|
2001-07-20 05:22:44 +00:00
|
|
|
if ((!temp1) || (!temp1[0])) {
|
2002-01-05 19:13:20 +00:00
|
|
|
temp1 = getenv ("TEMP");
|
|
|
|
if ((!temp1) || (!temp1[0])) {
|
|
|
|
temp1 = "/tmp";
|
|
|
|
}
|
2001-07-20 05:22:44 +00:00
|
|
|
}
|
2001-07-17 05:02:34 +00:00
|
|
|
|
2002-01-05 19:13:20 +00:00
|
|
|
snprintf (tempname, sizeof (tempname), "%s%c%sXXXXXX", temp1,
|
|
|
|
PATH_SEPARATOR, temp2 ? temp2 + 1 : argv[0]);
|
|
|
|
}
|
2002-02-05 18:40:47 +00:00
|
|
|
build_cpp_args (filename, tempname);
|
2001-07-17 05:02:34 +00:00
|
|
|
|
2001-11-15 03:54:35 +00:00
|
|
|
# ifdef _WIN32
|
2002-01-05 19:13:20 +00:00
|
|
|
if (!options.save_temps)
|
|
|
|
mktemp (tempname);
|
2001-11-15 03:54:35 +00:00
|
|
|
yyin = fopen (tempname, "wt");
|
|
|
|
fclose (yyin);
|
|
|
|
|
|
|
|
{
|
2002-02-05 18:40:47 +00:00
|
|
|
int status = spawnvp (_P_WAIT, cpp_argv[0], cpp_argv);
|
2001-11-15 03:54:35 +00:00
|
|
|
|
|
|
|
if (status) {
|
2002-01-05 19:13:20 +00:00
|
|
|
fprintf (stderr, "%s: cpp returned error code %d\n",
|
|
|
|
filename,
|
|
|
|
status);
|
2001-11-15 03:54:35 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
yyin = fopen (tempname, "rt");
|
|
|
|
# else
|
2002-01-05 19:13:20 +00:00
|
|
|
if (!options.save_temps)
|
|
|
|
tempfd = mkstemp (tempname);
|
|
|
|
|
2001-07-20 05:22:44 +00:00
|
|
|
if ((pid = fork ()) == -1) {
|
|
|
|
perror ("fork");
|
|
|
|
return 1;
|
|
|
|
}
|
2001-12-06 19:49:40 +00:00
|
|
|
if (!pid) {
|
|
|
|
// we're a child, check for abuse
|
2002-02-05 18:40:47 +00:00
|
|
|
execvp (cpp_argv[0], (char **)cpp_argv);
|
2002-01-05 19:13:20 +00:00
|
|
|
fprintf (stderr, "Child shouldn't reach here\n");
|
2001-07-20 05:22:44 +00:00
|
|
|
exit (1);
|
2001-12-06 19:49:40 +00:00
|
|
|
} else {
|
|
|
|
// give parental guidance (or bury it in the back yard)
|
|
|
|
int status;
|
|
|
|
pid_t rc;
|
|
|
|
|
|
|
|
// printf ("pid = %d\n", pid);
|
2001-07-20 05:22:44 +00:00
|
|
|
if ((rc = waitpid (0, &status, 0 | WUNTRACED)) != pid) {
|
|
|
|
if (rc == -1) {
|
|
|
|
perror ("wait");
|
|
|
|
exit (1);
|
|
|
|
}
|
2002-01-05 19:13:20 +00:00
|
|
|
fprintf (stderr, "%s: The wrong child (%d) died. Don't ask me, I don't know either.\n",
|
|
|
|
this_program,
|
2001-07-20 05:22:44 +00:00
|
|
|
rc);
|
2001-07-17 05:02:34 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
2001-07-20 05:22:44 +00:00
|
|
|
if (WIFEXITED (status)) {
|
|
|
|
if (WEXITSTATUS (status)) {
|
2002-01-05 19:13:20 +00:00
|
|
|
fprintf (stderr, "%s: cpp returned error code %d\n",
|
|
|
|
filename,
|
2001-07-20 05:22:44 +00:00
|
|
|
WEXITSTATUS (status));
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
} else {
|
2002-01-05 19:13:20 +00:00
|
|
|
fprintf (stderr, "%s: cpp returned prematurely.\n", filename);
|
2001-07-17 05:02:34 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
2002-01-05 19:13:20 +00:00
|
|
|
if (options.save_temps)
|
|
|
|
yyin = fopen (tempname, "rt");
|
|
|
|
else
|
|
|
|
yyin = fdopen (tempfd, "r+t");
|
2001-11-15 03:54:35 +00:00
|
|
|
# endif
|
2001-07-20 05:22:44 +00:00
|
|
|
} else {
|
|
|
|
yyin = fopen (filename, "rt");
|
2001-07-17 05:02:34 +00:00
|
|
|
}
|
|
|
|
#else
|
2001-06-13 18:35:41 +00:00
|
|
|
yyin = fopen (filename, "rt");
|
2001-07-17 05:02:34 +00:00
|
|
|
#endif
|
2001-06-25 22:11:20 +00:00
|
|
|
s_file = ReuseString (filename);
|
2001-06-25 23:38:32 +00:00
|
|
|
pr_source_line = 1;
|
2001-06-13 18:35:41 +00:00
|
|
|
clear_frame_macros ();
|
2001-07-24 04:45:53 +00:00
|
|
|
error = yyparse () || pr_error_count;
|
2001-06-13 18:35:41 +00:00
|
|
|
fclose (yyin);
|
2001-07-17 05:02:34 +00:00
|
|
|
#ifdef USE_CPP
|
2002-02-05 19:35:45 +00:00
|
|
|
if (cpp_name && (!options.save_temps)) {
|
2001-07-20 05:22:44 +00:00
|
|
|
if (unlink (tempname)) {
|
|
|
|
perror ("unlink");
|
|
|
|
exit (1);
|
|
|
|
}
|
2001-07-17 05:02:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-07-24 04:45:53 +00:00
|
|
|
if (error)
|
|
|
|
return 1;
|
2001-02-24 06:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!PR_FinishCompilation ())
|
|
|
|
Error ("compilation errors");
|
|
|
|
|
|
|
|
// write progdefs.h
|
2002-01-21 23:30:54 +00:00
|
|
|
if (options.code.progsversion == PROG_ID_VERSION)
|
|
|
|
crc = PR_WriteProgdefs ("progdefs.h");
|
2001-02-24 06:58:54 +00:00
|
|
|
|
|
|
|
// write data file
|
|
|
|
WriteData (crc);
|
|
|
|
|
|
|
|
// write files.dat
|
2002-01-21 23:30:54 +00:00
|
|
|
if (options.files_dat)
|
|
|
|
WriteFiles ();
|
2001-02-24 06:58:54 +00:00
|
|
|
|
2001-04-01 03:33:11 +00:00
|
|
|
stop = Sys_DoubleTime ();
|
2001-10-26 22:07:35 +00:00
|
|
|
if (options.verbosity >= 0)
|
2001-10-26 06:43:56 +00:00
|
|
|
printf ("Compilation time: %0.3g seconds.\n", (stop - start));
|
2001-03-28 17:17:56 +00:00
|
|
|
return 0;
|
2001-02-24 06:58:54 +00:00
|
|
|
}
|