allow the output file to be specified on the command line

This commit is contained in:
Bill Currie 2002-06-24 22:53:21 +00:00
parent 4d496a2cd6
commit ecdb5a5cb4
6 changed files with 17 additions and 13 deletions

View file

@ -30,12 +30,12 @@ int FileLength (FILE *f);
void Error (char *error, ...)__attribute__((format(printf, 1,2)));
FILE *SafeOpenWrite (char *filename);
FILE *SafeOpenRead (char *filename);
FILE *SafeOpenWrite (const char *filename);
FILE *SafeOpenRead (const char *filename);
void SafeRead (FILE *f, void *buffer, int count);
void SafeWrite (FILE *f, void *buffer, int count);
int LoadFile (char *filename, void **bufferptr);
int LoadFile (const char *filename, void **bufferptr);
char *Parse (char *data);

View file

@ -66,6 +66,7 @@ typedef struct {
qboolean compile; // serparate compilation mode
int strip_path; // number of leading path elements to strip
// from source file names
const char *output_file;
} options_t;
extern options_t options;

View file

@ -53,6 +53,7 @@ static const char rcsid[] =
#include "expr.h"
#include "immediate.h"
#include "method.h"
#include "options.h"
#include "reloc.h"
#include "struct.h"
#include "type.h"
@ -469,7 +470,7 @@ class_finish_module (void)
module_def->initialized = module_def->constant = 1;
module = &G_STRUCT (pr_module_t, module_def->ofs);
module->size = type_size (type_module);
module->name = ReuseString (destfile);
module->name = ReuseString (options.output_file);
module->symtab = symtab_def->ofs;
exec_class_def = get_def (&type_obj_exec_class, "__obj_exec_class",

View file

@ -167,7 +167,7 @@ FileLength (FILE *f)
FILE *
SafeOpenWrite (char *filename)
SafeOpenWrite (const char *filename)
{
FILE *f;
@ -180,7 +180,7 @@ SafeOpenWrite (char *filename)
}
FILE *
SafeOpenRead (char *filename)
SafeOpenRead (const char *filename)
{
FILE *f;
@ -213,7 +213,7 @@ SafeWrite (FILE *f, void *buffer, int count)
LoadFile
*/
int
LoadFile (char *filename, void **bufferptr)
LoadFile (const char *filename, void **bufferptr)
{
FILE *f;
int length;

View file

@ -54,6 +54,7 @@ static const char rcsid[] =
const char *this_program;
static struct option const long_options[] = {
{"output-file", required_argument, 0, 'o'},
{"source", required_argument, 0, 's'},
{"progs-src", required_argument, 0, 'P'},
{"save-temps", no_argument, 0, 'S'},
@ -75,6 +76,7 @@ static struct option const long_options[] = {
};
static const char *short_options =
"o:" // output file
"c" // separate compilation
"s:" // source dir
"P:" // progs.src name

View file

@ -82,7 +82,6 @@ options_t options;
const char *sourcedir;
const char *progs_src;
char destfile[1024];
char debugfile[1024];
pr_info_t pr;
@ -175,7 +174,7 @@ WriteData (int crc)
printf ("%6i entity fields\n", pr.entity_data->size);
}
h = SafeOpenWrite (destfile);
h = SafeOpenWrite (options.output_file);
SafeWrite (h, &progs, sizeof (progs));
progs.ofs_strings = ftell (h);
@ -255,7 +254,7 @@ WriteData (int crc)
return;
}
h = SafeOpenRead (destfile);
h = SafeOpenRead (options.output_file);
debug.version = LittleLong (PROG_DEBUG_VERSION);
CRC_Init (&debug.crc);
@ -434,9 +433,10 @@ main (int argc, char **argv)
if (!(src = Parse (src)))
Error ("No destination filename. qfcc --help for info.\n");
strcpy (destfile, qfcc_com_token);
if (!options.output_file)
options.output_file = strdup (qfcc_com_token);
if (options.verbosity >= 1) {
printf ("outputfile: %s\n", destfile);
printf ("output file: %s\n", options.output_file);
}
if (options.code.debug) {
char *s;
@ -496,7 +496,7 @@ main (int argc, char **argv)
}
if (options.compile) {
write_obj_file ("test.qfo");
write_obj_file (options.output_file);
} else {
if (!finish_compilation ())
Error ("compilation errors");