mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
allow the output file to be specified on the command line
This commit is contained in:
parent
4d496a2cd6
commit
ecdb5a5cb4
6 changed files with 17 additions and 13 deletions
|
@ -30,12 +30,12 @@ int FileLength (FILE *f);
|
||||||
|
|
||||||
void Error (char *error, ...)__attribute__((format(printf, 1,2)));
|
void Error (char *error, ...)__attribute__((format(printf, 1,2)));
|
||||||
|
|
||||||
FILE *SafeOpenWrite (char *filename);
|
FILE *SafeOpenWrite (const char *filename);
|
||||||
FILE *SafeOpenRead (char *filename);
|
FILE *SafeOpenRead (const char *filename);
|
||||||
void SafeRead (FILE *f, void *buffer, int count);
|
void SafeRead (FILE *f, void *buffer, int count);
|
||||||
void SafeWrite (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);
|
char *Parse (char *data);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ typedef struct {
|
||||||
qboolean compile; // serparate compilation mode
|
qboolean compile; // serparate compilation mode
|
||||||
int strip_path; // number of leading path elements to strip
|
int strip_path; // number of leading path elements to strip
|
||||||
// from source file names
|
// from source file names
|
||||||
|
const char *output_file;
|
||||||
} options_t;
|
} options_t;
|
||||||
|
|
||||||
extern options_t options;
|
extern options_t options;
|
||||||
|
|
|
@ -53,6 +53,7 @@ static const char rcsid[] =
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "immediate.h"
|
#include "immediate.h"
|
||||||
#include "method.h"
|
#include "method.h"
|
||||||
|
#include "options.h"
|
||||||
#include "reloc.h"
|
#include "reloc.h"
|
||||||
#include "struct.h"
|
#include "struct.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
@ -469,7 +470,7 @@ class_finish_module (void)
|
||||||
module_def->initialized = module_def->constant = 1;
|
module_def->initialized = module_def->constant = 1;
|
||||||
module = &G_STRUCT (pr_module_t, module_def->ofs);
|
module = &G_STRUCT (pr_module_t, module_def->ofs);
|
||||||
module->size = type_size (type_module);
|
module->size = type_size (type_module);
|
||||||
module->name = ReuseString (destfile);
|
module->name = ReuseString (options.output_file);
|
||||||
module->symtab = symtab_def->ofs;
|
module->symtab = symtab_def->ofs;
|
||||||
|
|
||||||
exec_class_def = get_def (&type_obj_exec_class, "__obj_exec_class",
|
exec_class_def = get_def (&type_obj_exec_class, "__obj_exec_class",
|
||||||
|
|
|
@ -167,7 +167,7 @@ FileLength (FILE *f)
|
||||||
|
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
SafeOpenWrite (char *filename)
|
SafeOpenWrite (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ SafeOpenWrite (char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
SafeOpenRead (char *filename)
|
SafeOpenRead (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ SafeWrite (FILE *f, void *buffer, int count)
|
||||||
LoadFile
|
LoadFile
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
LoadFile (char *filename, void **bufferptr)
|
LoadFile (const char *filename, void **bufferptr)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int length;
|
int length;
|
||||||
|
|
|
@ -54,6 +54,7 @@ static const char rcsid[] =
|
||||||
const char *this_program;
|
const char *this_program;
|
||||||
|
|
||||||
static struct option const long_options[] = {
|
static struct option const long_options[] = {
|
||||||
|
{"output-file", required_argument, 0, 'o'},
|
||||||
{"source", required_argument, 0, 's'},
|
{"source", required_argument, 0, 's'},
|
||||||
{"progs-src", required_argument, 0, 'P'},
|
{"progs-src", required_argument, 0, 'P'},
|
||||||
{"save-temps", no_argument, 0, 'S'},
|
{"save-temps", no_argument, 0, 'S'},
|
||||||
|
@ -75,6 +76,7 @@ static struct option const long_options[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *short_options =
|
static const char *short_options =
|
||||||
|
"o:" // output file
|
||||||
"c" // separate compilation
|
"c" // separate compilation
|
||||||
"s:" // source dir
|
"s:" // source dir
|
||||||
"P:" // progs.src name
|
"P:" // progs.src name
|
||||||
|
|
|
@ -82,7 +82,6 @@ options_t options;
|
||||||
const char *sourcedir;
|
const char *sourcedir;
|
||||||
const char *progs_src;
|
const char *progs_src;
|
||||||
|
|
||||||
char destfile[1024];
|
|
||||||
char debugfile[1024];
|
char debugfile[1024];
|
||||||
|
|
||||||
pr_info_t pr;
|
pr_info_t pr;
|
||||||
|
@ -175,7 +174,7 @@ WriteData (int crc)
|
||||||
printf ("%6i entity fields\n", pr.entity_data->size);
|
printf ("%6i entity fields\n", pr.entity_data->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
h = SafeOpenWrite (destfile);
|
h = SafeOpenWrite (options.output_file);
|
||||||
SafeWrite (h, &progs, sizeof (progs));
|
SafeWrite (h, &progs, sizeof (progs));
|
||||||
|
|
||||||
progs.ofs_strings = ftell (h);
|
progs.ofs_strings = ftell (h);
|
||||||
|
@ -255,7 +254,7 @@ WriteData (int crc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = SafeOpenRead (destfile);
|
h = SafeOpenRead (options.output_file);
|
||||||
|
|
||||||
debug.version = LittleLong (PROG_DEBUG_VERSION);
|
debug.version = LittleLong (PROG_DEBUG_VERSION);
|
||||||
CRC_Init (&debug.crc);
|
CRC_Init (&debug.crc);
|
||||||
|
@ -434,9 +433,10 @@ main (int argc, char **argv)
|
||||||
if (!(src = Parse (src)))
|
if (!(src = Parse (src)))
|
||||||
Error ("No destination filename. qfcc --help for info.\n");
|
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) {
|
if (options.verbosity >= 1) {
|
||||||
printf ("outputfile: %s\n", destfile);
|
printf ("output file: %s\n", options.output_file);
|
||||||
}
|
}
|
||||||
if (options.code.debug) {
|
if (options.code.debug) {
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -496,7 +496,7 @@ main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.compile) {
|
if (options.compile) {
|
||||||
write_obj_file ("test.qfo");
|
write_obj_file (options.output_file);
|
||||||
} else {
|
} else {
|
||||||
if (!finish_compilation ())
|
if (!finish_compilation ())
|
||||||
Error ("compilation errors");
|
Error ("compilation errors");
|
||||||
|
|
Loading…
Reference in a new issue