mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Move the dependency option handling to cpp.c
This cleans up options.c a little more and prepares for implementing dependency tracking with the built-in preprocessor.
This commit is contained in:
parent
92832a3b2c
commit
ae3a6c8b90
3 changed files with 106 additions and 9 deletions
|
@ -37,6 +37,7 @@ void parse_cpp_name (void);
|
|||
void add_cpp_undef (const char *arg);
|
||||
void add_cpp_def (const char *arg);
|
||||
|
||||
int cpp_depend (const char *opt, const char *arg);
|
||||
int cpp_include (const char *opt, const char *arg);
|
||||
void cpp_define (const char *arg);
|
||||
void cpp_undefine (const char *arg);
|
||||
|
|
|
@ -140,6 +140,102 @@ add_cpp_def (const char *arg)
|
|||
cpp_argc++;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_ (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-M");
|
||||
options.preprocess_only = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_D (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MD");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_F (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MF");
|
||||
add_cpp_def (arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_G (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MG");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_M (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MM");
|
||||
options.preprocess_only = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_MD (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MMD");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_P (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MP");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_Q (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MQ");
|
||||
add_cpp_def (arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_depend_T (const char *opt, const char *arg)
|
||||
{
|
||||
add_cpp_def ("-MT");
|
||||
add_cpp_def (arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define CPP_DEPEND(name) {#name, cpp_depend_##name}
|
||||
int
|
||||
cpp_depend (const char *opt, const char *arg)
|
||||
{
|
||||
static cpp_func_t depend_funcs[] = {
|
||||
CPP_DEPEND (),
|
||||
CPP_DEPEND (D),
|
||||
CPP_DEPEND (F),
|
||||
CPP_DEPEND (G),
|
||||
CPP_DEPEND (M),
|
||||
CPP_DEPEND (MD),
|
||||
CPP_DEPEND (P),
|
||||
CPP_DEPEND (Q),
|
||||
CPP_DEPEND (T),
|
||||
{}
|
||||
};
|
||||
if (!opt) {
|
||||
opt = "";
|
||||
}
|
||||
for (int i = 0; depend_funcs[i].name; i++) {
|
||||
if (!strcmp (opt, depend_funcs[i].name)) {
|
||||
return depend_funcs[i].func (opt, arg);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#undef CPP_DEPEND
|
||||
|
||||
static int
|
||||
cpp_include_I (const char *opt, const char *arg)
|
||||
{
|
||||
|
|
|
@ -770,16 +770,16 @@ DecodeArgs (int argc, char **argv)
|
|||
cpp_undefine (optarg);
|
||||
break;
|
||||
case 'M':
|
||||
options.preprocess_only = 1;
|
||||
if (optarg) {
|
||||
add_cpp_def (nva ("-M%s", optarg));
|
||||
if (strchr (optarg, 'D'))
|
||||
{
|
||||
if (optarg && strchr (optarg, 'D')) {
|
||||
saw_MD = 1;
|
||||
if (strchr ("FQT", optarg[0]))
|
||||
add_cpp_def (argv[optind++]);
|
||||
} else {
|
||||
options.preprocess_only = 1;
|
||||
add_cpp_def (nva ("-M"));
|
||||
}
|
||||
int o = cpp_depend (optarg, argv[optind]);
|
||||
if (o < 0) {
|
||||
usage (1);
|
||||
} else {
|
||||
optind += o;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OPT_NO_DEFAULT_PATHS:
|
||||
|
|
Loading…
Reference in a new issue