mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add -MT option
Allows overriding the output file in dependencies, which also allows outputting those without also outputting the object file. This, again, mimicks GCC's option.
This commit is contained in:
@@ -35,6 +35,7 @@ extern struct sOptions DefaultOptions;
|
|||||||
extern struct sOptions CurrentOptions;
|
extern struct sOptions CurrentOptions;
|
||||||
|
|
||||||
extern FILE *dependfile;
|
extern FILE *dependfile;
|
||||||
|
extern char *tzTargetFileName;
|
||||||
|
|
||||||
extern bool oGeneratePhonyDeps;
|
extern bool oGeneratePhonyDeps;
|
||||||
|
|
||||||
|
|||||||
@@ -338,7 +338,8 @@ FILE *fstk_FindFile(char *fname, char **incPathUsed)
|
|||||||
|
|
||||||
if (f != NULL || errno != ENOENT) {
|
if (f != NULL || errno != ENOENT) {
|
||||||
if (dependfile) {
|
if (dependfile) {
|
||||||
fprintf(dependfile, "%s: %s\n", tzObjectname, fname);
|
fprintf(dependfile, "%s: %s\n", tzTargetFileName,
|
||||||
|
fname);
|
||||||
if (oGeneratePhonyDeps)
|
if (oGeneratePhonyDeps)
|
||||||
fprintf(dependfile, "%s:\n", fname);
|
fprintf(dependfile, "%s:\n", fname);
|
||||||
}
|
}
|
||||||
@@ -366,8 +367,8 @@ FILE *fstk_FindFile(char *fname, char **incPathUsed)
|
|||||||
|
|
||||||
if (f != NULL || errno != ENOENT) {
|
if (f != NULL || errno != ENOENT) {
|
||||||
if (dependfile) {
|
if (dependfile) {
|
||||||
fprintf(dependfile, "%s: %s\n", tzObjectname,
|
fprintf(dependfile, "%s: %s\n",
|
||||||
fname);
|
tzTargetFileName, fname);
|
||||||
if (oGeneratePhonyDeps)
|
if (oGeneratePhonyDeps)
|
||||||
fprintf(dependfile, "%s:\n", fname);
|
fprintf(dependfile, "%s:\n", fname);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ uint32_t unionStart[128], unionSize[128];
|
|||||||
FILE *dependfile;
|
FILE *dependfile;
|
||||||
|
|
||||||
bool oGeneratePhonyDeps;
|
bool oGeneratePhonyDeps;
|
||||||
|
char *tzTargetFileName;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Option stack
|
* Option stack
|
||||||
@@ -272,8 +273,8 @@ static void print_usage(void)
|
|||||||
{
|
{
|
||||||
fputs(
|
fputs(
|
||||||
"Usage: rgbasm [-EhLVvw] [-b chars] [-D name[=value]] [-g chars] [-i path]\n"
|
"Usage: rgbasm [-EhLVvw] [-b chars] [-D name[=value]] [-g chars] [-i path]\n"
|
||||||
" [-M depend_file] [-MP] [-o out_file] [-p pad_value] [-r depth]\n"
|
" [-M depend_file] [-MP] [-MT target_file] [-o out_file]\n"
|
||||||
" [-W warning] <file> ...\n"
|
" [-p pad_value] [-r depth] [-W warning] <file> ...\n"
|
||||||
"Useful options:\n"
|
"Useful options:\n"
|
||||||
" -E, --export-all export all labels\n"
|
" -E, --export-all export all labels\n"
|
||||||
" -M, --dependfile <path> set the output dependency file\n"
|
" -M, --dependfile <path> set the output dependency file\n"
|
||||||
@@ -309,6 +310,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
nMaxRecursionDepth = 64;
|
nMaxRecursionDepth = 64;
|
||||||
oGeneratePhonyDeps = false;
|
oGeneratePhonyDeps = false;
|
||||||
|
tzTargetFileName = NULL;
|
||||||
|
|
||||||
DefaultOptions.gbgfx[0] = '0';
|
DefaultOptions.gbgfx[0] = '0';
|
||||||
DefaultOptions.gbgfx[1] = '1';
|
DefaultOptions.gbgfx[1] = '1';
|
||||||
@@ -364,7 +366,7 @@ int main(int argc, char *argv[])
|
|||||||
newopt.optimizeloads = false;
|
newopt.optimizeloads = false;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
ep = strchr("P", optarg[0]);
|
ep = strchr("PT", optarg[0]);
|
||||||
if (!ep || !*ep || optarg[1]) {
|
if (!ep || !*ep || optarg[1]) {
|
||||||
dependfile = fopen(optarg, "w");
|
dependfile = fopen(optarg, "w");
|
||||||
if (dependfile == NULL)
|
if (dependfile == NULL)
|
||||||
@@ -376,6 +378,12 @@ int main(int argc, char *argv[])
|
|||||||
oGeneratePhonyDeps = true;
|
oGeneratePhonyDeps = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'T':
|
||||||
|
if (optind == argc)
|
||||||
|
errx(1, "-MT takes a target file name argument");
|
||||||
|
tzTargetFileName = argv[optind];
|
||||||
|
optind++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -418,6 +426,9 @@ int main(int argc, char *argv[])
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
|
if (tzTargetFileName == NULL)
|
||||||
|
tzTargetFileName = tzObjectname;
|
||||||
|
|
||||||
opt_SetCurrentOptions(&newopt);
|
opt_SetCurrentOptions(&newopt);
|
||||||
|
|
||||||
DefaultOptions = CurrentOptions;
|
DefaultOptions = CurrentOptions;
|
||||||
@@ -435,10 +446,10 @@ int main(int argc, char *argv[])
|
|||||||
printf("Assembling %s\n", tzMainfile);
|
printf("Assembling %s\n", tzMainfile);
|
||||||
|
|
||||||
if (dependfile) {
|
if (dependfile) {
|
||||||
if (!tzObjectname)
|
if (!tzTargetFileName)
|
||||||
errx(1, "Dependency files can only be created if an output object file is specified.\n");
|
errx(1, "Dependency files can only be created if a target file is specified with either -o or -MT.\n");
|
||||||
|
|
||||||
fprintf(dependfile, "%s: %s\n", tzObjectname, tzMainfile);
|
fprintf(dependfile, "%s: %s\n", tzTargetFileName, tzMainfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
nStartClock = clock();
|
nStartClock = clock();
|
||||||
|
|||||||
Reference in New Issue
Block a user