[qfcc] Add --ruamoko command line option and pragma

The command line option works the same way as
--advanced/traditional/extended, as does the pragma. As well, raumoko
(alternative spelling) can be used because both are legitimate and some
people may prefer one spelling over the other.

As always, use of the pragma is at one's own risk: its intended use is
forcing the target in the unit tests.
This commit is contained in:
Bill Currie 2022-02-04 09:27:07 +09:00
parent 52a399daeb
commit f3770cc647
3 changed files with 39 additions and 15 deletions

View File

@ -109,7 +109,7 @@ typedef struct {
qboolean progdefs_h; // generate progdefs.h
qboolean qccx_escapes; // use qccx escapes instead of standard C
int traditional; // behave more like qcc
qboolean advanced; // behold the power of Ruamoko
int advanced; // behold the power of Ruamoko
qboolean compile; // serparate compilation mode
qboolean partial_link; // partial linking
qboolean preprocess_only;// run only cpp, don't compile

View File

@ -69,6 +69,7 @@ enum {
OPT_NO_DEFAULT_PATHS,
OPT_PROGDEFS,
OPT_QCCX_ESCAPES,
OPT_RUAMOKO,
OPT_TRADITIONAL,
OPT_BUG,
};
@ -92,7 +93,9 @@ static struct option const long_options[] = {
{"progs-src", required_argument, 0, 'P'},
{"qccx-escapes", no_argument, 0, OPT_QCCX_ESCAPES},
{"quiet", no_argument, 0, 'q'},
{"raumoko", no_argument, 0, OPT_RUAMOKO},
{"relocatable", no_argument, 0, 'r'},
{"ruamoko", no_argument, 0, OPT_RUAMOKO},
{"save-temps", no_argument, 0, 'S'},
{"source", required_argument, 0, 's'},
{"traditional", no_argument, 0, OPT_TRADITIONAL},
@ -394,16 +397,22 @@ DecodeArgs (int argc, char **argv)
break;
case OPT_TRADITIONAL:
options.traditional = 2;
options.advanced = false;
options.advanced = 0;
options.code.progsversion = PROG_ID_VERSION;
options.code.const_initializers = true;
break;
case OPT_ADVANCED:
options.traditional = 0;
options.advanced = true;
options.advanced = 1;
options.code.progsversion = PROG_V6P_VERSION;
options.code.const_initializers = false;
break;
case OPT_RUAMOKO:
options.traditional = 0;
options.advanced = 2;
options.code.progsversion = PROG_VERSION;
options.code.const_initializers = false;
break;
case OPT_BLOCK_DOT:
if (optarg) {
char *opts = strdup (optarg);
@ -693,7 +702,7 @@ DecodeArgs (int argc, char **argv)
if (saw_MD)
options.preprocess_only = 0;
if (!source_files && !options.advanced) {
// progs.src mode without --advanced implies --traditional
// progs.src mode without --advanced or --ruamoko implies --traditional
// but --extended overrides
if (!options.traditional)
options.traditional = 2;
@ -712,14 +721,10 @@ DecodeArgs (int argc, char **argv)
if (!options.code.progsversion)
options.code.progsversion = PROG_V6P_VERSION;
if (!options.traditional) {
options.advanced = true;
if (options.code.progsversion < PROG_VERSION) {
add_cpp_def ("-D__RUAMOKO__=1");
add_cpp_def ("-D__RAUMOKO__=1");
} else {
add_cpp_def ("-D__RUAMOKO__=2");
add_cpp_def ("-D__RAUMOKO__=2");
}
// avanced=2 requires the Ruamoko ISA
options.advanced = 2 - (options.code.progsversion < PROG_VERSION);
const char *ruamoko = va (0, "-D__RUAMOKO__=%d", options.advanced);
add_cpp_def (save_string (ruamoko));
if (options.code.ifstring == (qboolean) -1)
options.code.ifstring = false;
if (options.code.short_circuit == (qboolean) -1)
@ -741,6 +746,13 @@ DecodeArgs (int argc, char **argv)
options.code.crc = false;
}
if (options.traditional && options.advanced) {
fprintf (stderr,
"%s: internal error: traditional and advanced twisted\n",
this_program);
abort ();
}
// add the default paths
if (!options.no_default_paths) {
add_cpp_sysinc ("-isystem");

View File

@ -63,21 +63,31 @@ static void
set_traditional (int traditional)
{
switch (traditional) {
case -1:
options.traditional = 0;
options.advanced = 2;
options.code.progsversion = PROG_VERSION;
type_default = &type_int;
type_long_int = &type_long;
type_ulong_uint = &type_ulong;
break;
case 0:
options.traditional = 0;
options.advanced = true;
options.advanced = 1;
options.code.progsversion = PROG_V6P_VERSION;
type_default = &type_int;
type_long_int = &type_int;
type_ulong_uint = &type_uint;
break;
case 1:
options.traditional = 1;
options.advanced = false;
options.advanced = 0;
options.code.progsversion = PROG_ID_VERSION;
type_default = &type_float;
break;
case 2:
options.traditional = 2;
options.advanced = false;
options.advanced = 0;
options.code.progsversion = PROG_ID_VERSION;
type_default = &type_float;
break;
@ -157,6 +167,8 @@ pragma_process ()
set_traditional (1);
} else if (!strcmp (id, "advanced")) {
set_traditional (0);
} else if (!strcmp (id, "ruamoko") || !strcmp (id, "raumoko")) {
set_traditional (-1);
} else if (!strcmp (id, "bug")) {
set_bug (pragma_args->next);
} else if (!strcmp (id, "warn")) {