mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
Use the script api to parse progs.src instead of idparse. Now any additional tokens on the first line of progs.src are ignored and any additional tokens on subsequent lines get cumulatively added to the cpp command line. See progs.src[.in] in tools/qwaq for a simple example.
This is an imperfect revision of history.
This commit is contained in:
parent
a97f74a6ac
commit
7dfd9ab502
1 changed files with 23 additions and 6 deletions
|
@ -56,11 +56,11 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#include <errno.h>
|
||||
|
||||
#include <QF/cbuf.h>
|
||||
#include <QF/idparse.h>
|
||||
#include <QF/crc.h>
|
||||
#include <QF/dstring.h>
|
||||
#include <QF/hash.h>
|
||||
#include <QF/qendian.h>
|
||||
#include <QF/script.h>
|
||||
#include <QF/sys.h>
|
||||
#include <QF/va.h>
|
||||
|
||||
|
@ -672,6 +672,7 @@ progs_src_compile (void)
|
|||
dstring_t *filename = dstring_newstr ();
|
||||
const char *src;
|
||||
int crc = 0;
|
||||
script_t *script;
|
||||
|
||||
if (options.verbosity >= 1 && strcmp (sourcedir, "")) {
|
||||
printf ("Source directory: %s\n", sourcedir);
|
||||
|
@ -691,14 +692,21 @@ progs_src_compile (void)
|
|||
strerror (errno));
|
||||
return 1;
|
||||
}
|
||||
script = Script_New ();
|
||||
Script_Start (script, filename->str, src);
|
||||
|
||||
if (!(src = COM_Parse (src))) {
|
||||
if (!Script_GetToken (script, 1)) {
|
||||
fprintf (stderr, "No destination filename. qfcc --help for info.\n");
|
||||
return 1;
|
||||
}
|
||||
// Consume any aditional tokens on this line.
|
||||
// FIXME compilation options?
|
||||
// FIXME could break some progs.src files, have an optional control?
|
||||
while (Script_TokenAvailable (script, 0))
|
||||
Script_GetToken (script, 0);
|
||||
|
||||
if (!options.output_file)
|
||||
options.output_file = strdup (com_token);
|
||||
options.output_file = save_string (script->token->str);
|
||||
if (options.verbosity >= 1) {
|
||||
printf ("output file: %s\n", options.output_file);
|
||||
}
|
||||
|
@ -713,17 +721,26 @@ progs_src_compile (void)
|
|||
setup_param_block ();
|
||||
|
||||
// compile all the files
|
||||
while ((src = COM_Parse (src))) {
|
||||
while (Script_GetToken (script, 1)) {
|
||||
int err;
|
||||
|
||||
if (*sourcedir)
|
||||
dsprintf (filename, "%s%c%s", sourcedir, PATH_SEPARATOR,
|
||||
com_token);
|
||||
script->token->str);
|
||||
else
|
||||
dsprintf (filename, "%s", com_token);
|
||||
dsprintf (filename, "%s", script->token->str);
|
||||
if (options.verbosity >= 2)
|
||||
printf ("compiling %s\n", filename->str);
|
||||
|
||||
// Consume any aditional tokens on this line, cumulatively adding them
|
||||
// to the cpp command line.
|
||||
// FIXME is non-cumulative more desirable? make an option?
|
||||
// FIXME could break some progs.src files. have an optional control?
|
||||
while (Script_TokenAvailable (script, 0)) {
|
||||
Script_GetToken (script, 0);
|
||||
add_cpp_def (save_string (script->token->str));
|
||||
}
|
||||
|
||||
yyin = preprocess_file (filename->str);
|
||||
if (!yyin)
|
||||
return !options.preprocess_only;
|
||||
|
|
Loading…
Reference in a new issue