mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Reimplement -M variants using long options
This commit is contained in:
@@ -263,6 +263,9 @@ static char *make_escape(const char *str)
|
|||||||
/* Short options */
|
/* Short options */
|
||||||
static char const *optstring = "b:D:Eg:hi:LM:o:p:r:VvW:w";
|
static char const *optstring = "b:D:Eg:hi:LM:o:p:r:VvW:w";
|
||||||
|
|
||||||
|
/* Variables for the long-only options */
|
||||||
|
static int depType; /* Variants of `-M` */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Equivalent long options
|
* Equivalent long options
|
||||||
* Please keep in the same order as short opts
|
* Please keep in the same order as short opts
|
||||||
@@ -282,6 +285,10 @@ static struct option const longopts[] = {
|
|||||||
{ "include", required_argument, NULL, 'i' },
|
{ "include", required_argument, NULL, 'i' },
|
||||||
{ "preserve-ld", no_argument, NULL, 'L' },
|
{ "preserve-ld", no_argument, NULL, 'L' },
|
||||||
{ "dependfile", required_argument, NULL, 'M' },
|
{ "dependfile", required_argument, NULL, 'M' },
|
||||||
|
{ "MG", no_argument, &depType, 'G' },
|
||||||
|
{ "MP", no_argument, &depType, 'P' },
|
||||||
|
{ "MT", required_argument, &depType, 'T' },
|
||||||
|
{ "MQ", required_argument, &depType, 'Q' },
|
||||||
{ "output", required_argument, NULL, 'o' },
|
{ "output", required_argument, NULL, 'o' },
|
||||||
{ "pad-value", required_argument, NULL, 'p' },
|
{ "pad-value", required_argument, NULL, 'p' },
|
||||||
{ "recursion-depth", required_argument, NULL, 'r' },
|
{ "recursion-depth", required_argument, NULL, 'r' },
|
||||||
@@ -391,8 +398,6 @@ int main(int argc, char *argv[])
|
|||||||
newopt.optimizeloads = false;
|
newopt.optimizeloads = false;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
ep = strchr("GPQT", optarg[0]);
|
|
||||||
if (!ep || !*ep || optarg[1]) {
|
|
||||||
if (!strcmp("-", optarg))
|
if (!strcmp("-", optarg))
|
||||||
dependfile = stdout;
|
dependfile = stdout;
|
||||||
else
|
else
|
||||||
@@ -400,41 +405,6 @@ int main(int argc, char *argv[])
|
|||||||
if (dependfile == NULL)
|
if (dependfile == NULL)
|
||||||
err(1, "Could not open dependfile %s",
|
err(1, "Could not open dependfile %s",
|
||||||
optarg);
|
optarg);
|
||||||
} else {
|
|
||||||
switch (optarg[0]) {
|
|
||||||
case 'G':
|
|
||||||
oGeneratedMissingIncludes = true;
|
|
||||||
break;
|
|
||||||
case 'P':
|
|
||||||
oGeneratePhonyDeps = true;
|
|
||||||
break;
|
|
||||||
case 'Q':
|
|
||||||
case 'T':
|
|
||||||
if (optind == argc)
|
|
||||||
errx(1, "-M%c takes a target file name argument",
|
|
||||||
optarg[0]);
|
|
||||||
ep = argv[optind];
|
|
||||||
optind++;
|
|
||||||
if (optarg[0] == 'Q')
|
|
||||||
ep = make_escape(ep);
|
|
||||||
|
|
||||||
nTargetFileNameLen += strlen(ep) + 1;
|
|
||||||
tzTargetFileName =
|
|
||||||
realloc(tzTargetFileName,
|
|
||||||
nTargetFileNameLen + 1);
|
|
||||||
if (tzTargetFileName == NULL)
|
|
||||||
err(1, "Cannot append new file to target file list");
|
|
||||||
strcat(tzTargetFileName, ep);
|
|
||||||
if (optarg[0] == 'Q')
|
|
||||||
free(ep);
|
|
||||||
char *ptr = tzTargetFileName +
|
|
||||||
strlen(tzTargetFileName);
|
|
||||||
*ptr++ = ' ';
|
|
||||||
*ptr = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
out_SetFileName(optarg);
|
out_SetFileName(optarg);
|
||||||
@@ -467,6 +437,45 @@ int main(int argc, char *argv[])
|
|||||||
case 'w':
|
case 'w':
|
||||||
newopt.warnings = false;
|
newopt.warnings = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Long-only options */
|
||||||
|
case 0:
|
||||||
|
if (depType) {
|
||||||
|
switch (depType) {
|
||||||
|
case 'G':
|
||||||
|
oGeneratedMissingIncludes = true;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
oGeneratePhonyDeps = true;
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
case 'T':
|
||||||
|
if (optind == argc)
|
||||||
|
errx(1, "-M%c takes a target file name argument",
|
||||||
|
depType);
|
||||||
|
ep = optarg;
|
||||||
|
if (depType == 'Q')
|
||||||
|
ep = make_escape(ep);
|
||||||
|
|
||||||
|
nTargetFileNameLen += strlen(ep) + 1;
|
||||||
|
tzTargetFileName =
|
||||||
|
realloc(tzTargetFileName,
|
||||||
|
nTargetFileNameLen + 1);
|
||||||
|
if (tzTargetFileName == NULL)
|
||||||
|
err(1, "Cannot append new file to target file list");
|
||||||
|
strcat(tzTargetFileName, ep);
|
||||||
|
if (depType == 'Q')
|
||||||
|
free(ep);
|
||||||
|
char *ptr = tzTargetFileName +
|
||||||
|
strlen(tzTargetFileName);
|
||||||
|
*ptr++ = ' ';
|
||||||
|
*ptr = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Unrecognized options */
|
||||||
default:
|
default:
|
||||||
print_usage();
|
print_usage();
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
|||||||
Reference in New Issue
Block a user